/* ========================================
   BASE CSS - DARK/LIGHT MODE + PRINT
   DIYCalcHub V3 - Professional Edition
   ======================================== */

/* ========================================
   DARK MODE (Default)
   ======================================== */
:root {
    /* Colors - Dark Mode */
    --bg-primary: #020409;
    --bg-secondary: #03050a;
    --bg-card: rgba(12, 20, 44, 0.82);
    --bg-input: #0f1730;
    --bg-input-hover: #141e3a;
    
    /* Text */
    --text-primary: #e8eef8;
    --text-secondary: #c4d0e4;
    --text-muted: #94a3b8;
    
    /* Brand Colors */
    --accent-primary: #FFA500;
    --accent-gold: #D4B483;
    --accent-secondary: #FF8C00;
    
    /* Borders */
    --border-primary: rgba(255, 165, 0, 0.2);
    --border-secondary: rgba(255, 255, 255, 0.1);
    --border-muted: rgba(100, 116, 139, 0.3);
    
    /* Shadows */
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-button: 0 2px 8px rgba(255, 165, 0, 0.25);
    
    /* Glassmorphism */
    --glass-bg: rgba(7, 13, 31, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --backdrop-blur: blur(4px);
}

/* ========================================
   LIGHT MODE (OPPDATERT: Slate & White)
   ======================================== */
[data-theme="light"] {
    /* Colors - Light Mode */
    --bg-primary: #F9FAFB;
    --bg-secondary: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-input: #FFFFFF;
    --bg-input-hover: #F3F4F6;
    --bg-shopping-list: #FFEDD5;

    /* Text — high contrast */
    --text-primary: #111827;
    --text-secondary: #485563;
    --text-muted: #6B7280;

    /* Brand Colors (unchanged) */
    --accent-primary: #FFA500;
    --accent-gold: #D4B483;
    --accent-secondary: #FF8C00;

    /* Borders */
    --border-primary: rgba(255, 165, 0, 0.35);
    --border-secondary: #E5E7EB;
    --border-muted: #E5E7EB;

    /* Shadows — one clear signal per card */
    --shadow-card: 0 1px 4px rgba(0, 0, 0, 0.08);
    --shadow-button: 0 2px 4px rgba(255, 165, 0, 0.2);

    /* Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.97);
    --glass-border: #E5E7EB;
    --backdrop-blur: blur(12px);
}

/* ========================================
   BASE STYLES
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-primary);
}

::selection {
    background: var(--accent-primary);
    color: var(--bg-primary);
}

html {
    scroll-behavior: smooth;
}

/* ========================================
   PROFESSIONAL PDF PRINT STYLES
   ======================================== */
@media print {
    :root, [data-theme="dark"] {
        --bg-primary: #ffffff !important;
        --bg-secondary: #ffffff !important;
        --bg-card: #ffffff !important;
        --bg-input: transparent !important;
        --bg-input-hover: transparent !important;
        --text-primary: #000000 !important;
        --text-secondary: #333333 !important;
        --text-muted: #666666 !important;
        --border-primary: #cccccc !important;
        --border-secondary: #e0e0e0 !important;
        --border-muted: #e0e0e0 !important;
        --shadow-card: none !important;
        --shadow-button: none !important;
    }
    
    @page { margin: 1.5cm 2cm; size: A4 portrait; }
    body { background: white !important; color: black !important; margin: 0 !important; padding: 0 !important; }
    * { background-image: none !important; }
    
    .main::before {
        content: ''; display: block; width: 100%; height: 60px; margin-bottom: 20px;
        background: linear-gradient(to right, #000 0%, #000 calc(50% - 1px), transparent calc(50% - 1px), transparent calc(50% + 1px), #000 calc(50% + 1px), #000 100%) left 55px / 100% 1px no-repeat;
        position: relative;
    }
    .main::after {
        content: 'PROJECT ESTIMATE'; position: absolute; top: 7rem; left: 1.5rem; font-size: 18px; font-weight: 700; color: #000; letter-spacing: 1px;
    }
    body::before {
        content: 'DIYCalcHub'; position: fixed; top: 1.5cm; right: 2cm; font-size: 18px; font-weight: 600; color: #FFA500; letter-spacing: 0.5px;
    }
    body::after {
        content: ''; position: fixed; top: calc(1.5cm + 35px); left: 2cm; right: 2cm; height: 2px; background: linear-gradient(to right, #FFA500, #D4B483);
    }
    
    nav, header, footer, .header, .footer, button, .btn, .btns, .ai-trigger, .ai-panel, .sticky-hub-btn, .add-room-btn, .remove-btn, .btn-remove, .btn-add, #addRoom, #calcBtn, #savePdf, #resetCalc, #copyLink, .theme-toggle, .quick-start, .help-box, .seo-guide, .status-badge, .breadcrumbs, #toastContainer, #shareModal, .modal-overlay, .mobile-menu, .no-print, .bg-layers, .bg-gradient, .bg-layer-1, .bg-layer-2, .bg-layer-3, .bg-layer-4, .bg-glow, .glow-trails, .glow-trail, .circles-container, .glass-bg { display: none !important; }
    
    .main { padding-top: 100px !important; max-width: 100% !important; padding-left: 0 !important; padding-right: 0 !important; }
    .card { background: white !important; border: 1px solid #ddd !important; box-shadow: none !important; backdrop-filter: none !important; page-break-inside: avoid; margin-bottom: 12px !important; padding: 16px !important; border-radius: 0 !important; }
    .card h3 { color: #000 !important; border-bottom: 2px solid #FFA500 !important; padding-bottom: 6px !important; margin-bottom: 12px !important; font-size: 16px !important; font-weight: 700 !important; }
    .hero { border: none !important; padding: 0 !important; margin-bottom: 20px !important; background: transparent !important; }
    .hero h2 { font-size: 20px !important; margin-bottom: 6px !important; color: #000 !important; font-weight: 700 !important; }
    .hero p { font-size: 12px !important; color: #333 !important; }
    
    input, select, textarea { border: none !important; background: transparent !important; color: #000 !important; padding: 0 !important; font-weight: 600 !important; font-size: 11px !important; appearance: none !important; -webkit-appearance: none !important; }
    .input-group.with-suffix::after { content: '' !important; }
    label { font-size: 9px !important; font-weight: 500 !important; margin-bottom: 2px !important; color: #666 !important; text-transform: uppercase !important; letter-spacing: 0.3px !important; }
    
    #resultsCard { page-break-inside: avoid !important; margin-bottom: 16px !important; }
    .kv { display: flex !important; justify-content: space-between !important; align-items: center !important; padding: 8px 0 !important; border-bottom: 1px solid #e0e0e0 !important; }
    .kv:last-child { border-bottom: none !important; }
    .kv strong, .kv span:first-child { color: #333 !important; font-weight: 500 !important; font-size: 11px !important; }
    .kv span:last-child, .kv strong:last-child { color: #000 !important; font-weight: 700 !important; font-size: 12px !important; }
    .total-area { background: #f5f5f5 !important; border: 1px solid #FFA500 !important; border-radius: 0 !important; padding: 10px !important; margin-top: 8px !important; }
    .total-area span:last-child { font-size: 14px !important; color: #000 !important; font-weight: 700 !important; }
    
    .room-item { border: 1px solid #ddd !important; background: white !important; padding: 10px !important; margin-bottom: 8px !important; page-break-inside: avoid; }
    .room-title, .room-name-input { font-weight: 600 !important; color: #000 !important; font-size: 12px !important; border: none !important; padding: 0 !important; background: transparent !important; }
    .room-box { border: 2px solid #FFA500 !important; background: #fff !important; padding: 8px !important; }
    .room-box-title { color: #666 !important; font-size: 9px !important; }
    .room-box-dims { color: #000 !important; font-weight: 600 !important; font-size: 11px !important; }
    .room-box-area { color: #000 !important; font-weight: 700 !important; font-size: 13px !important; }
    
    .shopping-list { page-break-before: auto; page-break-inside: avoid !important; background: white !important; border: 1px solid #ddd !important; padding: 16px !important; margin-top: 12px !important; }
    @supports (break-before: page) { .shopping-list { break-before: auto; break-inside: avoid; } }
    .shopping-item-compact { padding: 6px 0 6px 20px !important; font-size: 11px !important; color: #000 !important; line-height: 1.6 !important; border-bottom: 1px solid #f0f0f0 !important; position: relative !important; page-break-inside: avoid; }
    .shopping-item-compact::before { content: '' !important; position: absolute !important; left: 0 !important; top: 7px !important; width: 12px !important; height: 12px !important; border: 1px solid #000 !important; background: white !important; }
    .shopping-item-compact:last-of-type { border-bottom: none !important; }
    .shopping-item-compact strong { color: #000 !important; font-weight: 600 !important; }
    
    #qrcode { display: block !important; position: fixed !important; bottom: 1.5cm !important; right: 2cm !important; width: 80px !important; height: 80px !important; padding: 4px !important; background: white !important; border: 1px solid #ddd !important; }
    #qrcode img, #qrcode canvas { width: 72px !important; height: 72px !important; display: block !important; }
    #qrcode::after { content: 'Scan to edit project' !important; position: absolute !important; bottom: -20px !important; left: 50% !important; transform: translateX(-50%) !important; font-size: 8px !important; color: #666 !important; white-space: nowrap !important; font-weight: 500 !important; }
    
    h1, h2, h3, h4, h5, h6 { color: #000 !important; page-break-after: avoid; }
    .container { max-width: 100% !important; padding: 0 !important; }
    .row { gap: 8px !important; }
    
    @page { @bottom-center { content: "Page " counter(page) " of " counter(pages); font-size: 9px; color: #666; } }
    .card, .room-item, .shopping-list, .room-diagram, #resultsCard { page-break-inside: avoid !important; break-inside: avoid !important; }
    #resultsCard { orphans: 3; widows: 3; }
    .shopping-list { orphans: 5; widows: 5; }
    textarea { min-height: 40px !important; max-height: 60px !important; overflow: hidden !important; }
    .pricing-toggle-wrapper, .pricing-toggle-btn, .pricing-toggle-bg { display: none !important; }
    .price-input-group input { font-weight: 700 !important; font-size: 12px !important; }
    p, span, div, td, th { color: #000 !important; }
    * { background-color: white !important; }
    .total-area, .room-box { background: #fafafa !important; }
    .card, .room-item, .shopping-list { border-color: #ddd !important; }
    .print-footer { display: block !important; margin-top: 30px !important; padding-top: 15px !important; border-top: 1px solid #ddd !important; font-size: 9px !important; color: #999 !important; text-align: center !important; }
}

/* ========================================
   PRINT — SHOPPING LIST ONLY
   ======================================== */
@media print {
    body.print-list-only > * { display: none !important; }

    body.print-list-only > #print-list-only {
        display: block !important;
        padding: 1.5cm 2cm;
        color: #000 !important;
        background: white !important;
    }

    body.print-list-only .plo-header {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 0.4cm;
        padding-bottom: 0.25cm;
        border-bottom: 2px solid #FFA500;
    }

    body.print-list-only .plo-brand {
        font-size: 18px !important;
        font-weight: 700 !important;
        color: #FFA500 !important;
        letter-spacing: 0.5px;
    }

    body.print-list-only .plo-date {
        font-size: 11px !important;
        color: #666 !important;
    }

    body.print-list-only .plo-project {
        font-size: 13px !important;
        font-weight: 600 !important;
        color: #333 !important;
        margin-bottom: 0.35cm;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    body.print-list-only .shopping-list {
        display: block !important;
        background: white !important;
        border: 1px solid #ddd !important;
        padding: 14px !important;
        border-radius: 0 !important;
    }

    body.print-list-only .shopping-list .result-accent {
        display: none !important;
    }

    body.print-list-only .shopping-item-compact {
        display: block !important;
        color: #000 !important;
        font-size: 12px !important;
        padding: 6px 0 6px 18px !important;
        border-bottom: 1px solid #f0f0f0 !important;
        position: relative !important;
        line-height: 1.5 !important;
    }

    body.print-list-only .shopping-item-compact::before {
        content: '' !important;
        position: absolute !important;
        left: 0 !important;
        top: 8px !important;
        width: 10px !important;
        height: 10px !important;
        border: 1px solid #555 !important;
        background: white !important;
        display: block !important;
    }

    body.print-list-only .shopping-item-compact strong {
        color: #000 !important;
        font-weight: 600 !important;
    }

    body.print-list-only .shopping-item-compact:last-of-type {
        border-bottom: none !important;
    }

    body.print-list-only .shopping-item-compact.price-row {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
    }

    body.print-list-only .plo-item-price {
        font-size: 12px !important;
        font-weight: 600 !important;
        color: #000 !important;
        white-space: nowrap;
        display: inline-block !important;
    }

    body.print-list-only .shopping-subtotal-row {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 8px 0 0 !important;
        margin-top: 6px !important;
        border-top: 1px solid #ccc !important;
        font-weight: 700 !important;
        font-size: 13px !important;
        color: #000 !important;
    }
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }