/* ============================================
   Golden Ratio Design System
   φ (phi) = 1.618 - The Golden Ratio
   ============================================ */

:root {
    /* Golden Ratio Scale */
    --phi: 1.618;
    --phi-inverse: 0.618;
    
    /* Spacing System (based on 8px base) */
    --space-xs: 0.5rem;      /* 8px */
    --space-sm: 0.809rem;    /* 13px - 8 * φ⁻¹ */
    --space-md: 1.309rem;    /* 21px - 8 * φ */
    --space-lg: 2.118rem;    /* 34px - 8 * φ² */
    --space-xl: 3.427rem;    /* 55px - 8 * φ³ */
    --space-2xl: 5.545rem;   /* 89px - 8 * φ⁴ */
    
    /* Typography Scale */
    --text-xs: 0.809rem;     /* 13px */
    --text-sm: 1rem;         /* 16px */
    --text-md: 1.309rem;     /* 21px */
    --text-lg: 2.118rem;     /* 34px */
    --text-xl: 3.427rem;     /* 55px */
    --text-2xl: 5.545rem;    /* 89px */
    
    /* Colors - Light Theme */
    --color-bg: #FAFAF9;
    --color-surface: #FFFFFF;
    --color-text-primary: #1C1917;
    --color-text-secondary: #57534E;
    --color-text-tertiary: #A8A29E;
    --color-border: #E7E5E4;
    --color-gold: #D4AF37;
    --color-gold-light: #F4E4BC;
    --color-gold-dark: #B8941F;
    --color-success: #16A34A;
    --color-success-light: #DCFCE7;
    --color-danger: #DC2626;
    --color-danger-light: #FEE2E2;
    --color-shadow: rgba(0, 0, 0, 0.04);
    --color-shadow-lg: rgba(0, 0, 0, 0.08);
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Border Radius */
    --radius-sm: 0.5rem;
    --radius-md: 0.809rem;
    --radius-lg: 1.309rem;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px var(--color-shadow);
    --shadow-md: 0 4px 6px var(--color-shadow), 0 2px 4px var(--color-shadow);
    --shadow-lg: 0 10px 15px var(--color-shadow-lg), 0 4px 6px var(--color-shadow);
    --shadow-xl: 0 20px 25px var(--color-shadow-lg), 0 10px 10px var(--color-shadow);
}

/* Dark Theme */
[data-theme="dark"] {
    --color-bg: #0C0A09;
    --color-surface: #1C1917;
    --color-text-primary: #FAFAF9;
    --color-text-secondary: #D6D3D1;
    --color-text-tertiary: #78716C;
    --color-border: #292524;
    --color-gold: #F4D03F;
    --color-gold-light: #3A3419;
    --color-gold-dark: #F9E79F;
    --color-success: #22C55E;
    --color-success-light: #14532D;
    --color-danger: #EF4444;
    --color-danger-light: #450A0A;
    --color-shadow: rgba(0, 0, 0, 0.3);
    --color-shadow-lg: rgba(0, 0, 0, 0.5);
}

/* ============================================
   Reset & Base Styles
   ============================================ */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: var(--text-sm);
    line-height: var(--phi);
    color: var(--color-text-primary);
    background-color: var(--color-bg);
    transition: background-color var(--transition-base), color var(--transition-base);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Poppins', 'Inter', sans-serif;
}

/* For Urdu/Hindi text */
[lang="ur"] {
    font-family: 'Noto Nastaliq Urdu', 'Jameel Noori Nastaleeq', serif;
    direction: rtl;
}

/* ============================================
   Layout
   ============================================ */

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

.header {
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    transition: background-color var(--transition-base);
}

/* iOS Install Banner */
.ios-install-banner {
    background: linear-gradient(135deg, var(--color-gold-light), var(--color-gold));
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
    animation: slideDown 0.3s ease-out;
}

[data-theme="dark"] .ios-install-banner {
    background: linear-gradient(135deg, rgba(244, 208, 63, 0.2), rgba(244, 208, 63, 0.3));
    border: 1px solid var(--color-gold);
}

.ios-banner-content {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.ios-banner-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.ios-banner-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.ios-banner-text strong {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-text-primary);
}

