/* General Body and App Container Styles */
body {
    margin: 0;
    font-family: Arial, sans-serif;
    transition: background-color 0.3s, color 0.3s;
}

body.modal-open > #app-container {
    filter: blur(4px);
    -webkit-filter: blur(4px);
    pointer-events: none;
}

#app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header Styles */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #ced4da;
    gap: 15px; 
}

#page-title {
    font-size: clamp(16px, 4.5vw, 20px); /* Responsive font size */
    font-weight: bold;
    margin: 0;
    flex-grow: 1; /* Allow title to take available space */
    min-width: 0; /* Allow title to shrink and truncate */
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 8px; /* Space between buttons */
    flex-shrink: 0; /* Prevent this group from shrinking */
}

/* Hide hamburger on desktop and show regular controls */
@media (min-width: 769px) {
    .hamburger { display: none !important; }
}

/* Hamburger Menu Styles */
.hamburger {
    display: none; /* Hidden by default on desktop */
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 25px;
    background: transparent !important; /* Override default button styles */
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 10;
}

.hamburger span {
    width: 100%;
    height: 3px;
    background-color: var(--text-color);
    border-radius: 5px;
    transition: all 0.3s linear;
    position: relative;
    transform-origin: 1px;
}

/* Hamburger animation to 'X' */
.hamburger.active span:nth-child(1) {
    transform: rotate(45deg);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
    transform: translateX(20px);
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg);
}

/* Responsive Header for Mobile */
@media (max-width: 768px) {
    .hamburger {
        display: flex; /* Show hamburger on mobile */
    }

    .header-controls {
        display: none; /* Hide the nav links by default on mobile */
        position: absolute;
        top: 60px; /* Position below the header */
        right: 0;
        background-color: var(--bg-color);
        border: 1px solid var(--border-color);
        border-top: none;
        border-radius: 0 0 0 8px;
        flex-direction: column;
        width: 150px;
        padding: 10px;
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    }

    .header-controls.active {
        display: flex; /* Show the menu when active */
    }

    .header-controls button {
        width: 100%;
        text-align: left;
    }

    /* Adjust footer for small screens */
    .footer-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
}

/* Main Content and Page Styles */
#main-content {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
}

.page {
    display: none; /* Hidden by default */
}

.page.active-page {
    display: block; /* Show the active page */
}

/* Button Styles */
.button-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.big-button {
    width: 80%;
    max-width: 400px;
    min-height: 80px;
    border-radius: 8px;
    padding: 10px;
    font-size: 16px;
    cursor: pointer;
    text-align: center;
    white-space: pre-wrap; /* Allows wrapping with \n */
}

/* Footer Styles */
.app-footer {
    padding: 10px 20px;
    border-top: 1px solid #ced4da;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    font-size: 12px;
    gap: 15px; /* Space between version and disclaimer */
}

.footer-version {
    white-space: nowrap; /* Prevents the version text from wrapping */
    flex-shrink: 0; /* Prevents this element from shrinking */
}

.footer-disclaimer {
    text-align: right; /* Aligns disclaimer text to the right if it wraps */
}

/* --- Light Theme --- */
:root {
    --bg-color: #f0f0f0;
    --text-color: #000000;
    --primary-btn-bg: #007BFF;
    --primary-btn-hover-bg: #0056b3;
    --secondary-btn-bg: #6c757d;
    --secondary-btn-hover-bg: #5a6268;
    --header-bg: #f0f0f0;
    --footer-bg: #e9ecef;
    --border-color: #ced4da;
    --card-bg: #ffffff;
    --link-color: #007BFF;
    --link-hover-color: #0056b3;
    --tab-bg: #e9ecef;
    --tab-active-bg: #f0f0f0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
}

.app-header {
    background-color: var(--header-bg);
    border-bottom-color: var(--border-color);
}

.app-footer {
    background-color: var(--footer-bg);
    border-top-color: var(--border-color);
}

.big-button {
    background-color: var(--primary-btn-bg);
    color: white;
    border: none;
}

.big-button:hover {
    background-color: var(--primary-btn-hover-bg);
}

button {
    background-color: var(--secondary-btn-bg);
    color: white;
    border: none;
    border-radius: 5px;
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
}

button:hover {
    background-color: var(--secondary-btn-hover-bg);
}

textarea, input[type="number"] {
    width: 100%;
    background-color: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 10px;
    font-size: 14px;
    box-sizing: border-box; /* Ensures padding doesn't add to width */
}

textarea {
    min-height: 100px;
}


/* --- Dark Theme --- */
[data-theme="dark"] {
    --bg-color: #2b2b2b;
    --text-color: #ffffff;
    --primary-btn-bg: #008CBA;
    --primary-btn-hover-bg: #007A9E;
    --secondary-btn-bg: #5a5a5a;
    --secondary-btn-hover-bg: #6a6a6a;
    --header-bg: #2b2b2b;
    --footer-bg: #1e1e1e;
    --border-color: #5a5a5a;
    --card-bg: #3c3c3c;
    --link-color: #00BFFF;
    --link-hover-color: #1E90FF;
    --tab-bg: #3c3c3c;
    --tab-active-bg: #2b2b2b;
}

