/* ==========================================================================
   EasyToolio Health Tools Standard Design System
   Blood Alcohol Content (BAC) Calculator Component & Utility Styles
   ========================================================================== */

/* Design Tokens & Theme Variables */
:root {
    --bac-brand-primary: #f43f5e;
    --bac-brand-primary-hover: #e11d48;
    --bac-brand-primary-light: rgba(244, 63, 94, 0.12);
    --bac-brand-emerald: #10b981;
    --bac-brand-amber: #f59e0b;
    --bac-brand-orange: #f97316;
    --bac-brand-rose: #f43f5e;
    --bac-brand-sky: #0284c7;
    --bac-surface: #ffffff;
    --bac-surface-soft: #f8fafc;
    --bac-surface-card: #ffffff;
    --bac-border: #e2e8f0;
    --bac-border-strong: #cbd5e1;
    --bac-text: #0f172a;
    --bac-text-muted: #64748b;
    --bac-text-subtle: #94a3b8;
    --bac-ring: rgba(244, 63, 94, 0.35);
    --bac-slider-track: #e2e8f0;
    --bac-slider-thumb: #f43f5e;
    --bac-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --bac-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --bac-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
}

.dark {
    --bac-surface: #09090b;
    --bac-surface-soft: #121215;
    --bac-surface-card: #18181b;
    --bac-border: rgba(255, 255, 255, 0.08);
    --bac-border-strong: rgba(255, 255, 255, 0.16);
    --bac-text: #f8fafc;
    --bac-text-muted: #a1a1aa;
    --bac-text-subtle: #71717a;
    --bac-ring: rgba(244, 63, 94, 0.45);
    --bac-slider-track: rgba(255, 255, 255, 0.12);
    --bac-slider-thumb: #f43f5e;
    --bac-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
    --bac-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --bac-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
}

/* Glassmorphism & Reusable Cards */
.bac-glass-card {
    background: var(--bac-surface-card);
    border: 1px solid var(--bac-border);
    border-radius: 1.25rem;
    box-shadow: var(--bac-shadow-md);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.dark .bac-glass-card {
    background: rgba(24, 24, 27, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.bac-glass-card:hover {
    border-color: var(--bac-border-strong);
}

/* Primary Result Highlight Card */
.bac-result-card {
    background: linear-gradient(135deg, rgba(244, 63, 94, 0.08) 0%, rgba(245, 158, 11, 0.05) 100%), var(--bac-surface-card);
    border: 1px solid rgba(244, 63, 94, 0.2);
    border-radius: 1.25rem;
    position: relative;
    overflow: hidden;
}

.dark .bac-result-card {
    background: linear-gradient(135deg, rgba(244, 63, 94, 0.12) 0%, rgba(245, 158, 11, 0.06) 100%), #121215;
    border: 1px solid rgba(244, 63, 94, 0.25);
}

.bac-hero-value,
.bac-compact-value {
    display: block;
    min-width: 0;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25;
    font-variant-numeric: tabular-nums;
}

.bac-stat-chip {
    min-width: 0;
    overflow: hidden;
}

@media (max-width: 640px) {
    .bac-hero-value {
        font-size: 2.25rem;
        letter-spacing: -0.03em;
    }
}

/* BAC Gauge Visualizer */
.bac-gauge-track {
    width: 100%;
    height: 14px;
    border-radius: 9999px;
    background: linear-gradient(to right, #10b981 0%, #10b981 12%, #f59e0b 26%, #f97316 45%, #ef4444 70%, #991b1b 100%);
    position: relative;
    overflow: visible;
}

.bac-gauge-marker {
    position: absolute;
    top: -5px;
    bottom: -5px;
    width: 4px;
    background: #0f172a;
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.35);
    transition: left 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    left: 0%;
    transform: translateX(-50%);
    z-index: 10;
}

.dark .bac-gauge-marker {
    background: #ffffff;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

.bac-gauge-marker::after {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #0f172a;
}

.dark .bac-gauge-marker::after {
    border-top-color: #ffffff;
}

/* Synchronized Range Sliders */
.bac-range-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 5px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 9999px;
    outline: none;
    cursor: pointer;
    margin: 0.65rem 0 0.2rem 0;
    transition: background 0.2s ease;
}

.dark .bac-range-slider {
    background: rgba(255, 255, 255, 0.1);
}

.bac-range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #f43f5e;
    border: 2.5px solid #ffffff;
    box-shadow: 0 1.5px 4px rgba(0, 0, 0, 0.25);
    cursor: grab;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.15s ease, box-shadow 0.15s ease;
}

.bac-range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: #e11d48;
    box-shadow: 0 0 0 4px rgba(244, 63, 94, 0.25), 0 2px 5px rgba(0, 0, 0, 0.3);
}

.bac-range-slider::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.1);
}

.bac-range-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #f43f5e;
    border: 2.5px solid #ffffff;
    box-shadow: 0 1.5px 4px rgba(0, 0, 0, 0.25);
    cursor: grab;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.15s ease;
}

.bac-range-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    background: #e11d48;
}

/* Numeric Input Wrappers */
.bac-input-wrapper {
    display: inline-flex;
    align-items: center;
    background: rgba(244, 244, 245, 0.9);
    border: 1px solid rgba(228, 228, 231, 0.95);
    border-radius: 0.75rem;
    padding: 0.15rem 0.5rem;
    height: 32px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
}

.bac-input-wrapper.hidden,
.bac-range-slider.hidden {
    display: none !important;
}

.dark .bac-input-wrapper {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

.bac-input-wrapper:focus-within {
    background: #ffffff;
    border-color: #f43f5e;
    box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.2), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.dark .bac-input-wrapper:focus-within {
    background: rgba(24, 24, 27, 0.95);
    border-color: #f43f5e;
    box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.25);
}

.bac-input-field {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    font-size: 0.825rem;
    font-weight: 700;
    color: var(--bac-text);
    text-align: right;
    padding: 0;
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.bac-input-field::-webkit-inner-spin-button,
.bac-input-field::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Action Buttons & Dropdowns — Identical to SIP tool standard */
.fin-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    border-radius: 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--bac-surface-soft);
    border: 1px solid var(--bac-border);
    color: var(--bac-text);
    transition: all 0.15s ease;
    cursor: pointer;
    user-select: none;
}

.fin-action-btn:hover {
    background: var(--bac-brand-primary-light);
    border-color: var(--bac-brand-primary);
    color: var(--bac-brand-primary);
}

.fin-action-btn:active {
    transform: scale(0.98);
}

/* Export Popover Dropdown */
#export-dropdown {
    background-color: #ffffff !important;
    color: #0f172a !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: 0 20px 35px -5px rgba(0, 0, 0, 0.25), 0 10px 15px -5px rgba(0, 0, 0, 0.12) !important;
    z-index: 100 !important;
    opacity: 1 !important;
}

.dark #export-dropdown {
    background-color: #18181b !important;
    color: #f8fafc !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 20px 35px -5px rgba(0, 0, 0, 0.8) !important;
}

.fin-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    text-align: left;
    padding: 0.45rem 0.65rem;
    border-radius: 0.75rem;
    background: transparent;
    transition: all 0.15s ease;
    cursor: pointer;
    border: none;
    outline: none;
}

.fin-dropdown-item:hover {
    background: #f1f5f9 !important;
}

.dark .fin-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.08) !important;
}

/* Drink Counter Cards */
.drink-counter-card {
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.drink-counter-card:hover {
    border-color: rgba(244, 63, 94, 0.4);
}

.drink-qty-btn {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--bac-border);
    background: var(--bac-surface-soft);
    color: var(--bac-text);
    font-weight: 700;
    transition: all 0.15s ease;
    cursor: pointer;
}

.drink-qty-btn:hover {
    background: var(--bac-brand-primary);
    border-color: var(--bac-brand-primary);
    color: #ffffff;
}

.drink-qty-btn:active {
    transform: scale(0.92);
}

/* Elimination Schedule Table */
.fin-table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--bac-border);
    border-radius: 0.875rem;
    background: var(--bac-surface-card);
}

.dark .fin-table-container {
    background: rgba(24, 24, 27, 0.6);
}

.fin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    text-align: right;
}

.fin-table th {
    background: var(--bac-surface-soft);
    color: var(--bac-text-muted);
    font-weight: 600;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--bac-border);
    white-space: nowrap;
    text-transform: uppercase;
    font-size: 0.68rem;
    letter-spacing: 0.03em;
}

.dark .fin-table th {
    background: rgba(255, 255, 255, 0.03);
}

.fin-table th:first-child,
.fin-table td:first-child {
    text-align: left;
    padding-left: 1rem;
}

.fin-table td {
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--bac-border);
    color: var(--bac-text);
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.fin-table tr:last-child td {
    border-bottom: none;
}

.fin-table tr:hover td {
    background: rgba(244, 63, 94, 0.04);
}

/* Print Optimization */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
    }

    header,
    footer,
    nav,
    .no-print,
    #navbar,
    #sidebar,
    .tool-ad-slot,
    #ask-gemini,
    .theme-toggle-btn {
        display: none !important;
    }

    .bac-glass-card,
    .bac-result-card {
        border: 1px solid #ddd !important;
        box-shadow: none !important;
        background: #ffffff !important;
        page-break-inside: avoid;
    }
}


