/* ==========================================================================
   EasyToolio Health Tools Standard Design System
   TDEE Calculator Component & Utility Styles
   ========================================================================== */

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

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

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

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

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

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

.dark .tdee-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);
}

.tdee-hero-value,
.tdee-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;
}

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

#stat-bmi-val {
    flex-shrink: 0 !important;
    overflow: visible !important;
    text-overflow: clip !important;
    min-width: fit-content !important;
}

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

/* Synchronized Range Sliders */
.tdee-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 .tdee-range-slider {
    background: rgba(255, 255, 255, 0.1);
}

.tdee-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;
}

.tdee-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);
}

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

.tdee-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;
}

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

/* Numeric Input Wrappers */
.tdee-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);
}

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

.dark .tdee-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);
}

.tdee-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 .tdee-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);
}

.tdee-input-field {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    font-size: 0.825rem;
    font-weight: 700;
    color: var(--tdee-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;
}

.tdee-input-field::-webkit-inner-spin-button,
.tdee-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(--tdee-surface-soft);
    border: 1px solid var(--tdee-border);
    color: var(--tdee-text);
    transition: all 0.15s ease;
    cursor: pointer;
    user-select: none;
}

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

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

/* Export Popover Dropdown (Solid Opaque Surface) */
#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;
}

/* Goal Chips */
.tdee-goal-card {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.tdee-goal-card:hover {
    transform: translateY(-2px);
}

.tdee-goal-card.active-goal {
    border-color: #f43f5e !important;
    background: rgba(244, 63, 94, 0.08) !important;
    box-shadow: 0 0 0 1px #f43f5e;
}

/* Macro Bar Transitions */
.macro-bar-fill {
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.energy-bar-fill {
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Toggle Switch */
.fin-toggle {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 22px;
    flex-shrink: 0;
}

.fin-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.fin-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #d1d5db;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 9999px;
}

.dark .fin-toggle-slider {
    background-color: #3f3f46;
}

.fin-toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: #ffffff;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.fin-toggle input:checked + .fin-toggle-slider {
    background-color: #f43f5e;
}

.fin-toggle input:checked + .fin-toggle-slider:before {
    transform: translateX(16px);
}

/* Tables */
.fin-table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--tdee-border);
    border-radius: 0.875rem;
    background: var(--tdee-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(--tdee-surface-soft);
    color: var(--tdee-text-muted);
    font-weight: 600;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--tdee-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(--tdee-border);
    color: var(--tdee-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;
    }

    .tdee-glass-card,
    .tdee-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 .tdee-input-wrapper {
    border: 1.5px solid #d4d4d8;
    background: #f4f4f5;
    border-radius: 0.75rem;
    overflow: hidden;
}
.dark .is-tool-page .tdee-input-wrapper {
    border-color: rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.05);
}
.is-tool-page .tdee-input-wrapper:hover { border-color: #a1a1aa; }
.is-tool-page .tdee-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 .tdee-input-wrapper:focus-within { background: rgba(24, 24, 27, 0.95); }
.is-tool-page .tdee-input-wrapper .tdee-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 .tdee-input-wrapper .tdee-input-field { font-size: 16px !important; }
}

/* Macro planner dropdown toolbar: equal-width, aligned dropdowns */
.macro-dd-toolbar .fin-dd,
.macro-dd-toolbar .fin-dd-btn { width: 100%; }
.macro-dd-toolbar .fin-dd-btn { justify-content: space-between; }
@media (min-width: 640px) { .macro-dd-toolbar { min-width: 340px; } }

/* 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(--tdee-brand-primary-light) !important;
    border-color: var(--tdee-brand-primary) !important;
    color: var(--tdee-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%);
    }
}
