/* ========================================
   3D Kitchen Planner - Styles
   ======================================== */

:root {
    /* Colors */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #8b5cf6;
    --accent: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    /* Neutrals */
    --bg-dark: #0f172a;
    --bg-darker: #020617;
    --surface: #1e293b;
    --surface-light: #334155;
    --border: #475569;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    
    /* Effects */
    --glass-bg: rgba(30, 41, 59, 0.8);
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    
    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease;
    
    /* Spacing */
    --panel-width: 360px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

/* ========================================
   Loading Screen
   ======================================== */

#loading-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, var(--bg-darker) 0%, var(--bg-dark) 50%, #1a1a2e 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    text-align: center;
}

.spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 24px;
    border: 3px solid var(--surface);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loader-content h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.loader-content p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.progress-bar {
    width: 200px;
    height: 4px;
    background: var(--surface);
    border-radius: 2px;
    margin: 0 auto 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.875rem;
    color: var(--text-dim);
}

/* ========================================
   Main Container
   ======================================== */

#app-container {
    position: relative;
    width: 100%;
    height: 100%;
}

#canvas-container {
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #1a1a2e 0%, var(--bg-dark) 100%);
}

#canvas-container canvas {
    display: block;
}

/* ========================================
   Top Navigation
   ======================================== */

.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 1.125rem;
}

.nav-controls {
    display: flex;
    gap: 8px;
}

.nav-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
}

.nav-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    transform: translateY(-2px);
}

/* ========================================
   Side Panel
   ======================================== */

.side-panel {
    position: fixed;
    top: 64px;
    right: 0;
    bottom: 60px;
    width: var(--panel-width);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    z-index: 90;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.side-panel.collapsed {
    transform: translateX(calc(100% - 48px));
}

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

.panel-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.panel-toggle {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.panel-toggle:hover {
    color: var(--text);
}

.side-panel.collapsed .panel-toggle svg {
    transform: rotate(180deg);
}

/* Category Tabs */
.category-tabs {
    display: flex;
    gap: 8px;
    padding: 16px 20px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.category-tabs::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    padding: 8px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn:hover {
    background: var(--surface-light);
    color: var(--text);
}

.tab-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Appliance Grid */
.appliance-grid {
    flex: 1;
    padding: 0 20px 20px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    align-content: start;
}

.appliance-grid::-webkit-scrollbar {
    width: 6px;
}

.appliance-grid::-webkit-scrollbar-track {
    background: transparent;
}

.appliance-grid::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* Appliance Card */
.appliance-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
}

.appliance-card:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(99, 102, 241, 0.2);
}

.appliance-card.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
}

.appliance-card.hidden {
    display: none;
}

.card-image {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--surface-light), var(--surface));
    padding: 12px;
}

/* Appliance Previews (CSS-based 3D look) */
.appliance-preview {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    position: relative;
}

.appliance-preview.fridge {
    background: linear-gradient(180deg, var(--color) 0%, var(--color-dark) 100%);
    border-radius: 6px;
    position: relative;
}

.appliance-preview.fridge::before {
    content: '';
    position: absolute;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 35%;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

.appliance-preview.fridge::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 40%;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

.appliance-preview.dishwasher {
    background: linear-gradient(180deg, var(--color) 0%, var(--color-dark) 100%);
    border-radius: 4px;
}

.appliance-preview.dishwasher::before {
    content: '';
    position: absolute;
    top: 15%;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 8%;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

.appliance-preview.oven {
    background: linear-gradient(180deg, var(--color) 0%, var(--color-dark) 100%);
    border-radius: 4px;
}

.appliance-preview.oven::before {
    content: '';
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    height: 30%;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 2px;
}

.appliance-preview.oven::after {
    content: '';
    position: absolute;
    bottom: 15%;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    height: 30%;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 2px;
}

.appliance-preview.microwave {
    background: linear-gradient(180deg, var(--color) 0%, var(--color-dark) 100%);
    border-radius: 4px;
}

.appliance-preview.microwave::before {
    content: '';
    position: absolute;
    top: 15%;
    left: 10%;
    width: 55%;
    height: 60%;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 2px;
}

/* Color Variants */
.appliance-preview.silver {
    --color: #c0c0c0;
    --color-dark: #8a8a8a;
}

.appliance-preview.black {
    --color: #3a3a3a;
    --color-dark: #1a1a1a;
}

.appliance-preview.white {
    --color: #f0f0f0;
    --color-dark: #d0d0d0;
}

.card-info {
    padding: 12px;
}

.card-info h4 {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.card-info p {
    font-size: 0.625rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.card-info .price {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
}

.select-btn {
    width: 100%;
    padding: 10px;
    background: transparent;
    border: none;
    border-top: 1px solid var(--border);
    color: var(--primary-light);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.select-btn:hover {
    background: var(--primary);
    color: white;
}

.appliance-card.selected .select-btn {
    background: var(--primary);
    color: white;
}

.appliance-card.selected .select-btn::before {
    content: '✓ ';
}

/* ========================================
   Bottom Info Bar
   ======================================== */

.info-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 32px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    z-index: 100;
}

.selected-info,
.total-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.value {
    font-weight: 600;
}

.value.price {
    color: var(--accent);
    font-size: 1.125rem;
}

.action-btn {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: 10px;
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

/* ========================================
   Tooltip
   ======================================== */

.tooltip {
    position: fixed;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    pointer-events: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s, transform 0.2s;
    z-index: 200;
}

.tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.tooltip h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.tooltip p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 768px) {
    :root {
        --panel-width: 100%;
    }

    .side-panel {
        top: auto;
        bottom: 60px;
        left: 0;
        right: 0;
        height: 50vh;
        border-left: none;
        border-top: 1px solid var(--glass-border);
        border-radius: 20px 20px 0 0;
        transform: translateY(calc(100% - 60px));
    }

    .side-panel.expanded {
        transform: translateY(0);
    }

    .appliance-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .panel-header h2 {
        font-size: 1rem;
    }

    .tab-btn {
        padding: 6px 12px;
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    .appliance-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .info-bar {
        flex-wrap: wrap;
        height: auto;
        padding: 12px;
        gap: 12px;
    }

    .action-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ========================================
   Animations
   ======================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.appliance-card {
    animation: fadeIn 0.4s ease forwards;
}

.appliance-card:nth-child(1) { animation-delay: 0.05s; }
.appliance-card:nth-child(2) { animation-delay: 0.1s; }
.appliance-card:nth-child(3) { animation-delay: 0.15s; }
.appliance-card:nth-child(4) { animation-delay: 0.2s; }
.appliance-card:nth-child(5) { animation-delay: 0.25s; }
.appliance-card:nth-child(6) { animation-delay: 0.3s; }
.appliance-card:nth-child(7) { animation-delay: 0.35s; }
.appliance-card:nth-child(8) { animation-delay: 0.4s; }
.appliance-card:nth-child(9) { animation-delay: 0.45s; }
.appliance-card:nth-child(10) { animation-delay: 0.5s; }