.ios-banner-text span {
    font-size: 0.7rem;
    color: var(--color-text-secondary);
}

.ios-banner-close {
    background: transparent;
    border: none;
    color: var(--color-text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.ios-banner-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) 0;
    gap: var(--space-lg);
}

.logo {
    font-size: var(--text-md);
    font-weight: 700;
    color: var(--color-text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.logo-link {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    text-decoration: none !important;
    color: inherit !important;
    transition: opacity var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.logo-link:hover {
    opacity: 0.8;
    text-decoration: none !important;
}

.logo-link:active {
    opacity: 0.6;
}

.logo-link:visited {
    color: inherit !important;
    text-decoration: none !important;
}

.logo-icon {
    font-size: var(--text-lg);
}

.controls {
    display: flex;
    gap: var(--space-xs);
}

/* RTL support for controls */
[dir="rtl"] .controls {
    flex-direction: row-reverse;
}

.main {
    flex: 1;
    padding: var(--space-xl) 0;
}

.footer {
    background-color: var(--color-surface);
    border-top: 2px solid var(--color-gold);
    padding: var(--space-2xl) 0 var(--space-lg);
    margin-top: var(--space-3xl);
}

.footer-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

.footer-disclaimer {
    background-color: var(--color-gold-light);
    border-left: 4px solid var(--color-gold);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
}

[data-theme="dark"] .footer-disclaimer {
    background-color: rgba(244, 208, 63, 0.1);
    border-left-color: var(--color-gold);
}

[data-theme="dark"] .footer-disclaimer-text {
    color: var(--color-text-secondary);
}

.footer-disclaimer-title {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--color-gold-dark);
    margin-bottom: var(--space-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

[data-theme="dark"] .footer-disclaimer-title {
    color: var(--color-gold);
}

.footer-disclaimer-text {
    font-size: var(--text-sm);
    color: var(--color-text-primary);
    line-height: 1.6;
    margin-bottom: var(--space-sm);
}

.footer-disclaimer-text:last-child {
    margin-bottom: 0;
}

.footer-info {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    text-align: center;
}

.footer-text {
    color: var(--color-text-primary);
    font-size: var(--text-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.separator {
    color: var(--color-text-tertiary);
}

/* Footer Links for SEO */
.footer-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-xl);
    padding: var(--space-xl) 0;
    border-top: 1px solid var(--color-border);
    margin-top: var(--space-lg);
}

.footer-links-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.footer-links-title {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--color-gold-dark);
    margin-bottom: var(--space-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

[data-theme="dark"] .footer-links-title {
    color: var(--color-gold);
}

.footer-link {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
    display: inline-block;
}

.footer-link:hover {
    color: var(--color-gold-dark);
    transform: translateX(4px);
}

[data-theme="dark"] .footer-link:hover {
    color: var(--color-gold);
}

.footer-copyright {
    text-align: center;
    padding-top: var(--space-md);
    border-top: 1px solid var(--color-border);
}

.footer-copyright p {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}

.footer-link-deprecated {
    color: var(--color-gold-dark);
    text-decoration: none;
    font-weight: 600;
    transition: all var(--transition-fast);
    border-bottom: 1px solid transparent;
}

.footer-link:hover {
    color: var(--color-gold);
    border-bottom-color: var(--color-gold);
}

[data-theme="dark"] .footer-link {
    color: var(--color-gold);
}

[data-theme="dark"] .footer-link:hover {
    color: var(--color-gold-light);
    border-bottom-color: var(--color-gold-light);
}

/* ============================================
   Tab Navigation
   ============================================ */

.tab-nav {
    display: flex;
    gap: var(--space-xs);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.tab-nav::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

/* Header Tabs */
.header-tabs {
    flex: 1;
    max-width: 600px;
    border-bottom: none;
}

/* Mobile Menu Toggle */
.btn-menu-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--color-border);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: var(--color-text);
    transition: all 0.2s ease;
}

.btn-menu-toggle:hover {
    background: rgba(212, 175, 55, 0.1);
    border-color: var(--color-gold-dark);
}

[data-theme="dark"] .btn-menu-toggle:hover {
    border-color: var(--color-gold);
}

.mobile-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 250px;
    z-index: 1000;
    margin-top: var(--space-xs);
}

/* RTL support for mobile menu */
[dir="rtl"] .mobile-menu {
    right: auto;
    left: 0;
}

.mobile-menu.active {
    display: block;
}

.mobile-menu-item {
    display: block;
    width: 100%;
    padding: var(--space-md);
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Poppins', sans-serif;
}

.mobile-menu-item:last-child {
    border-bottom: none;
}

.mobile-menu-item:hover {
    background: rgba(212, 175, 55, 0.1);
    color: var(--color-gold-dark);
}

[data-theme="dark"] .mobile-menu-item:hover {
    color: var(--color-gold);
}

/* Mobile Install Button in Menu */
.mobile-install-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--color-gold-dark);
    font-weight: 700;
}

.mobile-install-btn svg {
    flex-shrink: 0;
}

[data-theme="dark"] .mobile-install-btn {
    color: var(--color-gold);
}

.tab-btn {
    background: transparent;
    border: 1px solid transparent;
    padding: var(--space-xs) var(--space-md);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text-secondary);
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
    white-space: nowrap;
    font-family: 'Poppins', sans-serif;
    border-radius: var(--radius-sm);
}

