:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --secondary: #10b981;
    --background: #0f172a;
    --surface: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;

    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/********************
 * Reset & Base
 ********************/
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.6;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

h1,
h2,
h3,
h4 {
    font-family: var(--font-heading);
    color: #fff;
    margin-bottom: 0.5em;
}

/********************
 * Navigation
 ********************/
.navbar {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 1rem 0;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-main);
    font-family: var(--font-heading);
}

.text-primary {
    color: var(--primary);
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary);
}

/* Language Selector */
.lang-selector {
    position: relative;
    margin-left: 1rem;
}

.lang-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.lang-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.lang-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem;
    display: none;
    flex-direction: column;
    min-width: 120px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

.lang-selector:hover .lang-dropdown {
    display: flex;
}

.lang-dropdown a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.5rem;
    border-radius: 4px;
    display: block;
    transition: background 0.2s;
}

.lang-dropdown a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--primary);
}




/********************
 * Hero / Calculator
 ********************/
.main-content {
    padding-top: 3rem;
    padding-bottom: 5rem;
}

.calculator-hero {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-bottom: 4rem;
}

@media (min-width: 768px) {
    .calculator-hero {
        align-items: center;
    }
}

.calculator-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1.5rem;
    padding: 2rem;
    width: 100%;
    max-width: 600px;
    box-shadow: var(--shadow-lg);
}

.calc-header {
    text-align: center;
    margin-bottom: 2rem;
}

.calc-header h1 {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}

.calc-header p {
    color: var(--text-muted);
}

/********************
 * Form Elements
 ********************/
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

input[type="number"],
select {
    width: 100%;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.875rem 1rem;
    color: var(--text-main);
    font-size: 1rem;
    transition: all 0.2s;
}

input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.unit-label {
    position: absolute;
    right: 1rem;
    color: var(--text-muted);
    pointer-events: none;
}

/* Radio Cards (Gender) */
.radio-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.radio-option input {
    display: none;
}

