/* Fonts */
@font-face {
    font-family: 'Nunito Sans';
    src: url('./fonts/nunito-sans-400.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Nunito Sans';
    src: url('./fonts/nunito-sans-600.ttf') format('truetype');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Nunito Sans';
    src: url('./fonts/nunito-sans-700.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Nunito Sans';
    src: url('./fonts/nunito-sans-800.ttf') format('truetype');
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg-color: #f8f9fa; /* Brighter background */
    --card-bg: #ffffff;
    --card-border: #d1d4db;
    --text-primary: #132537;
    --text-secondary: #555555;
    --accent-red: #ed292b;
    --accent-blue: #132537;
    --accent-green: #28a745;
    --font-main: 'Nunito Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    line-height: 1.3;
    font-size: 13px;
    padding-bottom: 40px;
    overflow-x: hidden;
    overflow-anchor: none; /* Prevent scroll anchoring from re-firing scroll listener during header resize */
}

body.modal-open {
    overflow: hidden;
    height: 100vh;
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    background-color: transparent;
    padding: 0 20px;
}

.main-header {
    background-color: #132537 !important; /* Force JTG Navy */
    color: #ffffff !important;
    padding: 0.8rem 0;
    text-align: center;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: padding 0.25s ease, box-shadow 0.25s ease;
}

.main-header.shrink {
    padding: 0.1rem 0 0.8rem 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.main-header.shrink .header-content {
    gap: 0.5rem;
}

.main-header.shrink .header-logo {
    max-width: 80px;
}

.main-header.shrink h1 {
    font-size: 0.75rem;
}

.main-header.shrink .subtitle {
    display: none;
}

.tax-disclaimer-strip {
    background-color: rgba(0, 0, 0, 0.35);
    color: rgba(255, 255, 255, 0.95);
    font-size: 10.5px;
    font-weight: 600;
    padding: 4px 10px;
    margin-top: 6px;
    line-height: 1.2;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    letter-spacing: 0.1px;
}

.tax-disclaimer-strip i {
    margin-right: 4px;
    color: #ffc107;
    font-size: 10px;
}

.main-header.shrink .tax-disclaimer-strip {
    margin-top: 2px;
    padding: 3px 8px;
    font-size: 9.5px;
}

.header-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.header-logo {
    max-width: 100px;
    height: auto;
    transition: all 0.3s ease;
}

.header-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
}

.header-content h1 {
    font-weight: 800;
    font-size: 1.1rem;
    line-height: 1.1;
    letter-spacing: -0.5px;
    margin-bottom: 2px;
    color: #ffffff !important;
    text-transform: uppercase;
    transition: all 0.3s ease;
}

.help-btn {
    background-color: var(--accent-blue);
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.help-btn:hover {
    transform: scale(1.1);
    background-color: white;
    color: var(--accent-blue);
}

.main-header.shrink .help-btn {
    width: 24px;
    height: 24px;
    font-size: 14px;
}

.main-header .subtitle {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 0;
}

/* Sections */
.bvd-section {
    margin-bottom: 15px;
}

.section-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 8px;
    gap: 4px;
}

.section-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.section-date {
    font-size: 10px;
    color: var(--text-secondary);
    font-style: italic;
    line-height: 1.2;
}

/* Yard Card Styling - COMPACT VERSION. Lives inside .main-header (not app-container), so it
   carries its own max-width/centering to line up with the rest of the header content. */
.yard-card {
    max-width: 560px;
    width: calc(100% - 40px);
    margin: 8px auto 0;
    background-color: var(--card-bg);
    border-radius: 4px;
    border: 1px solid var(--card-border);
    padding: 10px 15px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: padding 0.25s ease;
}

/* Compacts in lockstep with the header's own .shrink transition — same trigger, same class. */
.main-header.shrink .yard-card {
    padding: 4px 15px;
    margin-top: 4px;
}

.main-header.shrink .price-value {
    font-size: 18px;
}

.main-header.shrink .result-label {
    font-size: 8px;
}

.main-header.shrink .yard-card .effective-date,
.main-header.shrink .yard-card .yard-note {
    display: none;
}

.result-label {
    display: block;
    font-size: 9px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.price-display {
    margin-bottom: 4px;
}

.price-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--accent-red);
}

.unit {
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: 3px;
}

.effective-date {
    font-size: 10px;
    color: var(--text-secondary);
    padding-top: 8px;
    border-top: 1px solid #eee;
    line-height: 1.2;
}

.yard-note {
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 4px;
    font-style: italic;
    opacity: 0.85;
}

/* Info Trigger & Label */
.label-with-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.info-trigger {
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    padding: 4px; /* Larger hit area */
    transition: all 0.2s;
    vertical-align: middle;
}

.info-trigger:hover {
    color: var(--accent-red);
    transform: scale(1.2);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(2px);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.show {
    display: flex;
}

/* Help Drawer Variation */
.modal.help-drawer {
    justify-content: flex-end;
    padding: 0;
}

.modal.help-drawer .modal-content {
    height: 100%;
    max-height: 100vh;
    width: 85%;
    max-width: 400px;
    border-radius: 0;
    transform: translateX(100%);
    display: flex;
    flex-direction: column;
}

.modal.help-drawer.show .modal-content {
    transform: translateX(0);
}

.modal-content {
    background-color: #ffffff;
    border-radius: 12px;
    width: 100%;
    max-width: 450px;
    box-shadow: -10px 0 30px rgba(0,0,0,0.2);
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: modalFadeIn 0.3s ease;
}

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

.modal-header {
    background-color: var(--accent-blue);
    color: white;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
}

.close-modal {
    font-size: 24px;
    cursor: pointer;
    opacity: 0.8;
    line-height: 1;
}

.close-modal:hover {
    opacity: 1;
}

.modal-body {
    padding: 24px;
    font-size: 14px;
    color: var(--text-primary);
    overflow-y: auto;
    flex: 1;
}

.modal-body p {
    margin-bottom: 12px;
}

.modal-body ul {
    margin-bottom: 15px;
    padding-left: 20px;
}

.modal-body li {
    margin-bottom: 5px;
}

/* Guide Accordion Styles */
/* Guide Static Styles */
.guide-static {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.guide-intro {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 0;
    font-style: italic;
}

.guide-section h4 {
    color: var(--accent-blue);
    margin: 0 0 8px 0;
    font-size: 16px;
    border-bottom: 2px solid #f0f2f5;
    padding-bottom: 4px;
}

.guide-section p {
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
}

.guide-section ul {
    margin: 8px 0 0 0;
    padding-left: 20px;
}

.guide-section li {
    margin-bottom: 6px;
    font-size: 14px;
}

.support-alert {
    background-color: #fff4f4;
    border-left: 4px solid var(--accent-red);
    padding: 15px;
    margin-top: 10px;
    font-size: 13px;
    border-radius: 0 8px 8px 0;
}

.disclosure-link {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    color: var(--accent-red);
    text-decoration: none;
    font-weight: 700;
    font-size: 12px;
}

.disclosure-link i {
    font-size: 10px;
}

.disclosure-link:hover {
    text-decoration: underline;
}

/* Filters & Slicers */
.filters-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 8px;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group label, .search-container label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.multi-select {
    position: relative;
    width: 100%;
}

.multi-select-btn {
    width: 100%;
    padding: 8px 12px;
    background-color: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 4px;
    text-align: left;
    font-size: 16px; /* Prevents iOS auto-zoom */
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.multi-select-btn::after {
    content: "";
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #666;
}

.multi-select-btn:focus {
    outline: none;
    border-color: var(--accent-red);
    box-shadow: 0 0 0 3px rgba(237, 41, 43, 0.1);
}

.multi-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 250px;
    overflow-y: auto;
    background: white;
    border: 1px solid var(--card-border);
    border-radius: 4px;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    margin-top: 4px;
}

.multi-select-dropdown.show {
    display: block;
}

.multi-select-option {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
    user-select: none;
}

.multi-select-option:last-child {
    border-bottom: none;
}

.multi-select-option:hover {
    background-color: #f8f9fa;
}

.multi-select-option input {
    margin-right: 10px;
    width: 16px;
    height: 16px;
    accent-color: var(--accent-red);
    cursor: pointer;
}

#site-search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--card-border);
    border-radius: 4px;
    font-size: 16px; /* Prevents iOS auto-zoom */
    font-family: var(--font-main);
    background-color: white;
    color: var(--text-primary);
    transition: all 0.2s;
}

#site-search:focus {
    outline: none;
    border-color: var(--accent-red);
    box-shadow: 0 0 0 3px rgba(237, 41, 43, 0.1);
}

.search-container {
    margin-bottom: 10px;
}

/* Site List Styling */
.site-item {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-item.best-price {
    border: 2px solid var(--accent-green);
    background-color: #f8fff9;
}

.site-info h3 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 2px;
}

.site-location {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.site-price-value {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
}

.best-price-badge, .diff-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 10px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.best-price-badge {
    background-color: var(--accent-green);
    color: white;
}

.diff-badge {
    background-color: #f1f3f5;
    color: var(--text-secondary);
    border: 1px solid var(--card-border);
}

.network-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 2px;
}

/* Exchange Rate Banner */
.exchange-rate-banner {
    background-color: #f8f9fa;
    border: 1px dashed var(--card-border);
    border-radius: 4px;
    padding: 6px 10px;
    margin-bottom: 10px;
    font-size: 11px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.2;
}

.exchange-rate-banner strong {
    color: var(--text-primary);
}

.exchange-rate-banner .source {
    font-size: 9px;
    opacity: 0.8;
}

/* Currency Info in Cards */
.currency-note {
    font-size: 10px;
    color: var(--accent-red);
    font-weight: 700;
    margin-top: 4px;
}

.site-price {
    text-align: right;
}

.site-price .unit {
    display: block;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-top: -2px;
}

.no-results {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-style: italic;
}

/* Actions */
.actions-container {
    margin-bottom: 12px;
    display: flex;
    justify-content: center;
}

.clear-btn {
    background: none;
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    padding: 6px 16px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 20px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
}

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

.clear-btn:active {
    transform: translateY(1px);
    opacity: 0.8;
}

/* Footer */
footer {
    text-align: center;
    padding-top: 15px;
    border-top: 1px solid var(--card-border);
    margin-top: 15px;
}

footer p {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

@media (max-width: 600px) {
    body {
        padding-bottom: 20px;
    }
    .app-container {
        padding: 0 12px;
    }
    .main-header {
        padding: 0.5rem 0;
        margin-bottom: 8px;
    }
    .header-content {
        gap: 10px;
        padding: 0 12px;
    }
    .header-logo {
        max-width: 70px;
    }
    .header-content h1 {
        font-size: 1rem;
    }
    .main-header .subtitle {
        display: none; /* Hide subtitle on mobile to save space */
    }
    
    .bvd-section {
        margin-bottom: 10px;
    }

    .yard-card {
        margin: 6px auto 0;
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto auto;
        align-items: center;
        padding: 6px 15px;
        text-align: left;
        gap: 0 10px;
    }
    .yard-card .label-with-info {
        grid-column: 1;
        grid-row: 1;
        margin-bottom: 0;
        justify-content: flex-start;
    }
    .yard-card .result-label {
        margin-bottom: 0;
        font-size: 9px;
    }
    .yard-card .price-display {
        grid-column: 2;
        grid-row: 1 / span 2;
        margin-bottom: 0;
    }
    .yard-card .price-value {
        font-size: 22px;
    }
    .yard-card .effective-date {
        grid-column: 1;
        grid-row: 2;
        display: block;
        font-size: 8px;
        color: var(--text-secondary);
        border-top: none;
        padding-top: 0;
        margin-top: -2px;
        opacity: 0.8;
    }
    .yard-card .yard-note {
        grid-column: 1 / span 2;
        grid-row: 3;
        font-size: 8px;
        color: var(--text-secondary);
        opacity: 0.8;
        margin-top: 2px;
        text-align: left;
    }

    .section-header {
        margin-bottom: 6px;
        padding-bottom: 4px;
    }
    .section-header h2 {
        font-size: 13px;
    }
    .section-date {
        font-size: 9px;
    }

    .exchange-rate-banner {
        padding: 4px 6px;
        margin-bottom: 6px;
        font-size: 9px;
    }

    .filters-container {
        grid-template-columns: 1fr 1fr; /* Keep side-by-side */
        gap: 8px;
        margin-bottom: 6px;
    }
    .filter-group label, .search-container label {
        font-size: 9px;
        margin-bottom: 2px;
    }
    .multi-select-btn, #site-search {
        padding: 6px 10px;
        font-size: 12px;
    }

    .search-container {
        margin-bottom: 6px;
    }

    .actions-container {
        margin-bottom: 6px;
    }

    .site-item {
        padding: 8px 10px;
        margin-bottom: 4px;
    }
    .site-info h3 {
        font-size: 13px;
    }
    .site-price-value {
        font-size: 15px;
    }
}

.main-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: #ffffff;
    color: var(--text-secondary);
    padding: 4px 10px;
    text-align: center;
    font-size: 8px;
    z-index: 2000;
    border-top: 1px solid var(--card-border);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.main-footer p {
    margin: 0;
    line-height: 1.2;
}

/* =============================================
   Skeleton Loader
   ============================================= */
@keyframes shimmer {
    0%   { background-position: -400px 0; }
    100% { background-position:  400px 0; }
}

.skeleton {
    background: linear-gradient(90deg, #e8eaed 25%, #f5f6f7 50%, #e8eaed 75%);
    background-size: 800px 100%;
    animation: shimmer 1.4s infinite linear;
    border-radius: 4px;
}

/* Inline shimmer for the yard price value */
.skeleton-inline {
    display: inline-block;
    width: 80px;
    height: 28px;
    background: linear-gradient(90deg, #e8eaed 25%, #f5f6f7 50%, #e8eaed 75%);
    background-size: 800px 100%;
    animation: shimmer 1.4s infinite linear;
    border-radius: 4px;
    vertical-align: middle;
}

/* Skeleton site card shape */
.skeleton-card {
    pointer-events: none;
}

.skeleton-badge {
    width: 60px;
    height: 12px;
    margin-bottom: 8px;
}

.skeleton-name {
    width: 140px;
    height: 16px;
    margin-bottom: 6px;
}

.skeleton-location {
    width: 90px;
    height: 12px;
}

.skeleton-price-val {
    width: 64px;
    height: 20px;
    margin-bottom: 4px;
    margin-left: auto;
}

.skeleton-price-unit {
    width: 40px;
    height: 10px;
    margin-left: auto;
}

/* Error State Card */
.error-card {
    background-color: #fff8f8;
    border: 1px solid #ffcccc;
    border-left: 5px solid var(--accent-red);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    margin: 15px 0;
}

.error-icon-container {
    color: var(--accent-red);
    font-size: 32px;
    margin-bottom: 12px;
}

.error-card h3 {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.error-description {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 15px;
}

.error-footer {
    background-color: #fff0f0;
    border-radius: 4px;
    padding: 10px;
    font-size: 12px;
    color: #b30000;
    line-height: 1.4;
}

.error-text {
    color: var(--accent-red);
    font-weight: 700;
}