.tab-btn:hover {
    color: var(--color-gold-dark);
    background: rgba(212, 175, 55, 0.05);
}

.tab-btn.active {
    color: var(--color-gold-dark);
    background: rgba(212, 175, 55, 0.1);
    border-color: var(--color-gold-dark);
}

[data-theme="dark"] .tab-btn.active {
    color: var(--color-gold);
    border-color: var(--color-gold);
}

[data-theme="dark"] .tab-btn:hover {
    color: var(--color-gold-light);
    background: rgba(244, 208, 63, 0.05);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.tab-content.active {
    display: block;
}

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

/* ============================================
   Zakat Calculator
   ============================================ */

.zakat-calculator {
    max-width: 900px;
    margin: 0 auto;
}

.zakat-header {
    text-align: center;
    margin-bottom: var(--space-lg);
}

.zakat-header .hero-title {
    font-size: var(--text-xl);
    margin-bottom: var(--space-xs);
}

.zakat-subtitle {
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    margin-top: 0;
}

/* Zakat Info Card */
.zakat-info-card {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-lg);
    margin-top: var(--space-2xl);
    margin-bottom: var(--space-xl);
    padding: var(--space-lg);
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.08), rgba(212, 175, 55, 0.03));
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

.zakat-info-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.zakat-info-label {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    font-weight: 500;
}

.zakat-info-value {
    font-size: var(--text-md);
    color: var(--color-gold-dark);
    font-weight: 700;
    font-family: 'Poppins', sans-serif;
}

[data-theme="dark"] .zakat-info-value {
    color: var(--color-gold);
}

/* Gold Entries Section */
.zakat-entries {
    margin-bottom: var(--space-2xl);
}

.zakat-entries .section-title {
    font-size: var(--text-md);
    margin-bottom: var(--space-md);
}

