/*
 * Frame Calculator – Gallery Wall Layout calculator styles (inputs, frame list, preview, results, nail positions).
 * v13.3: moved here from salon-wall-calculator.html, unchanged, so the Gallery Wall Planner page can use them too.
 * Page parts (how-to, FAQ, related links) stay in salon-wall-calculator.html.
 */
/* Calculator Container */
.calc-page-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem 3rem;
}

.calc-grid {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 1.5rem;
    align-items: start;
}

/* Input Panel */
.input-panel {
    position: sticky;
    top: calc(var(--header-height) + 1rem);
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-section {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.card-section:last-child {
    border-bottom: none;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.section-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

/* Mode Tabs */
.mode-tabs {
    display: flex;
    background: var(--bg-secondary);
    padding: 0.25rem;
    border-radius: var(--radius-md);
    gap: 0.25rem;
}

.mode-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.625rem 0.25rem;
    border: none;
    border-radius: calc(var(--radius-md) - 2px);
    background: transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-family: inherit;
}

.mode-tab:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

.mode-tab.active {
    background: var(--bg-card);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

.mode-tab svg {
    width: 20px;
    height: 20px;
}

/* Unit Toggle */
.unit-toggle {
    display: flex;
    background: var(--bg-secondary);
    padding: 0.15rem;
    border-radius: var(--radius-sm);
    gap: 0.15rem;
}

.unit-btn {
    padding: 0.25rem 0.625rem;
    border: none;
    border-radius: calc(var(--radius-sm) - 2px);
    background: transparent;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all var(--transition-fast);
    font-family: inherit;
}

.unit-btn.active {
    background: var(--bg-card);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

/* Input Grid */
.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.input-grid.single {
    grid-template-columns: 1fr;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.input-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition-fast);
}

.input-wrapper:focus-within {
    border-color: var(--accent);
}

.input-field {
    flex: 1;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: none;
    background: none;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text-primary);
    outline: none;
    -moz-appearance: textfield;
}

.input-field::-webkit-inner-spin-button,
.input-field::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-suffix {
    padding: 0.5rem 0.75rem 0.5rem 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Frame List */
.frame-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.frame-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: border-color var(--transition-fast);
}

.frame-card:hover {
    border-color: color-mix(in srgb, var(--border) 50%, var(--text-muted) 50%);
}

.frame-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    cursor: pointer;
    user-select: none;
}

.frame-card-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.frame-card-name {
    font-size: 0.825rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.frame-card-summary {
    flex: 1;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: right;
    white-space: nowrap;
}

.frame-card-toggle {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: transform var(--transition-fast);
    display: flex;
    align-items: center;
}

.frame-card-toggle.expanded {
    transform: rotate(180deg);
}

.frame-card-remove {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    transition: color var(--transition-fast);
}

.frame-card-remove:hover {
    color: var(--error);
}

.frame-card-remove:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.frame-card-drag {
    padding: 0.375rem 0;
    cursor: grab;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    opacity: 0.5;
    transition: opacity var(--transition-fast);
    touch-action: none;
}

.frame-card-drag:hover {
    opacity: 1;
}

.frame-card.dragging-source {
    opacity: 0.3;
}

.frame-card.drag-above {
    box-shadow: 0 -2px 0 0 var(--accent);
}

.frame-card.drag-below {
    box-shadow: 0 2px 0 0 var(--accent);
}

.frame-card-body {
    padding: 0.75rem;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.frame-card-body[hidden] {
    display: none;
}

.frame-card-sizes {
    margin-bottom: 0.625rem;
}

.size-preset {
    width: 100%;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-family: inherit;
    cursor: pointer;
}

.frame-card-actions {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.5rem;
}

.frame-action-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.725rem;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.frame-action-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.add-frame-btn {
    width: 100%;
    padding: 0.625rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-top: 0.5rem;
}

.add-frame-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-subtle);
}

.add-frame-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Results Panel */
.results-panel {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Diagram */
.diagram-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.diagram-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.diagram-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.diagram-actions {
    display: flex;
    gap: 0.5rem;
}

.diagram-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.diagram-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.diagram-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.diagram-canvas {
    padding: 1rem;
}

.diagram-svg {
    width: 100%;
    height: auto;
}

.diagram-svg.drag-mode {
    cursor: crosshair;
}

.diagram-svg .frame-group {
    cursor: default;
}

.diagram-svg.drag-mode .frame-group {
    cursor: grab;
}

.diagram-svg.drag-mode .frame-group.dragging {
    cursor: grabbing;
}

.diagram-hint {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0 1rem 0.75rem;
}

/* Warning Box */
.warning-box {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: #fef3cd;
    border: 1px solid #ffc107;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    color: #664d03;
}

.warning-box[hidden] {
    display: none;
}

[data-theme="dark"] .warning-box {
    background: #332701;
    border-color: #665000;
    color: #ffda6a;
}

.warning-box-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

/* Results Grid */
.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
}

.result-card.primary {
    grid-column: span 2;
    background: var(--accent-subtle);
    border-color: var(--accent);
}
/* readable primary card on subtle background (both themes) */
.result-card.primary .result-label { color: var(--accent); opacity: 0.8; }
.result-card.primary .result-value { color: var(--accent); }
.result-card.primary .result-desc { color: var(--text-secondary); }


.result-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.375rem;
}