.custom-radio {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.75rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.radio-option input:checked+.custom-radio {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Toggle Switch (Units) */
.toggle-switch {
    display: flex;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    position: relative;
    padding: 0.25rem;
    width: fit-content;
    gap: 0.5rem;
}

.toggle-switch input {
    display: none;
}

.toggle-switch label {
    padding: 0.5rem 1rem;
    margin: 0;
    cursor: pointer;
    z-index: 2;
    color: var(--text-muted);
    transition: color 0.2s;
}

.toggle-switch input:checked+label {
    color: white;
}

.slider {
    position: absolute;
    top: 4px;
    left: 4px;
    bottom: 4px;
    width: calc(50% - 4px);
    background: var(--surface);
    /* Subtle difference or primary */
    background: var(--primary);
    border-radius: 0.25rem;
    transition: transform 0.3s ease;
    z-index: 1;
}

/* Logic for slider movement usually needs JS or complex CSS adjacency selectors. 
   Simplifying for now with active classes in JS or standard styling: */
input#imperial:checked~.slider {
    transform: translateX(100%);
}

.optional label .badge {
    background: var(--border);
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.btn-primary {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 0.75rem;
    font-size: 1.125rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

/********************
 * Results Section
 ********************/
.results-card {
    background: linear-gradient(135deg, var(--surface), #1e1e2d);
    border: 1px solid var(--border);
    border-radius: 1.5rem;
    padding: 2rem;
    width: 100%;
    max-width: 600px;
    animation: slideUp 0.5s ease-out;
}

.hidden {
    display: none;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-text:hover {
    color: var(--primary);
}

.main-stats {
    text-align: center;
    margin-bottom: 2rem;
}

.tdee-box {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.stat-value {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1;
    color: var(--primary);
    font-family: var(--font-heading);
}

.stat-value small {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted);
}

.mini-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.stat-item {
    background: var(--background);
    padding: 1rem;
    border-radius: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-item .label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.stat-item .value {
    font-weight: 700;
    font-size: 1.25rem;
}

/* Tabs */
.tabs {
    display: flex;
    background: var(--background);
    padding: 0.25rem;
    border-radius: 0.75rem;
    margin-bottom: 1.5rem;
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 0.75rem;
    border-radius: 0.5rem;
    color: var(--text-muted);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--surface);
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}

.calorie-target {
    text-align: center;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.goal-desc {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* Macros */
.macros-container {
    background: var(--background);
    padding: 1.5rem;
    border-radius: 1rem;
}

.macros-container h4 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.macro-bars {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.macro-item {
    display: grid;
    grid-template-columns: 60px 1fr 60px;
    align-items: center;
    gap: 1rem;
}

.macro-bar {
    height: 8px;
    background: var(--surface);
    border-radius: 999px;
    overflow: hidden;
}

.macro-bar>div {
    height: 100%;
    border-radius: 999px;
}

.protein .macro-bar>div {
    background: #ef4444;
}

/* Red */
.fats .macro-bar>div {
    background: #eab308;
}

/* Yellow */
.carbs .macro-bar>div {
    background: #22c55e;
}

/* Green */

.macro-val {
    text-align: right;
    font-weight: 600;
    color: var(--text-muted);
}

/********************
 * Content Sections
 ********************/
.info-content {
    max-width: 800px;
    margin: 0 auto;
}

.info-block {
    margin-bottom: 4rem;
}

.info-block h2 {
    color: var(--primary);
    margin-bottom: 1.5rem;
    font-size: 2rem;
}

.info-block p {
    font-size: 1.125rem;
    color: #cbd5e1;
    margin-bottom: 1.5rem;
}

.comparison-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.comparison-item {
    background: var(--surface);
    padding: 2rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
}

.comparison-item h3 {
    color: var(--secondary);
}

.faq-grid {
    display: grid;
    gap: 1.5rem;
}

.faq-item {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 1rem;
}

.faq-item h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.faq-item p {
    color: var(--text-muted);
}

/********************
 * Footer
 ********************/
.footer {
    border-top: 1px solid var(--border);
    padding: 3rem 0;
    margin-top: 4rem;
    text-align: center;
    color: var(--text-muted);
}

.disclaimer {
    font-size: 0.875rem;
    margin-top: 1rem;
    opacity: 0.7;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .comparison-grid {
        grid-template-columns: 1fr;
    }

    .stat-value {
        font-size: 2.5rem;
    }

    .nav-links {
        display: none;
    }

    .macros-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

/* Header Actions */
.header-actions {
    display: flex;
    gap: 1rem;
}

/* Pie Chart */
.macros-content {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 2rem;
    align-items: center;
}

.macro-chart-wrapper {
    display: flex;
    justify-content: center;
}

.pie-chart {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: conic-gradient(#ef4444 0% 30%,
            #eab308 30% 65%,
            #22c55e 65% 100%);
    position: relative;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

.pie-chart::after {
    content: "Macros";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--background);
    width: 65%;
    height: 65%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* Print Styles */
@media print {
    body {
        background: white;
        color: black;
    }

    .navbar,
    .footer,
    .calculator-hero,
    .info-content,
    .faq-section,
    #recalculate-btn,
    #print-btn,
    .tabs {
        display: none !important;
    }

    .main-content {
        padding: 0;
    }

    .results-card {
        box-shadow: none;
        border: none;
        background: white;
        color: black;
        max-width: 100%;
        padding: 0;
        animation: none;
    }

    .results-card h2,
    .results-card h3,
    .results-card h4,
    .stat-value small,
    .unit-label,
    label {
        color: black;
    }

    .stat-value,
    .calorie-target span {
        color: black;
        /* Or keep primary color if user wants color print */
    }

    .tdee-box,
    .stat-item {
        border: 1px solid #ddd;
        background: #f9fafb;
    }

    .pie-chart::after {
        background: white;
    }

    .results-header {
        justify-content: center;
        margin-bottom: 20px;
    }

    .results-header h2 {
        font-size: 24px;
        text-decoration: underline;
    }

    .macro-bar,
    .macro-bar>div {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/********************
 * RTL Support
 ********************/
html[dir="rtl"] .lang-selector {
    margin-left: 0;
    margin-right: 1rem;
}

html[dir="rtl"] .lang-dropdown {
    right: auto;
    left: 0;
}

html[dir="rtl"] .unit-label {
    right: auto;
    left: 1rem;
}

html[dir="rtl"] .slider {
    left: auto;
    right: 4px;
}

html[dir="rtl"] input#imperial:checked~.slider {
    transform: translateX(-100%);
}

html[dir="rtl"] .macro-val {
    text-align: left;
}

html[dir="rtl"] .toggle-switch {
    flex-direction: row;
}

margin-right: 0.5rem;
}

/* Fix for overlapping unit labels */
.input-wrapper input[type="number"] {
    padding-right: 3.5rem;
}

html[dir="rtl"] .input-wrapper input[type="number"] {
    padding-right: 1rem;
    padding-left: 3.5rem;
    text-align: right;
    /* Usually RTL inputs default to right, but explicit is good */
}

/* Fix for toggle switch slider alignment */
.toggle-switch label {
    min-width: 80px;
    text-align: center;
}