.entries-container {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.entries-list {
    padding: var(--space-md);
}

.gold-entry {
    display: grid;
    grid-template-columns: 2fr 2fr 1.5fr auto;
    gap: var(--space-md);
    align-items: end;
    padding: var(--space-md);
    border-bottom: 1px solid var(--color-border);
    transition: background 0.2s ease;
}

.gold-entry:last-child {
    border-bottom: none;
}

.gold-entry:hover {
    background: rgba(212, 175, 55, 0.03);
}

.btn-remove-entry {
    background: transparent;
    border: 1px solid var(--color-border);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-remove-entry:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #ef4444;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.field-label {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.field-input,
.field-select {
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: var(--text-base);
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
}

.field-input:focus,
.field-select:focus {
    outline: none;
    border-color: var(--color-gold-dark);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

[data-theme="dark"] .field-input:focus,
[data-theme="dark"] .field-select:focus {
    border-color: var(--color-gold);
    box-shadow: 0 0 0 3px rgba(244, 208, 63, 0.1);
}

.field-input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.field-input[type="number"]::-webkit-outer-spin-button,
.field-input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

/* Add Entry Button */
.btn-add-entry {
    width: 100%;
    padding: var(--space-md);
    background: transparent;
    border: none;
    border-top: 1px solid var(--color-border);
    color: var(--color-gold-dark);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    transition: all 0.2s ease;
    font-family: 'Poppins', sans-serif;
}

.btn-add-entry:hover {
    background: rgba(212, 175, 55, 0.05);
}

[data-theme="dark"] .btn-add-entry {
    color: var(--color-gold);
}

[data-theme="dark"] .btn-add-entry:hover {
    background: rgba(244, 208, 63, 0.05);
}

/* Zakat Summary */
.zakat-summary {
    margin-top: var(--space-2xl);
    margin-bottom: var(--space-2xl);
}

.zakat-summary .section-title {
    font-size: var(--text-md);
    margin-bottom: var(--space-md);
}

.summary-card {
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-lg);
}

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

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

.summary-row.highlight {
    background: rgba(212, 175, 55, 0.05);
    margin: 0 calc(-1 * var(--space-md));
    padding: var(--space-md);
    border-radius: var(--radius-sm);
}

.summary-row.zakat-due {
    margin-top: var(--space-lg);
    padding-top: var(--space-xl);
    border-top: 2px solid var(--color-gold-dark);
}

[data-theme="dark"] .summary-row.zakat-due {
    border-top-color: var(--color-gold);
}

.summary-label {
    font-size: var(--text-base);
    color: var(--color-text-secondary);
    font-weight: 500;
}

.summary-value {
    font-size: var(--text-md);
    color: var(--color-text);
    font-weight: 700;
    font-family: 'Poppins', sans-serif;
}

.summary-value-large {
    font-size: var(--text-lg);
    color: var(--color-gold-dark);
    font-weight: 800;
    font-family: 'Poppins', sans-serif;
}

[data-theme="dark"] .summary-value-large {
    color: var(--color-gold);
}

/* Status Badge */
.status-badge {
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-badge.applicable {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.status-badge.not-applicable {
    background: rgba(148, 163, 184, 0.1);
    color: #94a3b8;
}

/* Mobile Responsive - Zakat Calculator */
@media (max-width: 768px) {
    .header-content {
        position: relative;
    }
    
    .logo {
        flex: 1;
    }
    
    .controls {
        display: flex;
        gap: var(--space-xs);
        flex-shrink: 0;
        position: relative;
    }
    
    /* Hide desktop tabs, show hamburger menu */
    .header-tabs {
        display: none;
    }
    
    .btn-menu-toggle {
        display: flex;
    }
    
    .zakat-info-card {
        grid-template-columns: 1fr;
        padding: var(--space-md);
    }
    
    .gold-entry {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
        padding: var(--space-md);
    }
    
    .btn-remove-entry {
        width: 100%;
        height: 32px;
    }
    
    .summary-card {
        padding: var(--space-md);
    }
    
    .summary-row {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-xs);
    }
    
    .summary-row.highlight {
        margin: 0 calc(-1 * var(--space-sm));
        padding: var(--space-sm);
    }
}

@media (max-width: 480px) {
    .logo {
        font-size: var(--text-sm);
    }
    
    .logo-icon {
        font-size: 1.2rem;
    }
    
    .btn-control {
        padding: var(--space-xs);
        min-width: 36px;
        min-height: 36px;
    }
    
    .btn-lang {
        font-size: 0.7rem;
    }
    
    .btn-menu-toggle {
        width: 36px;
        height: 36px;
    }
    
    .mobile-menu {
        right: 0;
        min-width: 220px;
    }
    
    [dir="rtl"] .mobile-menu {
        right: auto;
        left: 0;
    }
    
    .zakat-header {
        margin-bottom: var(--space-xl);
    }
    
    .entries-list {
        padding: var(--space-sm);
    }
    
    .gold-entry {
        padding: var(--space-sm);
    }
    
    .field-label {
        font-size: 0.65rem;
    }
    
    .field-input,
    .field-select {
        padding: var(--space-xs) var(--space-sm);
        font-size: var(--text-sm);
    }
    
    .summary-value-large {
        font-size: var(--text-md);
    }
}

/* ============================================
   Advertisement Sections
   ============================================ */

.ad-section {
    margin: var(--space-3xl) 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ad-container {
    width: 100%;
    max-width: 728px;
    min-height: 90px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ad-placeholder {
    width: 100%;
    min-height: 90px;
    background-color: rgba(212, 175, 55, 0.05);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.ad-placeholder::before {
    content: 'Advertisement';
    color: var(--color-text-tertiary);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.5;
}

/* Hide placeholder styling when ad is loaded */
.ad-placeholder:has(ins) {
    background: none;
    border: none;
}

.ad-placeholder:has(ins)::before {
    display: none;
}

/* Responsive Ad Sizes */
@media (max-width: 768px) {
    .ad-section {
        margin: var(--space-2xl) 0;
    }
    
    .ad-container {
        max-width: 100%;
    }
    
    .ad-placeholder {
        min-height: 50px;
    }
}

@media (max-width: 480px) {
    .ad-section {
        margin: var(--space-xl) 0;
    }
    
    .ad-placeholder {
        min-height: 50px;
    }
}

/* ============================================
   Components
   ============================================ */

/* Buttons */
.btn-control {
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: var(--space-xs);
    cursor: pointer;
    color: var(--color-text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    width: 2.5rem;
    height: 2.5rem;
}

.btn-control:hover {
    background-color: var(--color-gold-light);
    border-color: var(--color-gold);
    color: var(--color-gold-dark);
}

.btn-control:active {
    transform: scale(0.95);
}

.btn-control svg {
    display: block;
}

.btn-lang {
    width: auto;
    min-width: 4rem;
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.btn-lang #langText {
    display: block;
    line-height: 1;
}

.btn-install {
    background: linear-gradient(135deg, var(--color-gold), var(--color-gold-dark));
    border: none;
    border-radius: var(--radius-sm);
    padding: var(--space-xs) var(--space-sm);
    cursor: pointer;
    color: var(--color-bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: all var(--transition-fast);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.02em;
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
}

.btn-install:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.4);
}

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

.btn-install svg {
    display: block;
    width: 16px;
    height: 16px;
}

[data-theme="dark"] .btn-install {
    background: linear-gradient(135deg, var(--color-gold), var(--color-gold-light));
    box-shadow: 0 2px 8px rgba(244, 208, 63, 0.3);
}

[data-theme="dark"] .btn-install:hover {
    box-shadow: 0 4px 12px rgba(244, 208, 63, 0.4);
}

.moon-icon {
    display: none;
}

[data-theme="dark"] .sun-icon {
    display: none;
}

[data-theme="dark"] .moon-icon {
    display: block;
}

/* Hero Section */
.hero {
    margin-bottom: var(--space-2xl);
}

.hero-header {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.hero-title {
    font-size: var(--text-xl);
    font-weight: 800;
    color: var(--color-gold-dark);
    margin-bottom: var(--space-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    display: inline-block;
}

[data-theme="dark"] .hero-title {
    color: var(--color-gold);
}

.hero-title::after {
    content: '';
    position: absolute;
    bottom: -0.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 4px;
    background: linear-gradient(90deg, transparent, var(--color-gold), transparent);
    border-radius: 2px;
}

/* Date and City Row */
.date-city-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-lg);
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 var(--space-md);
}

.price-date {
    font-size: var(--text-sm);
    color: var(--color-gold-dark);
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

[data-theme="dark"] .price-date {
    color: var(--color-gold);
}

.price-date::before {
    content: '📅';
    font-size: 1.2rem;
}

/* City Selector */
.city-selector {
    font-size: 1rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    color: var(--color-gold-dark);
    background: var(--color-bg-light);
    border: 2px solid var(--color-border-light);
    border-radius: var(--radius-md);
    padding: 0.65rem 1rem;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
    min-width: 180px;
}

.city-selector:hover {
    border-color: var(--color-gold-dark);
}

.city-selector:focus {
    border-color: var(--color-gold-dark);
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.1);
}

[data-theme="dark"] .city-selector {
    color: var(--color-gold);
    background: var(--color-bg-dark);
    border-color: var(--color-border-dark);
}

[data-theme="dark"] .city-selector:hover {
    border-color: var(--color-gold);
}

[data-theme="dark"] .city-selector:focus {
    border-color: var(--color-gold);
    box-shadow: 0 0 0 2px rgba(244, 208, 63, 0.1);
}

[data-theme="dark"] .city-selector option {
    background-color: var(--color-bg-dark);
    color: var(--color-text-dark);
}

/* Featured Prices Grid */
.featured-prices {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-2xl);
}

.featured-card {
    background: linear-gradient(135deg, var(--color-gold-light) 0%, var(--color-surface) 100%);
    border: 2px solid var(--color-gold);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: 0 8px 32px rgba(212, 175, 55, 0.15), 0 4px 16px rgba(0, 0, 0, 0.1);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.featured-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(212, 175, 55, 0.2), 0 6px 20px rgba(0, 0, 0, 0.15);
}

.featured-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--color-gold), var(--color-gold-dark));
}

.featured-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl), 0 0 40px rgba(212, 175, 55, 0.3);
    border-color: var(--color-gold-dark);
}