/* --- Flowchart Specific Styles --- */
.breadcrumbs {
    margin-bottom: 20px;
}

.breadcrumb-button {
    background-color: transparent;
    color: var(--link-color);
    border: none;
    text-decoration: underline;
    padding: 0;
    font-size: 16px;
}

.breadcrumb-button:hover {
    color: var(--link-hover-color);
}

.flowchart-text {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 20px;
    white-space: pre-wrap;
}

.flowchart-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.flowchart-nav {
    margin-top: 30px;
    display: flex;
    gap: 10px;
}

/* --- Tab Styles --- */
.tab-container {
    border: 1px solid var(--border-color);
    border-radius: 5px;
}

.tab-buttons {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    /* New styles for horizontal scrolling on mobile */
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.tab-button {
    background: var(--tab-bg);
    color: var(--text-color);
    padding: 10px;
    border: none;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    cursor: pointer;
}

.tab-button.active {
    background: var(--tab-active-bg);
    border-bottom: 1px solid transparent;
}

.tab-content {
    display: none;
    padding: 20px;
}

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

/* --- Form & Calculator Styles --- */
.form-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 15px;
    align-items: center;
    margin-bottom: 15px;
}

.calculator-grid {
    display: grid;
    grid-template-columns: 2fr repeat(5, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.grid-header {
    font-weight: bold;
    text-align: center;
}

.results-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    margin-top: 15px;
    font-weight: bold;
}

.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-start !important;
}
.radio-group label {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* --- General Component Styles --- */
.button-group {
    margin-top: 15px;
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
}

/* Ensure severity buttons are exactly equal in size and text scales/wraps */
.regimen-severity-btn {
    flex: 1;
    min-width: 0; 
}

/* Specific styles for Standard Drinks by Type */
.std-drinks-grid {
    grid-template-columns: 1fr; /* Stack categories on small screens */
    gap: 20px;
}
.std-drinks-grid fieldset {
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 10px;
    display: grid;
    grid-template-columns: 1fr 70px;
    gap: 10px;
    align-items: center;
}
.std-drinks-grid legend {
    font-weight: bold;
    padding: 0 5px;
}

/* Media query for wider screens */
@media (min-width: 768px) {
    .std-drinks-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
}

/* --- New Calculator & Form Styles --- */
.calculator-container {
    overflow-x: auto; /* Adds horizontal scroll on small screens */
}

.calculator-note {
    margin-top: -10px;
    margin-bottom: 15px;
}

.calculator-item-instruction {
    font-style: italic;
    font-size: 14px;
    line-height: 1.4;
    margin: 5px 0 15px 0;
    opacity: 0.9;
}

.calculator-reference {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    line-height: 1.4;
    font-style: italic;
}

/* --- New Detailed Calculator List Styles --- */
.calculator-item {
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 10px 15px;
    margin-bottom: 15px;
}

.calculator-item legend {
    font-weight: bold;
    font-size: 18px;
    padding: 0 5px;
}

.radio-option {
    padding: 8px 0;
}

.radio-option label {
    display: flex;
    align-items: center;
    gap: 10px; /* Provides space between radio button and text */
    cursor: pointer;
}

/* --- Other Syndromes Page --- */
.calculator-page {
    display: none; /* Hidden by default */
    margin-top: 20px;
}

.back-to-selection-btn {
    margin-bottom: 20px;
    align-self: flex-start; /* Aligns the button to the left */
}

/* --- Contact List Styles --- */
.contact-list {
    list-style-type: none;
    padding-left: 0;
}

.contact-list li {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 15px;
    margin-bottom: 10px;
}

.contact-list a {
    color: var(--link-color);
    text-decoration: none;
    font-weight: bold;
}

.contact-list a:hover {
    text-decoration: underline;
    color: var(--link-hover-color);
}

/* Modal Styles */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1000; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.5); /* Black w/ opacity */
}

.modal-content {
    background-color: var(--card-bg);
    color: var(--text-color);
    margin: 10% auto; /* 10% from the top and centered */
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 80%;
    max-width: 600px;
    position: relative;
}

.close-button {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
}

.close-button:hover,
.close-button:focus {
    color: var(--text-color);
    text-decoration: none;
    cursor: pointer;
}

/* Style for the mandatory disclaimer modal button */
#disclaimer-modal button {
    background-color: var(--primary-btn-bg);
}

/* Link-style button */
.link-button {
    background: none!important;
    border: none;
    padding: 0!important;
    color: var(--link-color);
    text-decoration: underline;
    cursor: pointer;
    font-size: inherit; /* Inherit font size from parent */
    font-family: inherit;
}

.link-button:hover {
    color: var(--link-hover-color);
}