/* Input pill: neutralise global input rules (44px min-height, padding, white bg) so the field sits cleanly inside its bordered wrapper */
.is-tool-page .bac-input-wrapper {
    border: 1.5px solid #d4d4d8;
    background: #f4f4f5;
    border-radius: 0.75rem;
    overflow: hidden;
}
.dark .is-tool-page .bac-input-wrapper {
    border-color: rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.05);
}
.is-tool-page .bac-input-wrapper:hover { border-color: #a1a1aa; }
.is-tool-page .bac-input-wrapper:focus-within {
    border-color: #f43f5e;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.2);
}
.dark .is-tool-page .bac-input-wrapper:focus-within { background: rgba(24, 24, 27, 0.95); }
.is-tool-page .bac-input-wrapper .bac-input-field {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    padding: 0 !important;
    min-height: 0 !important;
    height: 100% !important;
    line-height: 1.2 !important;
    min-width: 0;
    font-size: 0.875rem !important;
}
@media (pointer: coarse), (max-width: 640px) {
    .is-tool-page .bac-input-wrapper .bac-input-field { font-size: 16px !important; }
}

/* Action buttons: one consistent hover (no pink-bg + green-border clash from the shared finance sheet) */
button.fin-action-btn:hover:not(.bg-rose-600):not(.border-emerald-500) {
    background: var(--bac-brand-primary-light) !important;
    border-color: var(--bac-brand-primary) !important;
    color: var(--bac-brand-primary) !important;
}
button.fin-action-btn.border-emerald-500 {
    background: rgba(236, 253, 245, 1) !important;
    border-color: #10b981 !important;
}
.dark button.fin-action-btn.border-emerald-500 { background: rgba(2, 44, 34, 0.3) !important; }

/* Section eyebrow labels on health tools: one colour, the health category rose (#e11d48), incl. the shared Education / FAQ / Guides labels. */
.ht-eyebrow { color: #e11d48 !important; }
.dark .ht-eyebrow { color: #fb7185 !important; }
html body .tool-guide .tg-eyebrow { color: #e11d48 !important; }
html.dark body .tool-guide .tg-eyebrow { color: #fb7185 !important; }

/* Accessible Field Tooltips */
.ht-tooltip-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: 0.35rem;
    vertical-align: middle;
}
.ht-tooltip-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    padding: 0;
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    border-radius: 9999px;
    font-size: 11px;
    line-height: 1;
    transition: color 0.15s ease, transform 0.15s ease;
}
.ht-tooltip-btn:hover,
.ht-tooltip-btn:focus-visible {
    color: #f43f5e;
    outline: none;
    transform: scale(1.15);
}
.dark .ht-tooltip-btn {
    color: #71717a;
}
.dark .ht-tooltip-btn:hover,
.dark .ht-tooltip-btn:focus-visible {
    color: #fb7185;
}
.ht-tooltip-box {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    width: max-content;
    max-width: 260px;
    padding: 0.5rem 0.75rem;
    font-size: 0.7rem;
    line-height: 1.4;
    font-weight: 400;
    text-align: left;
    color: #ffffff;
    background: rgba(24, 24, 27, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    z-index: 60;
}
.ht-tooltip-box::after {
    content: '';
    position: absolute;
    top: 100%;
    left: var(--ht-arrow-x, 50%);
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: rgba(24, 24, 27, 0.96) transparent transparent transparent;
}
.ht-tooltip-box.ht-placement-bottom {
    bottom: auto;
    top: calc(100% + 8px);
}
.ht-tooltip-box.ht-placement-bottom::after {
    top: auto;
    bottom: 100%;
    border-color: transparent transparent rgba(24, 24, 27, 0.96) transparent;
}
.ht-tooltip-wrap:hover .ht-tooltip-box,
.ht-tooltip-wrap:focus-within .ht-tooltip-box,
.ht-tooltip-wrap.ht-open .ht-tooltip-box {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}
.ht-tooltip-box.align-left {
    left: 0;
    transform: translateX(0) translateY(4px);
}
.ht-tooltip-box.align-left::after {
    left: var(--ht-arrow-x, 12px);
    transform: none;
}
.ht-tooltip-wrap:hover .ht-tooltip-box.align-left,
.ht-tooltip-wrap:focus-within .ht-tooltip-box.align-left,
.ht-tooltip-wrap.ht-open .ht-tooltip-box.align-left {
    transform: translateX(0) translateY(0);
}
.ht-tooltip-box.align-right {
    left: auto;
    right: 0;
    transform: translateX(0) translateY(4px);
}
.ht-tooltip-box.align-right::after {
    left: auto;
    right: var(--ht-arrow-x, 12px);
    transform: none;
}
.ht-tooltip-wrap:hover .ht-tooltip-box.align-right,
.ht-tooltip-wrap:focus-within .ht-tooltip-box.align-right,
.ht-tooltip-wrap.ht-open .ht-tooltip-box.align-right {
    transform: translateX(0) translateY(0);
}
@media (max-width: 640px) {
    .ht-tooltip-box,
    .ht-tooltip-box.align-left,
    .ht-tooltip-box.align-right {
        max-width: min(260px, calc(100vw - 28px));
        font-size: 0.68rem;
        padding: 0.45rem 0.65rem;
        left: 50%;
        right: auto;
        transform: translateX(-50%) translateY(4px);
    }
    .ht-tooltip-wrap:hover .ht-tooltip-box,
    .ht-tooltip-wrap:focus-within .ht-tooltip-box,
    .ht-tooltip-wrap.ht-open .ht-tooltip-box,
    .ht-tooltip-wrap:hover .ht-tooltip-box.align-left,
    .ht-tooltip-wrap:focus-within .ht-tooltip-box.align-left,
    .ht-tooltip-wrap.ht-open .ht-tooltip-box.align-left,
    .ht-tooltip-wrap:hover .ht-tooltip-box.align-right,
    .ht-tooltip-wrap:focus-within .ht-tooltip-box.align-right,
    .ht-tooltip-wrap.ht-open .ht-tooltip-box.align-right {
        transform: translateX(-50%) translateY(0);
    }
    .ht-tooltip-box::after,
    .ht-tooltip-box.align-left::after,
    .ht-tooltip-box.align-right::after {
        left: var(--ht-arrow-x, 50%);
        right: auto;
        transform: translateX(-50%);
    }
}