.featured-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.featured-karat {
    background: linear-gradient(135deg, var(--color-gold), var(--color-gold-dark));
    color: #1C1917;
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 800;
    letter-spacing: 0.05em;
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.3);
}

[data-theme="dark"] .featured-karat {
    color: #0C0A09;
}

.featured-unit {
    font-size: var(--text-md);
    font-weight: 700;
    color: var(--color-text-primary);
    letter-spacing: 0.02em;
}

.featured-price {
    display: flex;
    align-items: baseline;
    gap: var(--space-sm);
}

.featured-currency {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    font-weight: 600;
}

.featured-amount {
    font-size: var(--text-xl);
    font-weight: 800;
    color: var(--color-gold-dark);
    letter-spacing: -0.02em;
    font-feature-settings: 'tnum' on, 'lnum' on;
}

[data-theme="dark"] .featured-amount {
    color: var(--color-gold);
}

.featured-change {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    width: fit-content;
    font-size: var(--text-xs);
    font-weight: 600;
}

.featured-change.positive {
    background-color: var(--color-success-light);
    color: var(--color-success);
}

.featured-change.negative {
    background-color: var(--color-danger-light);
    color: var(--color-danger);
}

.featured-change.neutral {
    background-color: var(--color-border);
    color: var(--color-text-secondary);
}