.result-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.result-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Positions Table */
.positions-table {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.positions-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.positions-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.positions-cols {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1.2fr 1.2fr;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.position-row {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1.2fr 1.2fr;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.85rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    align-items: center;
}

.position-row:last-child {
    border-bottom: none;
}

.position-frame {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.position-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.position-nail {
    font-weight: 600;
    color: var(--accent);
}

/* Reassurance */
.reassurance {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.reassurance svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: var(--accent);
}

.reassurance-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Responsive */
@media (max-width: 1024px) {
    .calc-grid {
        grid-template-columns: 1fr;
    }

    .input-panel {
        position: static;
    }
}

@media (max-width: 768px) {
    .results-grid {
        grid-template-columns: 1fr;
    }

    .result-card.primary {
        grid-column: span 1;
    }

    .positions-cols,
    .position-row {
        grid-template-columns: 1fr 0.8fr 1fr 1fr;
        font-size: 0.75rem;
        gap: 0.25rem;
        padding: 0.5rem 0.75rem;
    }

    .mode-tabs {
        flex-wrap: wrap;
    }

    .mode-tab {
        flex: 1 1 45%;
    }
}

@media (max-width: 480px) {
    .input-grid {
        grid-template-columns: 1fr;
    }
}

/* Print Styles */
@media print {
    .input-panel, .diagram-btn, .reassurance, .add-frame-btn {
        display: none !important;
    }

    .calc-grid {
        display: block;
    }
}

/* ===== v13.4: bigger tap targets in the frame list and the unit switch ===== */
.frame-card-header { padding: 0 0 0 0.5rem; min-height: 44px; gap: 0.4rem; }
.frame-card-toggle, .frame-card-remove {
    width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
    flex: none;
    border-radius: var(--radius-sm);
}
.frame-card-remove { margin-left: 2px; }   /* a small gap so a slightly-off tap doesn't hit the other one */
.frame-card-toggle svg, .frame-card-remove svg { width: 14px; height: 14px; }
.frame-card-toggle:focus-visible, .frame-card-remove:focus-visible, .frame-card-drag:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.frame-card-drag { width: 28px; height: 44px; padding: 0; justify-content: center; flex: none; border-radius: var(--radius-sm); }
@media (max-width: 768px), (pointer: coarse) {
    .unit-btn { min-height: 36px; min-width: 44px; padding: 0 0.75rem; font-size: 0.8125rem; }
    .diagram-btn { min-height: 40px; padding: 0 0.75rem; font-size: 0.8125rem; }
}
