/* =============================================================================
   Interior Design PoC — Premium Dark Theme
   ============================================================================= */

/* --- Reset & Variables --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Palette */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a25;
    --bg-card-hover: #22222f;
    --bg-glass: rgba(26, 26, 37, 0.85);

    --accent: #6c5ce7;
    --accent-glow: rgba(108, 92, 231, 0.3);
    --accent-light: #a29bfe;
    --accent-success: #00cec9;
    --accent-warning: #fdcb6e;
    --accent-danger: #ff6b6b;

    --text-primary: #f0f0f5;
    --text-secondary: #8888a0;
    --text-muted: #555570;

    --border: rgba(255, 255, 255, 0.06);
    --border-active: rgba(108, 92, 231, 0.4);

    /* Layout */
    --sidebar-width: 320px;
    --radius: 12px;
    --radius-sm: 8px;

    /* Transitions */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow: hidden;
}

/* =============================================================================
   SIDEBAR
   ============================================================================= */

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 20px;
    overflow-y: auto;
    height: 100vh;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary);
}

.logo svg {
    color: var(--accent);
}

.badge {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 8px;
    background: var(--accent-glow);
    color: var(--accent-light);
    border-radius: 6px;
}

/* --- Phase Tracker --- */

.phase-tracker {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.phase-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    transition: all 0.3s var(--ease);
    opacity: 0.4;
}

.phase-step.active {
    opacity: 1;
    background: var(--bg-card);
}

.phase-step.completed {
    opacity: 0.7;
}

.phase-step.completed .step-dot {
    background: var(--accent-success);
    color: #fff;
    border-color: var(--accent-success);
}

.step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    border: 2px solid var(--text-muted);
    color: var(--text-muted);
    flex-shrink: 0;
    transition: all 0.3s var(--ease);
}

.phase-step.active .step-dot {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    box-shadow: 0 0 12px var(--accent-glow);
}

.step-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.step-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.step-desc {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* --- Info Panel --- */

.info-panel,
.config-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.info-panel h3,
.config-panel h3,
.download-panel h3 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

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

.info-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.info-value {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent-light);
    font-variant-numeric: tabular-nums;
}

/* --- Config Panel Inputs --- */

.input-group {
    margin-bottom: 10px;
}

.input-group:last-child {
    margin-bottom: 0;
}

.input-group label {
    display: block;
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-weight: 500;
}

.input-group input[type="number"] {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    transition: border 0.3s var(--ease);
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* --- Buttons --- */

.actions-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: all 0.25s var(--ease);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #5a4bd1);
    color: #fff;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

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

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

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

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px dashed var(--border);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent-light);
    background: rgba(108, 92, 231, 0.05);
}

.btn-download {
    background: var(--bg-card);
    color: var(--accent-light);
    border: 1px solid var(--border);
    text-align: center;
    margin-bottom: 6px;
}

.btn-download:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
}

/* --- Phase 2 Navigation --- */

.phase2-panel {
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.1), rgba(0, 206, 201, 0.08));
    border: 1px solid var(--border-active);
    border-radius: var(--radius);
    padding: 16px;
}

.phase2-panel h3 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-light);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-phase2 {
    width: 100%;
    background: linear-gradient(135deg, var(--accent), var(--accent-success));
    color: #fff;
    box-shadow: 0 4px 18px rgba(108, 92, 231, 0.35);
    font-size: 0.85rem;
}

.btn-phase2:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(108, 92, 231, 0.45);
}

.btn-phase2:active {
    transform: translateY(0);
}

/* --- Download Panel --- */

.download-panel {
    margin-top: auto;
}

/* =============================================================================
   MAIN CONTENT
   ============================================================================= */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 20px;
    overflow-y: auto;
    height: 100vh;
}

/* --- Canvas --- */

.canvas-wrapper {
    flex: 1;
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

#main-canvas {
    max-width: 100%;
    max-height: 100%;
    cursor: crosshair;
    image-rendering: auto;
}

.canvas-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    pointer-events: none;
    transition: opacity 0.4s var(--ease);
    white-space: nowrap;
}

.canvas-hint strong {
    color: var(--accent-light);
}

/* --- Mask Preview --- */

.mask-preview {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.mask-preview h3 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.mask-preview-images {
    display: flex;
    gap: 16px;
}

.preview-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
}

.preview-item img {
    max-width: 300px;
    max-height: 200px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: #000;
}

.preview-item span {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.mask-stats {
    margin-top: 10px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* =============================================================================
   MODAL
   ============================================================================= */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s var(--ease);
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
    animation: slideUp 0.35s var(--ease);
}

.modal h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.modal p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    line-height: 1.5;
}

.modal-hint {
    font-size: 0.75rem !important;
    color: var(--text-muted) !important;
    margin-bottom: 20px !important;
}

.modal-input-group {
    position: relative;
    margin-bottom: 24px;
}

.modal-input-group input {
    width: 100%;
    background: var(--bg-primary);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 50px 14px 16px;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-family: inherit;
    font-weight: 600;
    transition: border 0.3s var(--ease);
}

.modal-input-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

.input-suffix {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* =============================================================================
   TOAST NOTIFICATIONS
   ============================================================================= */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    font-size: 0.82rem;
    color: var(--text-primary);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    animation: slideInRight 0.35s var(--ease);
    max-width: 360px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.success {
    border-left: 3px solid var(--accent-success);
}

.toast.error {
    border-left: 3px solid var(--accent-danger);
}

.toast.info {
    border-left: 3px solid var(--accent);
}

/* =============================================================================
   ANIMATIONS
   ============================================================================= */

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 900px) {
    body {
        flex-direction: column;
        overflow-y: auto;
    }

    .sidebar {
        width: 100%;
        min-width: auto;
        height: auto;
        flex-direction: row;
        flex-wrap: wrap;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .phase-tracker {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .main-content {
        height: auto;
        min-height: 60vh;
    }

    .canvas-wrapper {
        min-height: 300px;
    }
}