/* All Prices Section */
.all-prices {
    margin-bottom: var(--space-2xl);
}

.all-prices-header {
    text-align: center;
    margin-bottom: var(--space-lg);
}

.all-prices-title {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--color-gold-dark);
    margin-bottom: var(--space-xs);
    text-align: center;
    font-family: 'Poppins', sans-serif;
}

[data-theme="dark"] .all-prices-title {
    color: var(--color-gold);
}

.all-prices-subtitle {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-lg);
    text-align: center;
    font-style: italic;
}

.scroll-hint {
    display: none;
    font-size: 0.75rem;
    color: var(--color-gold);
    text-align: center;
    margin-top: var(--space-xs);
    margin-bottom: var(--space-md);
    font-weight: 600;
    animation: pulseHint 2s ease-in-out infinite;
}

@keyframes pulseHint {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .scroll-hint {
        display: block;
    }
}

/* Matrix Table */
.matrix-table-container {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    overflow-y: visible;
    box-shadow: var(--shadow-md);
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    position: relative;
}

/* Scroll hint shadow on right edge */
.matrix-table-container::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(to left, var(--color-surface), transparent);
    pointer-events: none;
    opacity: 0.8;
}

@media (max-width: 768px) {
    .matrix-table-container::after {
        display: block;
    }
}

.matrix-table {
    width: 100%;
    border-collapse: collapse;
}

.matrix-table thead {
    background-color: var(--color-surface);
    border-bottom: 2px solid var(--color-border);
}

.matrix-table th {
    padding: var(--space-md);
    text-align: center;
    font-size: var(--text-sm);
    font-weight: 600;
    border-right: 1px solid var(--color-border);
}

.matrix-table th:last-child {
    border-right: none;
}

.matrix-header-label {
    color: var(--color-text-secondary);
    text-align: left !important;
    font-weight: 500;
}

.matrix-karat-header {
    color: var(--color-gold-dark);
    font-weight: 700;
}

[data-theme="dark"] .matrix-karat-header {
    color: var(--color-gold);
}

.matrix-table tbody tr {
    border-bottom: 1px solid var(--color-border);
    transition: background-color var(--transition-fast);
}

.matrix-table tbody tr:last-child {
    border-bottom: none;
}

.matrix-table tbody tr:hover {
    background-color: var(--color-gold-light);
}

.matrix-table td {
    padding: var(--space-md);
    font-size: var(--text-sm);
    border-right: 1px solid var(--color-border);
}

.matrix-table td:last-child {
    border-right: none;
}

.matrix-unit-label {
    color: var(--color-gold-dark);
    font-weight: 600;
    text-align: left;
}

[data-theme="dark"] .matrix-unit-label {
    color: var(--color-gold);
}

.matrix-price {
    color: var(--color-text-primary);
    font-weight: 500;
    text-align: center;
    font-feature-settings: 'tnum' on, 'lnum' on;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-lg);
    margin-top: var(--space-lg);
    padding: var(--space-lg) 0;
}

.pagination-btn {
    background: var(--color-gold-light);
    border: 2px solid var(--color-gold);
    border-radius: var(--radius-sm);
    padding: var(--space-sm) var(--space-lg);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.pagination-btn:hover:not(:disabled) {
    background: var(--color-gold);
    color: var(--color-surface);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: var(--color-border);
    background: var(--color-border);
}

.pagination-info {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text-primary);
    min-width: 100px;
    text-align: center;
}

/* History Section */
.history {
    margin-top: var(--space-xl);
}

/* Chart Container */
.chart-container {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-xl);
    box-shadow: var(--shadow-md);
    position: relative;
    height: 400px;
}

.chart-container canvas {
    max-height: 100%;
}

.section-title {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--color-gold-dark);
    margin-bottom: var(--space-lg);
    text-align: center;
    font-family: 'Poppins', sans-serif;
}

[data-theme="dark"] .section-title {
    color: var(--color-gold);
}

.table-container {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.price-table {
    width: 100%;
    border-collapse: collapse;
}

.price-table thead {
    background-color: var(--color-gold-light);
    border-bottom: 2px solid var(--color-gold);
}

[data-theme="dark"] .price-table thead {
    background-color: var(--color-gold-light);
}

.price-table th {
    padding: var(--space-md);
    text-align: left;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text-primary);
}

.price-table tbody tr {
    border-bottom: 1px solid var(--color-border);
    transition: background-color var(--transition-fast);
}

.price-table tbody tr:last-child {
    border-bottom: none;
}

.price-table tbody tr:hover {
    background-color: var(--color-gold-light);
}

.price-table td {
    padding: var(--space-md);
    font-size: var(--text-sm);
    color: var(--color-text-primary);
}

.price-table .table-date {
    font-weight: 500;
}

.price-table .table-unit {
    font-weight: 600;
    color: var(--color-text-primary);
}

.price-table .table-karat {
    font-weight: 600;
    color: var(--color-gold-dark);
}

[data-theme="dark"] .price-table .table-karat {
    color: var(--color-gold);
}

.price-table .table-price {
    font-weight: 600;
    font-feature-settings: 'tnum' on, 'lnum' on;
}

.price-table .table-change {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.change-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 600;
}

.change-badge.positive {
    background-color: var(--color-success-light);
    color: var(--color-success);
}

.change-badge.negative {
    background-color: var(--color-danger-light);
    color: var(--color-danger);
}

.change-badge.neutral {
    background-color: var(--color-border);
    color: var(--color-text-secondary);
}

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

@media (max-width: 768px) {
    :root {
        font-size: 14px;
    }
    
    .header-content {
        padding: var(--space-sm) 0;
    }
    
    .logo {
        font-size: var(--text-sm);
    }
    
    .logo-icon {
        font-size: var(--text-md);
    }

    /* Hide desktop install button on mobile - it's in the hamburger menu */
    .btn-install {
        display: none !important;
    }
    
    .main {
        padding: var(--space-md) 0;
    }
    
    .hero {
        margin-bottom: var(--space-lg);
    }
    
    .hero-header {
        margin-bottom: var(--space-md);
    }
    
    .hero-title {
        font-size: var(--text-md);
        margin-bottom: 0.25rem;
    }
    
    .price-date {
        font-size: 0.85rem;
        margin-bottom: var(--space-sm);
    }
    
    .price-date::before {
        font-size: 1rem;
    }
    
    /* Much more compact featured cards */
    .featured-prices {
        gap: var(--space-sm);
    }
    
    .featured-card {
        padding: var(--space-md) var(--space-lg);
        border-width: 2px;
    }
    
    .featured-card::before {
        height: 3px;
    }
    
    .featured-label {
        margin-bottom: var(--space-xs);
        gap: var(--space-xs);
    }
    
    .featured-karat {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }
    
    .featured-unit {
        font-size: 1rem;
    }
    
    .featured-price {
        gap: 0.35rem;
    }
    
    .featured-currency {
        font-size: 1rem;
    }
    
    .featured-amount {
        font-size: 2rem;
        letter-spacing: -0.03em;
        font-weight: 800;
    }
    
    .section-title {
        font-size: var(--text-md);
        margin-bottom: var(--space-md);
    }
    
    .all-prices-title {
        font-size: var(--text-md);
    }
    
    .all-prices-subtitle {
        font-size: 0.875rem;
    }
    
    .chart-container {
        height: 300px;
        padding: var(--space-md);
    }
    
    .table-container {
        overflow-x: auto;
    }
    
    .matrix-table {
        min-width: 600px;
    }
    
    .matrix-table th,
    .matrix-table td {
        padding: var(--space-sm);
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 var(--space-sm);
    }
    
    .main {
        padding: var(--space-sm) 0;
    }
    
    .hero {
        margin-bottom: var(--space-md);
    }
    
    .hero-header {
        margin-bottom: var(--space-sm);
    }
    
    .hero-title {
        font-size: var(--text-sm);
        margin-bottom: 0.2rem;
    }
    
    .hero-title::after {
        width: 60px;
        height: 3px;
    }
    
    .date-city-row {
        flex-direction: column;
        gap: var(--space-sm);
        align-items: flex-start;
        padding: 0 var(--space-sm);
    }
    
    .city-selector {
        font-size: 0.95rem;
        padding: 0.6rem 0.85rem;
        width: 100%;
        max-width: 100%;
        min-width: auto;
    }
    
    .price-date {
        font-size: 0.875rem;
    }
    
    .price-date::before {
        font-size: 1rem;
    }
    
    /* Ultra compact featured cards on small mobile */
    .featured-prices {
        gap: 0.5rem;
    }
    
    .featured-card {
        padding: var(--space-md);
        border-radius: var(--radius-lg);
        border-width: 2px;
    }
    
    .featured-card::before {
        height: 2px;
    }
    
    .featured-label {
        margin-bottom: 0.3rem;
    }
    
    .featured-karat {
        font-size: 0.65rem;
        padding: 0.15rem 0.4rem;
    }
    
    .featured-unit {
        font-size: 0.9rem;
    }
    
    .featured-price {
        gap: 0.3rem;
    }
    
    .featured-currency {
        font-size: 0.9rem;
    }
    
    .featured-amount {
        font-size: 1.75rem;
        font-weight: 800;
    }
    
    .section-title {
        font-size: var(--text-sm);
        margin-bottom: var(--space-sm);
    }
    
    .all-prices-title {
        font-size: var(--text-sm);
    }
    
    .all-prices-subtitle {
        font-size: 0.75rem;
    }
    
    .chart-container {
        height: 250px;
        padding: var(--space-sm);
    }
    
    .footer-disclaimer {
        padding: var(--space-md);
    }
    
    .footer-disclaimer-title {
        font-size: 0.875rem;
    }
    
    .footer-disclaimer-text {
        font-size: 0.75rem;
    }
    
    .footer-text {
        font-size: 0.75rem;
    }
    
    .footer-links {
        grid-template-columns: 1fr;
        gap: var(--space-lg);
        padding: var(--space-lg) 0;
    }
    
    .footer-copyright p {
        font-size: 0.75rem;
    }
}

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

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

.price-card,
.table-container {
    animation: fadeIn var(--transition-slow) ease-out;
}

/* ============================================
   Accessibility
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

:focus-visible {
    outline: 2px solid var(--color-gold);
    outline-offset: 2px;
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    .header,
    .controls,
    .footer {
        display: none;
    }
    
    .price-card,
    .table-container {
        box-shadow: none;
        border: 1px solid #000;
    }
}

