/* ==========================================================================
   1. CSS VARIABLES (:root)
   ========================================================================== */

:root {
    /* Color palette */
    --primary-color: #2c3e50;
    --secondary-color: #7f8c8d;
    --accent-color: #A61816;
    --accent-hover: #8A1412;
    --success-color: #39833c; /* WCAG AA compliant: 4.68:1 with white */
    --success-hover: #2d6930; /* Darker hover state */
    --danger-color: #cf382d; /* WCAG AA compliant: 4.93:1 with white */
    --danger-hover: #aa2e25; /* Darker hover state */
    --info-color: #2196F3;
    --warn-color: #ffc107;

    /* Text colors */
    --text-dark: #333;
    --text-medium: #555;
    --text-light: #777;

    /* Background colors */
    --bg-light: #f5f5f5;
    --bg-white: #fff;
    --bg-light-hover: #e9ecef;

    /* Border colors */
    --border-light: #ddd;
    --border-lighter: #eee;

    /* Spacing - compact for mobile */
    --space-xs: 0.25rem;  /* 4px */
    --space-sm: 0.5rem;   /* 8px */
    --space-md: 0.75rem;  /* 12px - tighter */
    --space-lg: 1rem;     /* 16px - tighter */
    --space-xl: 1.5rem;   /* 24px - tighter */

    /* Touch targets (WCAG 2.5.5) */
    --touch-target-min: 44px;
    --touch-target-comfortable: 48px;

    /* Form elements */
    --form-input-height-min: 44px;
    --form-input-padding: 0.75rem 1rem;
    --form-input-font-size: 16px;  /* Prevents iOS zoom on focus */

    /* Mobile viewport */
    --mobile-padding: 16px;
    --mobile-padding-comfortable: 20px;

    /* Line heights for typography - compact for mobile */
    --line-height-tight: 1.2;
    --line-height-normal: 1.4;   /* Tighter than WCAG 1.5, more compact */
    --line-height-relaxed: 1.6;

    /* Focus indicators */
    --focus-outline-width: 3px;
    --focus-outline-color: var(--accent-color);
    --focus-outline-offset: 2px;

    /* Font sizes - mobile-optimized (compact but readable) */
    --text-xs: 0.8125rem; /* 13px - small labels */
    --text-sm: 0.875rem;  /* 14px - body text */
    --text-md: 0.9375rem; /* 15px - default body */
    --text-lg: 1rem;      /* 16px - headings */
    --text-xl: 1.125rem;  /* 18px - larger headings */
    --text-xxl: 1.25rem;  /* 20px - page titles */

    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-round: 50%;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   2. TYPOGRAPHY
   ========================================================================== */

/* Base typography */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: var(--text-md);  /* 15px - compact but readable */
    line-height: var(--line-height-normal);  /* 1.4 - compact */
    color: var(--text-dark);
    background-color: var(--bg-light);
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    margin-top: 0;
    margin-bottom: 0;
}

.section-title h2,
.section-title h3,
.stat-card h3,
.results-section h3,
.modal-content h3 {
    color: var(--primary-color);
    line-height: var(--line-height-normal);
}

.results-section h3 {
    border-bottom: 2px solid var(--border-lighter);
    padding-bottom: var(--space-xs);
    margin-bottom: var(--space-md);
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: var(--space-md);
    font-size: var(--text-lg);
    font-family: Georgia, 'Times New Roman', Times, serif;
    line-height: var(--line-height-normal);
}

.recipes-list h3 {
    margin-bottom: 1.5rem;
    font-size: var(--text-xxl);
    color: var(--primary-color);
    line-height: var(--line-height-normal);
}

.ingredients-section h2 {
    font-size: var(--text-xl);
    line-height: var(--line-height-tight);
}

.ingredients-section h3 {
    font-size: var(--text-lg);
    line-height: var(--line-height-normal);
}

/* ==========================================================================
   3. LAYOUT (Header, Nav, Main, Footer)
   ========================================================================== */

/* Header */
header {
    background-color: var(--primary-color);
    color: white;
    padding: var(--space-md) var(--space-xl);
    box-shadow: var(--shadow-md);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-lg);
    max-width: 1400px;
    margin: 0 auto;
}

.site-title {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 600;
    line-height: var(--line-height-tight);
}

.site-title .title-line {
    display: inline;
}

/* Header nav container */
#header-nav-container {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

/* ==========================================================================
   Modern Navigation System
   ========================================================================== */

/* Mobile Bottom Navigation */
.nav-mobile-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--bg-white);
    border-top: 1px solid var(--border-light);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: none; /* Hidden by default, shown on mobile */
}

.nav-mobile-bottom .nav-items {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: var(--space-xs) 0;
    list-style: none;
    margin: 0;
}

.nav-mobile-bottom .nav-item {
    flex: 1;
    text-align: center;
}

.nav-mobile-bottom .nav-item a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: var(--space-xs);
    min-height: var(--touch-target-min);
    color: var(--text-medium);
    text-decoration: none;
    transition: color 0.2s ease, transform 0.15s ease;
    font-size: var(--text-xs);
}

.nav-mobile-bottom .nav-item a:hover {
    color: var(--accent-color);
    transform: translateY(-2px);
}

.nav-mobile-bottom .nav-item a:focus {
    outline: var(--focus-outline-width) solid var(--focus-outline-color);
    outline-offset: var(--focus-outline-offset);
}

.nav-mobile-bottom .nav-item.nav-active a {
    color: var(--accent-color);
    font-weight: 600;
}

.nav-mobile-bottom .nav-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.nav-mobile-bottom .nav-label {
    font-size: var(--text-xs);
    line-height: var(--line-height-tight);
}

/* Mobile Hamburger Menu */
.nav-mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.nav-mobile-menu-overlay.nav-menu-open {
    opacity: 1;
    visibility: visible;
}

.nav-mobile-menu {
    position: fixed;
    top: 0;
    right: -100%;
    bottom: 0;
    width: 80%;
    max-width: 320px;
    background-color: var(--bg-white);
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1100;
    overflow-y: auto;
    transition: right 0.3s ease;
}

.nav-mobile-menu.nav-menu-open {
    right: 0;
}

.nav-mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-light);
    background-color: var(--primary-color);
    color: white;
}

.nav-mobile-menu-header h2 {
    margin: 0;
    font-size: var(--text-lg);
    line-height: var(--line-height-tight);
}

.nav-mobile-menu-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: white;
    cursor: pointer;
    padding: 0;
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.nav-mobile-menu-close:hover {
    opacity: 0.8;
}

.nav-mobile-menu-close:focus {
    outline: var(--focus-outline-width) solid white;
    outline-offset: var(--focus-outline-offset);
}

.nav-mobile-menu .nav-items {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-mobile-menu .nav-item {
    border-bottom: 1px solid var(--border-lighter);
}

.nav-mobile-menu .nav-item a {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg);
    color: var(--text-dark);
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease;
    min-height: var(--touch-target-comfortable);
}

.nav-mobile-menu .nav-item a:hover {
    background-color: var(--bg-light);
    color: var(--accent-color);
}

.nav-mobile-menu .nav-item a:focus {
    outline: var(--focus-outline-width) solid var(--focus-outline-color);
    outline-offset: calc(var(--focus-outline-offset) * -1);
}

.nav-mobile-menu .nav-item.nav-active a {
    background-color: rgba(166, 24, 22, 0.1);
    color: var(--accent-color);
    font-weight: 600;
    border-left: 4px solid var(--accent-color);
}

.nav-mobile-menu .nav-icon {
    font-size: 1.5rem;
    line-height: 1;
    width: 1.5rem;
    text-align: center;
}

.nav-mobile-menu .nav-label {
    flex: 1;
    font-size: var(--text-md);
    line-height: var(--line-height-normal);
}

.nav-mobile-menu .nav-section-divider {
    padding: var(--space-md) var(--space-lg);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-light);
    background-color: var(--bg-light);
    border-bottom: 1px solid var(--border-lighter);
}

/* Hamburger button in header */
.nav-hamburger-btn {
    display: none; /* Hidden by default, shown on mobile */
    background: none;
    border: none;
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
    padding: var(--space-xs);
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
    line-height: 1;
}

.nav-hamburger-btn:hover {
    opacity: 0.8;
}

.nav-hamburger-btn:focus {
    outline: var(--focus-outline-width) solid white;
    outline-offset: var(--focus-outline-offset);
}

/* Desktop Navigation */
.nav-desktop {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.nav-desktop .nav-items {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-desktop .nav-item {
    position: relative;
}

.nav-desktop .nav-item a {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    color: white;
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: background-color 0.2s ease, transform 0.15s ease;
    min-height: var(--touch-target-min);
    font-size: var(--text-sm);
    line-height: var(--line-height-normal);
}

.nav-desktop .nav-item a:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.nav-desktop .nav-item a:focus {
    outline: var(--focus-outline-width) solid white;
    outline-offset: var(--focus-outline-offset);
}

.nav-desktop .nav-item.nav-active a {
    background-color: rgba(255, 255, 255, 0.2);
    font-weight: 600;
    border-bottom: 2px solid white;
}

.nav-desktop .nav-icon {
    font-size: 1.2rem;
    line-height: 1;
}

.nav-desktop .nav-label {
    font-size: var(--text-sm);
    line-height: var(--line-height-normal);
}

/* Desktop dropdown menu (for secondary items) */
.nav-desktop .nav-dropdown {
    position: relative;
}

.nav-desktop .nav-dropdown-toggle {
    cursor: pointer;
}

.nav-desktop .nav-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
    z-index: 100;
    list-style: none;
    padding: var(--space-xs) 0;
    margin: var(--space-xs) 0 0;
}

.nav-desktop .nav-dropdown:hover .nav-dropdown-menu,
.nav-desktop .nav-dropdown-toggle:focus + .nav-dropdown-menu,
.nav-desktop .nav-dropdown-menu:hover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-desktop .nav-dropdown-menu .nav-item {
    border: none;
}

.nav-desktop .nav-dropdown-menu .nav-item a {
    color: var(--text-dark);
    padding: var(--space-sm) var(--space-lg);
    border-radius: 0;
    justify-content: flex-start;
}

.nav-desktop .nav-dropdown-menu .nav-item a:hover {
    background-color: var(--bg-light);
    color: var(--accent-color);
    transform: none;
}

.nav-desktop .nav-dropdown-menu .nav-item.nav-active a {
    background-color: rgba(166, 24, 22, 0.1);
    color: var(--accent-color);
    font-weight: 600;
    border-bottom: none;
    border-left: 3px solid var(--accent-color);
}

/* Disabled navigation items */
.nav-item.nav-disabled a {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Navigation animations */
@keyframes navSlideIn {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes navFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Main content */
main {
    max-width: 1200px;
    margin: var(--space-xl) auto;
    padding: 0 var(--space-xl);
}

/* Footer */
footer {
    text-align: center;
    padding: var(--space-md);
    background-color: var(--primary-color);
    color: white;
    margin-top: var(--space-xl);
}

.stats-footer {
    margin: var(--space-xl) 0;
    padding: var(--space-md);
    text-align: center;
    font-size: var(--text-sm);
    color: #6c757d;
    background-color: transparent;
    box-shadow: none;
}

.stats-text {
    font-style: italic;
}

.stats-text span {
    font-weight: bold;
    color: var(--accent-color);
}

/* ==========================================================================
   4. COMPONENTS
   ========================================================================== */

/* Card containers
   ========================================================================== */

section, .card-container {
    background-color: var(--bg-white);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-sm);
}

.section-title {
    padding: var(--space-md) var(--space-md);
}

/* Generic cards */
.ingredient-card,
.recipe-card {
    background-color: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    box-shadow: var(--shadow-md);
    transition: box-shadow 0.3s ease;
}

.ingredient-card:hover,
.recipe-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* Card headers */
.ingredient-card h4,
.recipe-card h4 {
    margin-bottom: var(--space-xs); /* 4px - more compact */
    font-size: var(--text-lg); /* 16px - smaller */
    font-weight: 600;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: var(--space-xs); /* 4px - more compact */
    color: var(--primary-color);
}

/* Recipe card title styling */
.recipe-card h4.recipe-title {
    font-family: Georgia, 'Times New Roman', Times, serif;
    text-align: center;
    position: relative;
    line-height: var(--line-height-tight);
}

.recipe-card h4.recipe-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40%;
    height: 2px;
    background-color: var(--accent-color);
}

/* Card text styling */
.ingredient-card p,
.recipe-card p,
.ingredient-description {
    color: var(--text-medium);
    font-style: italic;
    font-family: Georgia, 'Times New Roman', Times, serif;
    margin-bottom: var(--space-sm);
}

/* Card action buttons */
.card-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm); /* 8px - compact */
    margin-top: var(--space-sm); /* 8px - compact */
    padding-top: var(--space-sm); /* 8px - compact */
    border-top: 1px solid #f0f0f0;
}

.ingredient-card .card-actions {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    flex-shrink: 0;
}

.recipe-card-compact-link {
    cursor: pointer;
}

.recipe-card-cta {
    margin-top: var(--space-sm);
    font-size: var(--text-xs);
    font-weight: 600;
    text-align: right;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--accent-color);
}

/* Recipe card components
   ========================================================================== */

/* Recipe meta information */
.recipe-card .recipe-meta {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    margin-bottom: var(--space-xs); /* 4px - more compact */
}

.recipe-card .recipe-rating {
    text-align: left;
}

.recipe-card .recipe-tags {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    min-width: 0;
    width: 100%;
}

/* Recipe description */
.recipe-card .recipe-description {
    margin-bottom: var(--space-sm);
    font-size: var(--text-sm);
}

/* Recipe ingredients, instructions, source */
.recipe-card .ingredients,
.recipe-card .instructions,
.recipe-card .recipe-source {
    margin: var(--space-xs) 0; /* 4px - more compact */
    font-family: Georgia, 'Times New Roman', Times, serif;
}

.recipe-card .ingredients h5,
.recipe-card .instructions h5 {
    font-size: var(--text-md); /* Smaller heading - 15px */
    color: var(--accent-color);
    margin-bottom: var(--space-xs); /* 4px - more compact */
    font-weight: 600;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: var(--line-height-tight);
}

.recipe-card .ingredients ul {
    list-style-type: disc;
    padding-left: 1.5rem;
    margin-top: var(--space-xs); /* 4px - more compact */
}

.recipe-card .ingredients ul li {
    padding: 2px 0; /* Tighter list items */
    border-bottom: none;
    display: list-item;
    line-height: var(--line-height-tight); /* 1.2 - tighter */
}

.recipe-card .instructions p {
    font-style: normal;
    white-space: pre-line;
    line-height: var(--line-height-tight); /* 1.2 - tighter */
    color: var(--text-dark);
    font-size: var(--text-sm);
}

.recipe-card .recipe-source h5 {
    font-size: var(--text-md); /* Smaller heading - 15px */
    color: var(--accent-color);
    margin-bottom: var(--space-xs); /* 4px - more compact */
    font-weight: 600;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: var(--line-height-tight);
}

.recipe-card .recipe-source p {
    font-style: normal;
    line-height: var(--line-height-tight); /* 1.2 - tighter */
    color: var(--text-dark);
    font-size: var(--text-sm);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.recipe-card .recipe-source a {
    word-wrap: break-word;
    overflow-wrap: break-word;
    display: inline-block;
    max-width: 100%;
}

.recipe-card .similar-cocktails {
    margin: var(--space-xs) 0;
    font-family: Georgia, 'Times New Roman', Times, serif;
}

.recipe-card .similar-cocktails h5 {
    font-size: var(--text-md);
    color: var(--accent-color);
    margin-bottom: var(--space-xs);
    font-weight: 600;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: var(--line-height-tight);
}

.recipe-card .similar-list {
    list-style-type: disc;
    padding-left: 1.5rem;
    margin-top: var(--space-xs);
}

.recipe-card .similar-list li {
    padding: 2px 0;
    line-height: var(--line-height-tight);
}

.recipe-card .similar-list a {
    color: var(--accent-color);
    text-decoration: none;
}

.recipe-card .similar-list a:hover {
    text-decoration: underline;
}

.recipe-card .similar-distance {
    margin-right: var(--space-xs);
    color: var(--text-medium);
    font-size: var(--text-xs);
}

.recipe-card .similar-transport {
    margin-left: var(--space-xs);
    color: var(--text-medium);
    font-size: var(--text-xs);
}

.recipe-card .similar-loading {
    color: var(--text-medium);
    font-size: var(--text-sm);
}

.recipe-card .cocktail-space-link {
    margin-top: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border-light);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.recipe-card .cocktail-space-link a {
    color: var(--accent-color);
    text-decoration: none;
    font-size: var(--text-sm);
}

.recipe-card .cocktail-space-link a:hover {
    text-decoration: underline;
}

/* Cocktail space highlight ring animation */
.highlight-ring {
    transform-box: fill-box;
    transform-origin: center;
}

@keyframes cocktail-space-pulse {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    100% {
        transform: scale(3);
        opacity: 0;
    }
}

/* Stat cards */
.stat-card p {
    font-size: 2rem;
    font-weight: bold;
    color: var(--info-color);
}

/* Ingredient card specific */
.ingredient-name {
    font-weight: bold;
    font-size: var(--text-lg);
    margin-right: var(--space-sm);
    color: var(--primary-color);
    line-height: var(--line-height-normal);
}

.ingredient-description {
    font-size: var(--text-sm);
    margin-top: var(--space-xs);
    line-height: var(--line-height-normal);
}

/* Analytics cards */
.analytics-card {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: var(--space-lg);
    margin-bottom: var(--space-xl);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.card-header {
    margin-bottom: 1.5rem;
}

.card-header h3 {
    margin-bottom: 0.5rem;
}

.card-description {
    color: #666;
    font-size: var(--text-sm);
    line-height: var(--line-height-normal);
}

/* Buttons
   ========================================================================== */

/* Button base - consolidated with WCAG touch targets */
button, .btn {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-md);
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
    transition: background-color 0.3s, transform 0.1s;
}

button:hover, .btn:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

button:active, .btn:active {
    transform: translateY(0);
}

button:disabled, .btn:disabled {
    background-color: var(--secondary-color);
    cursor: not-allowed;
    opacity: 0.6;
}

button:focus, .btn:focus {
    outline: var(--focus-outline-width) solid var(--focus-outline-color);
    outline-offset: var(--focus-outline-offset);
}

/* Button variants */
.btn-primary {
    background-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #1a2530;
}

.btn-secondary {
    background-color: var(--secondary-color);
}

.btn-secondary:hover {
    background-color: #666e6f;
}

.btn-success {
    background-color: var(--success-color);
}

.btn-success:hover {
    background-color: var(--success-hover);
}

.btn-danger {
    background-color: var(--danger-color);
}

.btn-danger:hover {
    background-color: var(--danger-hover);
}

/* Button outline variants */
.btn-outline {
    background-color: #f8f9fa;
    color: var(--primary-color);
    border: 1px solid #dee2e6;
}

.btn-outline:hover {
    background-color: var(--bg-light-hover);
}

.btn-outline-danger {
    background-color: #fff5f5;
    color: #e74c3c;
    border: 1px solid #ffcdd2;
}

.btn-outline-danger:hover {
    background-color: #fee;
}

/* Button sizes */
.btn-small {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-sm);
    min-height: var(--touch-target-min);
}

/* Circle buttons - meets touch target minimum */
.btn-circle {
    flex: 0 0 auto;
    width: var(--touch-target-min);
    height: var(--touch-target-min);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-round);
    font-size: var(--text-md);
    padding: 0;
    line-height: 1;
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
}

/* Button with icon */
.btn-icon {
    display: inline-block;
    margin-right: 5px;
    font-weight: bold;
    font-size: 16px;
}

/* Authentication controls */
.auth-controls {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

#user-info:not(.hidden) {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

#user-info.hidden {
    display: none !important;
}

#username-display {
    font-size: var(--text-sm);
    font-weight: 500;
    color: white;
    opacity: 0.9;
}

.btn-auth {
    padding: var(--space-sm) var(--space-lg);
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: 500;
    transition: all 0.2s ease;
    min-height: var(--touch-target-min);
}

.btn-auth:hover {
    background-color: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

.btn-auth:focus {
    outline: var(--focus-outline-width) solid white;
    outline-offset: var(--focus-outline-offset);
}

.btn-signup {
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.btn-signup:hover {
    background-color: var(--success-hover);
    border-color: var(--success-hover);
}

.btn-logout {
    padding: var(--space-sm) var(--space-md);
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-sm);
    transition: all 0.2s ease;
    min-height: var(--touch-target-min);
}

.btn-logout:hover {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
}

.btn-logout:focus {
    outline: var(--focus-outline-width) solid white;
    outline-offset: var(--focus-outline-offset);
}

/* Tab buttons */
.tab-button {
    padding: var(--space-md) var(--space-lg);
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: var(--text-sm);
    color: #666;
    transition: all 0.2s;
    line-height: var(--line-height-normal);
}

.tab-button:hover {
    color: #333;
    background-color: #f5f5f5;
}

.tab-button.active {
    color: #1f77b4;
    border-bottom-color: #1f77b4;
    font-weight: 500;
}

.tab-button:focus {
    outline: var(--focus-outline-width) solid var(--focus-outline-color);
    outline-offset: var(--focus-outline-offset);
}

/* Breadcrumb buttons */
.breadcrumb-item {
    background: white;
    color: #333;
    border: 1px solid #ddd;
    padding: var(--space-xs) var(--space-md);
    border-radius: 4px;
    cursor: pointer;
    font-size: var(--text-sm);
    transition: all 0.2s;
    line-height: var(--line-height-normal);
}

.breadcrumb-item:hover {
    background: #1f77b4;
    color: white;
    border-color: #1f77b4;
}

.breadcrumb-item:focus {
    outline: var(--focus-outline-width) solid var(--focus-outline-color);
    outline-offset: var(--focus-outline-offset);
}

/* Tree toggle buttons */
.tree-toggle {
    background: none;
    border: none;
    font-size: 12px;
    color: var(--text-medium);
    cursor: pointer;
    padding: var(--space-xs) var(--space-xs);
    margin-right: 6px;
    min-width: 16px;
    text-align: center;
    border-radius: 2px;
}

.tree-toggle:hover {
    background-color: var(--border-lighter);
    color: var(--text-dark);
}

.tree-toggle:focus {
    outline: var(--focus-outline-width) solid var(--focus-outline-color);
    outline-offset: var(--focus-outline-offset);
}

/* Carousel arrow buttons */
.carousel-arrow {
    font-size: 2rem;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.carousel-arrow:hover {
    background-color: var(--accent-hover);
    transform: scale(1.1);
}

.carousel-arrow:active {
    transform: scale(0.95);
}

.carousel-arrow:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    transform: none;
}

.carousel-arrow:focus {
    outline: var(--focus-outline-width) solid var(--focus-outline-color);
    outline-offset: var(--focus-outline-offset);
}

/* Existing tag buttons */
.existing-tag-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    border: 1px solid #e0e0e0;
    background: #f8f9fa;
    color: var(--text-dark);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    cursor: pointer;
    transition: all 0.2s ease;
}

.existing-tag-btn:hover:not(:disabled) {
    background: #e9ecef;
    border-color: #dee2e6;
    transform: translateY(-1px);
}

.existing-tag-btn:active:not(:disabled) {
    transform: translateY(0);
}

.existing-tag-btn:focus {
    outline: var(--focus-outline-width) solid var(--focus-outline-color);
    outline-offset: var(--focus-outline-offset);
}

.existing-tag-btn.tag-already-added {
    background: #f1f3f4;
    color: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

.existing-tag-btn .tag-icon {
    font-size: 10px;
}

.existing-tag-btn .tag-name {
    font-weight: 500;
}

/* Forms
   ========================================================================== */

/* Form layout */
.form-group {
    margin-bottom: 0.375rem; /* 6px - compact */
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-group input[type="checkbox"] {
    margin: 0;
}

.checkbox-group label {
    margin-bottom: 0;
    display: inline;
}

.checkbox-group .tooltip {
    cursor: help;
    color: var(--text-secondary, #666);
    margin-left: 4px;
    font-size: 1em;
}

.form-group-inline {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.form-group-inline label {
    margin-bottom: 0;
    white-space: nowrap;
    min-width: fit-content;
}

.form-group-inline input,
.form-group-inline select,
.form-group-inline .tag-input-wrapper,
.form-group-inline .rating-search-group {
    flex: 1;
}

.form-row {
    display: flex;
    gap: var(--space-md);
    margin-bottom: 0.375rem; /* 6px - compact */
}

.form-row .form-group {
    flex: 1;
}

label {
    display: block;
    margin-bottom: 0.375rem; /* 6px - compact */
    font-weight: bold;
}

/* Input styles consolidated */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: var(--form-input-padding);
    min-height: var(--form-input-height-min);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: var(--form-input-font-size);
    line-height: var(--line-height-normal);
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: var(--focus-outline-width) solid var(--focus-outline-color);
    outline-offset: var(--focus-outline-offset);
    border-color: var(--accent-color);
}

textarea {
    resize: vertical;
    min-height: calc(var(--form-input-height-min) * 2);
}

/* Inline validation errors */
.field-error {
    display: block;
    color: var(--danger-color);
    font-size: var(--text-xs);
    margin-top: 0.25rem;
    line-height: var(--line-height-tight);
}

.form-group.has-error input,
.form-group.has-error select,
.form-group.has-error textarea {
    border-color: var(--danger-color);
}

.form-group.has-error input:focus,
.form-group.has-error select:focus,
.form-group.has-error textarea:focus {
    outline-color: var(--danger-color);
    border-color: var(--danger-color);
}

.ingredient-input.has-error {
    background-color: rgba(244, 67, 54, 0.05);
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(244, 67, 54, 0.2);
}

/* Checkboxes and radios - WCAG 2.5.5 touch targets */
input[type="checkbox"],
input[type="radio"] {
    min-width: 24px;
    min-height: 24px;
    width: 24px;
    height: 24px;
    cursor: pointer;
}

/* Input groups */
.input-group label {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: normal;
    cursor: pointer;
    min-height: var(--touch-target-min);
}

/* Focus indicator for checkboxes and radios */
input[type="checkbox"]:focus,
input[type="radio"]:focus {
    outline: var(--focus-outline-width) solid var(--focus-outline-color);
    outline-offset: var(--focus-outline-offset);
}

/* Form field layouts */
.ingredient-fields {
    display: flex;
    gap: var(--space-md);
    align-items: flex-start;
    margin-bottom: var(--space-md);
}

.ingredient-fields .form-group {
    flex: 1;
    margin-bottom: 0;
}

.ingredient-fields .form-group:first-child {
    flex: 0 0 100px;
}

.ingredient-fields .form-group:nth-child(2) {
    flex: 0 0 150px;
}

.ingredient-fields .remove-ingredient {
    flex: 0 0 auto;
    margin-top: var(--space-sm);
}

/* Item row styling */
.item-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px dashed var(--border-lighter);
}

.item-row-field-fixed {
    flex: 0 0 140px;
}

.item-row-field-expand {
    flex: 1;
    position: relative;
}

/* Form actions */
.form-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    align-items: flex-start;
    width: 120px;
    flex-shrink: 0;
    align-self: flex-end;
}

.form-actions button {
    width: 100%;
}

.form-actions.modal-actions {
    flex-direction: row;
    justify-content: flex-end;
    width: auto;
}

.form-actions.modal-actions button {
    width: auto;
}

.form-content-wrapper {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.main-search-fields {
    flex-grow: 1;
}

.add-row-wrapper {
    margin-top: var(--space-sm);
    margin-bottom: 0;
}

.ingredient-search-container .add-row-wrapper {
    text-align: right;
}

.modal-content .form-group small {
    font-size: 0.75em;
    color: #666;
    display: block;
    margin-top: var(--space-xs);
}

.form-actions.modal-actions {
    margin-top: 1.5rem;
}

/* Search bar
   ========================================================================== */

.search-bar {
    margin-bottom: var(--space-md);
}

.search-bar input {
    width: 100%;
    padding: var(--space-sm);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
}

/* Autocomplete */
.ingredient-search-container {
    position: relative;
    width: 100%;
}

.ingredient-search-container input {
    width: 100%;
    margin-bottom: var(--space-xs);
}

.ingredient-search-container select.ingredient-name {
    width: 100%;
    display: none;
}

.autocomplete-dropdown {
    position: absolute;
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    background-color: white;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: none;
}

.autocomplete-item {
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
    transition: background-color 0.2s;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background-color: #f0f7ff;
}

.autocomplete-item:focus {
    outline: var(--focus-outline-width) solid var(--focus-outline-color);
    outline-offset: var(--focus-outline-offset);
}

.autocomplete-item strong {
    font-weight: bold;
    color: var(--info-color);
}

/* Tags
   ========================================================================== */

/* Recipe card tag styles */
.recipe-card .existing-tags,
.recipe-card .no-tags-placeholder {
    font-size: 0.85em;
    white-space: nowrap;
    line-height: 1.2;
}

.recipe-card .existing-tags {
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recipe-card .no-tags-placeholder {
    color: #888;
    font-style: italic;
}

.recipe-card .add-tag-btn {
    font-size: 0.8em;
    padding: var(--space-xs) var(--space-sm);
    background-color: transparent;
    border: 1px solid #ccc;
    border-radius: 12px;
    cursor: pointer;
    color: #555;
    margin-left: var(--space-xs);
    white-space: nowrap;
    flex-shrink: 0;
}

.recipe-card .add-tag-btn:hover {
    background-color: var(--bg-light-hover);
    border-color: #bbb;
    color: #333;
}

.recipe-card .add-tag-btn:focus {
    outline: var(--focus-outline-width) solid var(--focus-outline-color);
    outline-offset: var(--focus-outline-offset);
}

/* Recipe card tag chip styles */
.recipe-card .tags-container {
    display: inline-flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    align-items: center;
}

.recipe-card .tag-chip {
    display: inline-flex;
    align-items: center;
    padding: var(--space-xs) var(--space-sm);
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 500;
    line-height: 1.2;
    border: 1px solid;
    transition: all 0.2s ease;
    gap: var(--space-xs);
}

.recipe-card .tag-chip.tag-public {
    background-color: #e0f2fe;
    color: #0c4a6e;
    border-color: #bae6fd;
}

.recipe-card .tag-chip.tag-private {
    background-color: #f3e8ff;
    color: #581c87;
    border-color: #e9d5ff;
}

.recipe-card .tag-remove-btn {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    margin: 0 0 0 var(--space-xs);
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.recipe-card .tag-remove-btn:hover {
    opacity: 1;
}

.recipe-card .tag-remove-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Search page tag input styles */
.tag-search-container {
    position: relative;
}

.tag-input-wrapper {
    position: relative;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--bg-white);
    min-height: 40px;
    padding: var(--space-xs);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-xs);
    transition: border-color 0.2s ease;
}

.tag-input-wrapper:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(166, 24, 22, 0.1);
}

.selected-tags-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    align-items: center;
}

.search-tag-chip {
    display: inline-flex;
    align-items: center;
    padding: var(--space-xs) var(--space-sm);
    background-color: var(--accent-color);
    color: white;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 500;
    gap: var(--space-xs);
}

.search-tag-chip.tag-public {
    background-color: #2196F3;
}

.search-tag-chip.tag-private {
    background-color: #9C27B0;
}

.search-tag-chip-remove {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    margin: 0;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s ease;
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.search-tag-chip-remove:hover {
    opacity: 1;
}

.tag-input-wrapper input[type="text"] {
    border: none;
    outline: none;
    background: transparent;
    flex: 1;
    min-width: 120px;
    padding: var(--space-xs) 0;
    font-size: var(--text-md);
}

.tag-suggestions-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tag-suggestions-dropdown.hidden {
    display: none;
}

.tag-suggestion-item {
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid var(--border-lighter);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tag-suggestion-item:last-child {
    border-bottom: none;
}

.tag-suggestion-item:hover,
.tag-suggestion-item.highlighted {
    background-color: var(--bg-light);
}

.tag-suggestion-item:focus {
    outline: var(--focus-outline-width) solid var(--focus-outline-color);
    outline-offset: var(--focus-outline-offset);
}

.tag-suggestion-name {
    font-weight: 500;
}

.tag-suggestion-type {
    font-size: var(--text-sm);
    color: var(--text-light);
    text-transform: capitalize;
}

.tag-suggestion-type.public {
    color: #2196F3;
}

.tag-suggestion-type.private {
    color: #9C27B0;
}

.tag-suggestions-dropdown .no-results,
.tag-suggestions-dropdown .loading {
    padding: var(--space-md);
    text-align: center;
    color: var(--text-light);
    font-style: italic;
}

/* Name search autosuggest dropdown */
.name-search-wrapper {
    position: relative;
    flex: 1;
}

.name-search-wrapper input {
    width: 100%;
}

.name-suggestions-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.name-suggestions-dropdown.hidden {
    display: none;
}

.name-suggestion-item {
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid var(--border-lighter);
}

.name-suggestion-item:last-child {
    border-bottom: none;
}

.name-suggestion-item:hover,
.name-suggestion-item.highlighted {
    background-color: var(--bg-light);
}

.name-suggestions-dropdown .no-results,
.name-suggestions-dropdown .loading {
    padding: var(--space-md);
    text-align: center;
    color: var(--text-light);
    font-style: italic;
}

/* Admin tag management */
.tags-management-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--bg-white);
}

.tag-management-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-lighter);
}

.tag-management-item:last-child {
    border-bottom: none;
}

.tag-management-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.tag-management-name {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: var(--space-xs);
}

.tag-management-usage {
    font-size: var(--text-sm);
    color: var(--text-light);
}

.tag-management-actions {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.tags-management-list .loading-message,
.tags-management-list .error-message,
.tags-management-list .empty-message {
    padding: var(--space-lg);
    text-align: center;
    color: var(--text-light);
    font-style: italic;
}

.tags-management-list .error-message {
    color: var(--danger-color);
}

/* Tag modal styles */
#tag-input {
    margin-bottom: var(--space-sm);
    font-size: var(--text-sm);
}

.tag-chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-md);
    margin-bottom: var(--space-md);
    padding: var(--space-sm);
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background-color: #f9f9f9;
    min-height: 40px;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    padding: var(--space-xs) var(--space-md);
    border-radius: 14px;
    font-size: var(--text-xs);
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s, transform 0.1s;
    border: 1px solid transparent;
    font-weight: 500;
}

.tag-chip:hover {
    transform: translateY(-1px);
}

.tag-chip:focus {
    outline: var(--focus-outline-width) solid var(--focus-outline-color);
    outline-offset: var(--focus-outline-offset);
}

.tag-chip-public {
    background-color: #e0f2fe;
    color: #0c4a6e;
    border-color: #bae6fd;
}

.tag-chip-public:hover {
    background-color: #bae6fd;
    border-color: #7dd3fc;
}

.tag-chip-private {
    background-color: #f3e8ff;
    color: #581c87;
    border-color: #e9d5ff;
}

.tag-chip-private:hover {
    background-color: #e9d5ff;
    border-color: #c084fc;
}

.tag-chip .tag-icon {
    margin-right: 0.4rem;
    font-size: 1em;
    line-height: 1;
}

.tag-chip .tag-remove-btn {
    margin-left: 0.6rem;
    font-size: 0.9em;
    font-weight: bold;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.5;
    padding: 0;
    line-height: 1;
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tag-chip .tag-remove-btn:hover {
    opacity: 0.9;
}

/* Existing tags section */
#existing-tags-section {
    margin-bottom: var(--space-md);
    max-height: 300px;
    overflow-y: auto;
}

#public-tags-section,
#private-tags-section {
    margin-bottom: var(--space-md);
}

#public-tags-section h5,
#private-tags-section h5 {
    font-size: var(--text-sm);
    font-weight: 600;
    margin-bottom: var(--space-xs);
    color: var(--text-secondary);
}

.existing-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-bottom: var(--space-sm);
}

.existing-tags-list .no-tags,
.existing-tags-list .error,
.existing-tags-list .auth-required {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-style: italic;
    padding: var(--space-xs);
}

.existing-tags-list .error {
    color: var(--danger-600);
}

/* Rating components
   ========================================================================== */

/* Star rating */
.star-rating {
    display: flex;
    align-items: center;
    margin: 0;
    font-size: 1.2rem;
}

.star {
    color: #ddd;
    margin-right: 1px; /* Minimal spacing for compact star display */
}

.star.filled {
    color: var(--warn-color);
}

.star.no-rating {
    color: #ddd;
}

.star.zero-rating {
    color: #999;
    opacity: 0.6;
}

.star.half {
    position: relative;
    color: #ddd;
}

.star.half::before {
    content: "★";
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    overflow: hidden;
    color: var(--warn-color);
}

.rating-count, .rating-stats {
    color: var(--text-light);
    font-size: var(--text-sm);
    margin-left: var(--space-xs);
}

.rating-stats {
    margin-left: var(--space-sm);
}

/* Interactive star rating */
.star-rating.interactive {
    cursor: pointer;
}

.star.interactive {
    cursor: pointer;
    transition: transform 0.1s ease, color 0.2s ease;
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.star.interactive:hover {
    transform: scale(1.2);
}

.star.interactive.hover {
    color: var(--warn-color);
}

.star.interactive:focus {
    outline: var(--focus-outline-width) solid var(--focus-outline-color);
    outline-offset: var(--focus-outline-offset);
}

/* Star rating filter for search */
.rating-label-stars-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-xs);
}

.rating-label-stars-row label {
    margin-bottom: 0;
    white-space: nowrap;
}

.rating-search-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.star-rating-filter {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 1.4rem;
}

.star-rating-filter .star {
    color: #ddd;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.star-rating-filter .star:hover,
.star-rating-filter .star.active {
    color: var(--warn-color);
    transform: scale(1.1);
}

.star-rating-filter .and-up-text {
    margin-left: var(--space-sm);
    font-size: var(--text-sm);
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.star-rating-filter.has-selection .and-up-text {
    opacity: 1;
}

.rating-notification {
    background-color: rgba(76, 175, 80, 0.9);
    color: white;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    margin-left: var(--space-sm);
    animation: fadeIn 0.3s, fadeOut 0.5s 2s forwards;
}

/* Modals
   ========================================================================== */

.modal {
    display: flex;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
}

.modal-content {
    position: relative;
    background-color: #fff;
    margin: 10% auto;
    padding: var(--space-xl);
    border: 1px solid #ccc;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
    z-index: 2001;
}

.close-tag-modal-btn {
    color: #737373; /* WCAG AA compliant: 4.74:1 with white (was #888) */
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 24px;
    font-weight: bold;
    line-height: 1;
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0;
}

.close-tag-modal-btn:hover,
.close-tag-modal-btn:focus {
    color: #333;
    text-decoration: none;
    cursor: pointer;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #666;
    z-index: 2002;
    padding: 0;
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #333;
}

#recipe-modal-body {
    padding: var(--mobile-padding);
    min-height: 200px;
}

.modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
}

.modal-loading.hidden {
    display: none !important;
}

.modal-loading .spinner {
    margin-bottom: var(--space-md);
}

.modal-footer {
    padding: var(--space-md) var(--mobile-padding);
    border-top: 1px solid #e0e0e0;
    text-align: center;
}

.modal-footer .btn-primary {
    display: inline-block;
    padding: var(--space-sm) var(--mobile-padding);
    background: #007bff;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
}

.modal-footer .btn-primary:hover {
    background: #0056b3;
}

/* Recipe Preview Card (Cocktail Space hover)
   ========================================================================== */

.recipe-preview-card {
    position: absolute;
    background: white;
    border: 2px solid var(--accent-color);
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    pointer-events: none; /* Click-through to data point */
    max-width: 300px;
    font-size: 14px;
}

.recipe-preview-card .recipe-name {
    font-weight: bold;
    margin-bottom: 8px;
    color: var(--text-color, #2c3e50);
    font-size: 15px;
}

.recipe-preview-card .ingredients {
    color: var(--text-color-secondary, #666);
    line-height: 1.5;
    font-size: 13px;
}

.modal-footer .btn-primary:focus {
    outline: var(--focus-outline-width) solid var(--focus-outline-color);
    outline-offset: var(--focus-outline-offset);
}

/* Carousel
   ========================================================================== */

.recipe-carousel {
    margin: var(--space-md) auto;
    padding: var(--space-lg);
    background-color: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.carousel-container {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    justify-content: space-between;
    position: relative;
}

.carousel-content {
    flex: 1;
    min-height: 400px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#recipe-display .recipe-card {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    transition: transform 0.3s, opacity 0.3s;
}

#recipe-display .recipe-card.fade-out {
    animation: fadeOut 0.5s ease-out;
}

/* Notification system
   ========================================================================== */

.notification {
    padding: var(--space-md) var(--space-md);
    margin-bottom: var(--mobile-padding);
    border-radius: var(--radius-sm);
    color: white;
    font-weight: 500;
    position: relative;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    animation: slideIn 0.3s ease-out;
}

.notification.success {
    background-color: var(--success-color);
}

.notification.error {
    background-color: var(--danger-color);
}

.notification.info {
    background-color: var(--info-color);
}

.notification.fade-out {
    animation: fadeOut 0.5s ease-out forwards;
    visibility: hidden;
}

/* Toast notifications */
.toast {
    position: fixed;
    top: var(--mobile-padding);
    right: var(--mobile-padding);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    color: white;
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

.toast-success {
    background-color: var(--success-color);
}

.toast-error {
    background-color: var(--danger-color);
}

/* Page-specific components
   ========================================================================== */

/* About page */
.about-content ul {
    padding-left: 1.5rem;
    margin: var(--space-sm) 0;
    line-height: var(--line-height-normal);
}

.about-content li {
    margin-bottom: var(--space-xs);
    line-height: var(--line-height-normal);
}

/* User ingredients page */
.page-header {
    text-align: center;
    margin-bottom: var(--space-xl);
    padding: var(--space-lg);
    background-color: var(--bg-light);
    border-radius: var(--radius-md);
}

.page-header h2 {
    color: var(--text-dark);
    margin-bottom: var(--space-sm);
    line-height: var(--line-height-tight);
}

.page-header p {
    color: var(--text-medium);
    line-height: var(--line-height-normal);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    padding: var(--space-md);
    background-color: var(--bg-white);
    border-radius: var(--radius-md);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.section-header h3 {
    color: var(--text-dark);
    margin: 0;
    line-height: var(--line-height-normal);
}

.section-header .controls {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.section-header input[type="text"] {
    padding: var(--space-sm);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    min-width: 200px;
}

.ingredients-list {
    background-color: var(--bg-white);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    min-height: 300px;
    max-height: 500px;
    overflow-y: auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-top: var(--space-lg);
}

.ingredients-list.hierarchy {
    background-color: var(--bg-light);
}

.hierarchy-root {
    list-style: none;
    margin: 0;
    padding: 0;
    line-height: 1;
}

.hierarchy-children {
    list-style: none;
    margin: 0;
    padding: 0;
    line-height: 1;
}

.hierarchy-item {
    margin-bottom: var(--space-xs);
}

.hierarchy-item.has-children {
    margin-bottom: var(--space-sm);
}

.ingredient-row {
    display: flex;
    align-items: center;
    padding: var(--space-xs) var(--space-sm);
    line-height: 1;
    border-radius: var(--radius-sm);
    background-color: var(--bg-white);
    margin-bottom: var(--space-xs);
    border: 1px solid var(--border-lighter);
}

.ingredient-checkbox {
    margin-right: var(--space-sm);
    cursor: pointer;
}

.ingredient-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    flex: 1;
    font-weight: normal;
    line-height: var(--line-height-normal);
}

.empty-state {
    text-align: center;
    color: var(--text-medium);
    padding: var(--space-xl);
    font-style: italic;
    line-height: var(--line-height-normal);
}

.auth-required-message {
    text-align: center;
    padding: var(--space-xl);
    background-color: var(--bg-light);
    border-radius: var(--radius-md);
    color: var(--text-medium);
    line-height: var(--line-height-normal);
}

.auth-required-message .btn-link {
    background: none;
    border: none;
    color: var(--accent-color);
    cursor: pointer;
    text-decoration: underline;
    font-size: inherit;
}

.auth-required-message .btn-link:hover {
    color: var(--accent-hover);
}

.auth-required-message .btn-link:focus {
    outline: var(--focus-outline-width) solid var(--focus-outline-color);
    outline-offset: var(--focus-outline-offset);
}

/* Ingredient tree view */
.ingredient-tree-row {
    display: flex;
    align-items: center;
    padding: var(--space-xs) var(--space-sm);
    margin-bottom: var(--space-xs);
    border-radius: 4px;
    background-color: var(--bg-white);
    border: 1px solid var(--border-lighter);
    font-size: 13px;
    line-height: 1.3;
}

.ingredient-tree-row:hover {
    background-color: var(--bg-light);
}

.tree-spacer {
    color: var(--text-light);
    font-size: 10px;
    margin-right: var(--space-sm);
    min-width: 16px;
    text-align: center;
}

.tree-content {
    display: flex;
    align-items: center;
    flex: 1;
    justify-content: space-between;
}

.tree-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tree-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dark);
    line-height: 1.2;
}

.tree-description {
    font-size: 11px;
    color: var(--text-medium);
    font-style: italic;
    margin-top: var(--space-xs);
    line-height: 1.2;
}

.tree-actions {
    display: flex;
    gap: var(--space-xs);
    margin-left: var(--space-sm);
    flex-shrink: 0;
}

.tree-actions .btn-small {
    font-size: 11px;
    padding: var(--space-xs) var(--space-xs);
    min-height: auto;
    line-height: 1.2;
}

.tree-children {
    margin-left: var(--space-sm);
}

.hierarchy-item.expanded > .ingredient-tree-row .tree-toggle {
    color: var(--primary-color);
}

#ingredients-container {
    font-size: 13px;
}

#ingredients-container .hierarchy-root {
    margin: 0;
    padding: 0;
}

/* Analytics page */
.analytics-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-xl);
}

.analytics-header {
    margin-bottom: var(--space-xl);
}

.analytics-header h2 {
    margin-bottom: var(--space-sm);
    line-height: var(--line-height-tight);
}

.analytics-description {
    color: #666;
    margin-bottom: var(--space-sm);
    line-height: var(--line-height-normal);
}

.analytics-meta {
    color: #888;
    font-size: var(--text-sm);
    margin-top: var(--space-sm);
    line-height: var(--line-height-normal);
}

.analytics-tabs {
    display: flex;
    gap: var(--space-sm);
    border-bottom: 2px solid #ddd;
    margin-bottom: var(--space-xl);
}

/* Mobile view selector - hidden on desktop */
.analytics-view-selector {
    display: none;
}

.tab-content {
    display: none;
}

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

.chart-container {
    position: relative;
    min-height: 400px;
}

.chart-area {
    width: 100%;
    min-height: 400px;
}

.loading-state, .error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    text-align: center;
}

.loading-state.hidden, .error-state.hidden {
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #1f77b4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.error-message {
    color: #d32f2f;
    margin-bottom: 1rem;
}

.breadcrumb-nav {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    padding: var(--space-md);
    background: #f5f5f5;
    border-radius: 4px;
    flex-wrap: wrap;
}

.breadcrumb-nav.hidden {
    display: none;
}

.breadcrumb-separator {
    color: #999;
}

.chart-info {
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.legend {
    display: flex;
    gap: var(--space-lg);
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--text-sm);
    line-height: var(--line-height-normal);
}

.legend-color {
    width: 20px;
    height: 12px;
    border-radius: 2px;
}

.chart-stats {
    color: #666;
    font-size: var(--text-sm);
    line-height: var(--line-height-normal);
}

.stats-summary {
    display: flex;
    gap: var(--space-xl);
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.stat-label {
    color: #666;
    font-size: var(--text-xs);  /* Exception: supplementary label */
    line-height: var(--line-height-normal);
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f77b4;
}

.no-data {
    text-align: center;
    color: #888;
    padding: var(--space-xl);
}

.analytics-footer {
    margin-top: 3rem;
    padding-top: var(--space-xl);
    border-top: 1px solid #ddd;
    text-align: center;
}

.info-text {
    color: #666;
    font-size: var(--text-sm);
    line-height: var(--line-height-normal);
}

#cocktail-space-chart {
    min-height: 650px;
}

#cocktail-space-chart svg {
    font-family: Arial, sans-serif;
}

#cocktail-space-chart .grid line {
    stroke: #ccc;
}

#cocktail-space-chart .grid path {
    stroke-width: 0;
}

/* Touch behavior for chart SVGs - allow native scroll, require two fingers for pan/zoom */
#cocktail-space-chart svg,
#cocktail-space-em-chart svg,
#ingredient-tree-chart svg {
    touch-action: pan-y pinch-zoom;
}

/* Mobile touch hint overlay */
.touch-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 100;
    white-space: nowrap;
}

.touch-hint.visible {
    opacity: 1;
}

/* Upload results */
.upload-results {
    padding: var(--space-md);
    background-color: var(--bg-light);
    border-radius: var(--radius-md);
    margin-top: var(--space-md);
}

.upload-results h4 {
    color: var(--text-dark);
    margin-bottom: var(--space-sm);
    line-height: var(--line-height-normal);
}

.upload-results ul {
    padding-left: var(--space-lg);
    margin-bottom: var(--space-sm);
    line-height: var(--line-height-normal);
}

.upload-results li {
    margin-bottom: var(--space-xs);
    line-height: var(--line-height-normal);
}

.success-results {
    background-color: rgba(76, 175, 80, 0.1);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--success-color);
}

.error-results {
    background-color: rgba(244, 67, 54, 0.1);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--danger-color);
}

/* ==========================================================================
   5. LAYOUT UTILITIES
   ========================================================================== */

/* Grid layouts */
.grid {
    display: grid;
}

#recipes-container, #search-results-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-lg);
    margin-top: var(--space-md);
}

/* Results section */
.results-section {
    min-height: 150px;
}

#search-results-container {
    position: relative;
    min-height: 200px;
}

/* ==========================================================================
   6. UTILITIES
   ========================================================================== */

/* Visibility */
.hidden {
    display: none;
}

/* Loading indicators */
.loading-indicator {
    position: absolute;
    right: var(--space-sm);
    top: 50%;
    transform: translateY(-50%);
    display: none;
}

.loading-indicator.active {
    display: block;
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--info-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.search-status {
    font-size: var(--text-xs);
    color: #666;
    margin-top: var(--space-xs);
    display: none;
}

.search-status.active {
    display: block;
}

/* Placeholders and messages */
.empty-message {
    text-align: center;
    padding: var(--space-md);
    background-color: #f9f9f9;
    border-radius: var(--radius-md);
    color: #666;
    position: relative;
    z-index: 5;
    grid-column: 1 / -1;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-placeholder {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 120px;
    width: 100%;
    background-color: #f9f9fa;
    border-radius: var(--radius-md);
    border: 1px dashed #dee2e6;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
    grid-column: 1 / -1;
}

.loading-placeholder p {
    color: #6c757d;
    font-size: var(--text-md);
}

.infinite-scroll-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--space-lg);
    margin: var(--space-md) 0;
    background-color: transparent;
    border-radius: var(--radius-md);
}

.infinite-scroll-loading p {
    color: #6c757d;
    font-size: var(--text-sm);
    font-style: italic;
}

.loading-recipes {
    text-align: center;
    padding: var(--space-lg);
    color: var(--text-light);
    font-style: italic;
    line-height: var(--line-height-normal);
}

/* Progress bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background-color: var(--bg-light);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: var(--space-sm);
}

.progress-fill {
    height: 100%;
    background-color: var(--primary-color);
    border-radius: var(--radius-sm);
    animation: progress-pulse 1.5s infinite;
}

/* ==========================================================================
   7. ANIMATIONS
   ========================================================================== */

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

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes progress-pulse {
    0% { width: 0%; }
    50% { width: 100%; }
    100% { width: 0%; }
}

/* ==========================================================================
   8. RESPONSIVE (Media Queries)
   ========================================================================== */

@media (max-width: 768px) {
    /* Navigation system - Mobile view */
    /* Hide desktop navigation */
    .nav-desktop {
        display: none !important;
    }

    /* Show mobile bottom navigation */
    .nav-mobile-bottom {
        display: block;
    }

    /* Ensure mobile bottom nav stays horizontal */
    .nav-mobile-bottom .nav-items {
        flex-direction: row !important;
    }

    /* Show hamburger button in header */
    .nav-hamburger-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Add padding to main content to account for fixed bottom nav */
    main {
        padding-bottom: calc(var(--mobile-padding) + 60px); /* Extra space for bottom nav */
    }

    /* Main layout - ensure 16-20px viewport padding */
    main {
        padding: 0 var(--mobile-padding);
        padding-bottom: calc(var(--mobile-padding) + 60px);
    }

    header {
        padding: var(--space-sm) var(--mobile-padding);
    }

    .header-container {
        flex-wrap: nowrap;
        gap: var(--space-sm);
        align-items: center;
    }

    .site-title {
        font-size: 1rem;
        flex: 0 0 auto;
        line-height: 1.1;
    }

    .site-title .title-line {
        display: block;
    }

    .auth-controls {
        order: 2;
        flex: 1;
        justify-content: center;
        gap: var(--space-xs);
    }

    .btn-auth,
    .btn-logout {
        padding: var(--space-xs) var(--space-sm);
        font-size: var(--text-xs);
        min-height: 36px;
    }

    #username-display {
        display: none;
    }

    #header-nav-container {
        order: 3;
        flex: 0 0 auto;
    }

    footer {
        padding: var(--space-md) var(--mobile-padding);
    }

    /* Sections - consistent padding on mobile */
    section, .card-container {
        padding: var(--space-md); /* 12px - compact on mobile */
        margin-bottom: var(--space-sm); /* 8px - tighter */
    }

    /* Section title - compact on mobile */
    .section-title {
        margin-bottom: var(--space-sm); /* 8px - tighter */
    }

    .section-title p {
        margin-bottom: 0;
    }

    /* Cards - compact padding on mobile */
    .ingredient-card,
    .recipe-card {
        padding: var(--space-md); /* 12px - compact for mobile */
    }

    /* Modals - use mobile padding */
    .modal-content {
        padding: var(--mobile-padding);
    }

    #recipe-modal-body {
        padding: var(--mobile-padding);
    }

    .modal-footer {
        padding: var(--space-md) var(--mobile-padding);
    }

    /* Grid layouts */
    #recipes-container, #search-results-container {
        grid-template-columns: 1fr;
    }

    /* Search results constraints */
    .results-section {
        padding: 0 var(--mobile-padding);  /* 16px minimum for viewport */
        margin: 0 auto;
        max-width: 100vw;
        box-sizing: border-box;
    }

    #search-results-container {
        width: 100%;
        padding: 0;
    }

    /* Force recipe cards to respect container width */
    #search-results-container .recipe-card {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        overflow-wrap: break-word;
    }

    /* Form layout */
    .form-content-wrapper {
        flex-direction: column;
        gap: var(--space-sm); /* 8px - compact on mobile */
    }

    .form-group {
        margin-bottom: var(--space-xs); /* 4px - very compact on mobile */
    }

    .form-row {
        flex-direction: column; /* Stack vertically on mobile */
        margin-bottom: var(--space-xs); /* 4px - very compact */
        gap: var(--space-xs); /* 4px - minimal gap */
    }

    /* Reduce label spacing on mobile */
    label {
        margin-bottom: var(--space-xs); /* 4px - tighter labels */
    }

    /* Rating search group - compact on mobile */
    .rating-search-group {
        gap: var(--space-xs); /* 4px - tighter */
    }

    /* Compact star rating filter on mobile */
    .star-rating-filter {
        font-size: 1.2rem; /* Smaller stars on mobile */
        gap: 1px;
    }

    /* Compact tag input on mobile */
    .tag-input-wrapper {
        min-height: 44px; /* Match touch target minimum */
        padding: var(--space-xs); /* Smaller padding */
    }

    /* Compact ingredient search on mobile */
    .ingredient-search-container .add-row-wrapper {
        margin-top: var(--space-xs); /* 4px - tighter */
    }

    /* Ingredient fields - stack vertically to prevent overflow */
    .ingredient-fields {
        flex-direction: column;
        gap: var(--space-xs); /* 4px - minimal gap */
    }

    .ingredient-fields .form-group:first-child,
    .ingredient-fields .form-group:nth-child(2) {
        flex: 1; /* Remove fixed widths, make full width */
    }

    .ingredient-fields .remove-ingredient {
        margin-top: 0;
        align-self: stretch; /* Full width button */
    }

    .form-actions {
        width: 100%;
        flex-direction: row;
        justify-content: center;
        align-self: stretch;
        margin-top: var(--space-sm); /* 8px - reduce gap */
    }

    .form-actions button {
        flex: 1;
        max-width: 150px;
    }


    /* Carousel */
    .carousel-container {
        flex-direction: column;
        padding: var(--space-md) 0;
    }

    .carousel-arrow {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }

    #prev-recipe, #next-recipe {
        position: relative;
        transform: rotate(90deg);
        margin: var(--space-sm) 0;
    }

    #prev-recipe {
        order: 1;
    }

    .carousel-content {
        order: 2;
        width: 100%;
    }

    #next-recipe {
        order: 3;
    }

    /* Item rows */
    .item-row {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-md);
    }

    .item-row-field-fixed {
        flex: 1;
        width: 100%;
    }

    .btn-circle {
        align-self: flex-end;
    }

    /* Page-specific adjustments */
    .page-header {
        padding: var(--space-md) var(--mobile-padding);
    }

    .section-header {
        padding: var(--space-md) var(--mobile-padding);
    }

    .ingredients-list {
        padding: var(--mobile-padding);
    }

    .recipe-carousel {
        padding: var(--mobile-padding);
    }

    .upload-results {
        padding: var(--mobile-padding);
    }

    /* Analytics page */
    .analytics-container {
        padding: var(--mobile-padding);  /* 16px minimum for viewport */
    }

    /* Hide desktop tabs on mobile */
    .analytics-tabs {
        display: none;
    }

    /* Show mobile view selector */
    .analytics-view-selector {
        display: flex;
        align-items: center;
        gap: var(--space-sm);
        margin-bottom: var(--space-lg);
        padding: var(--space-sm) var(--space-md);
        background-color: var(--bg-light);
        border-radius: var(--radius-md);
    }

    .view-selector-label {
        font-size: var(--text-sm);
        font-weight: 500;
        color: var(--text-dark);
        white-space: nowrap;
    }

    .mobile-view-select {
        flex: 1;
        padding: var(--space-sm) var(--space-md);
        font-size: var(--text-sm);
        border: 1px solid var(--border-light);
        border-radius: var(--radius-sm);
        background-color: white;
        color: var(--text-dark);
        min-height: var(--touch-target-min);
    }

    .chart-info {
        flex-direction: column;
        gap: var(--space-md);
        align-items: flex-start;
    }

    .stats-summary {
        flex-direction: column;
        gap: var(--space-md);
    }
}

/* Desktop navigation visibility */
@media (min-width: 769px) {
    /* Show desktop navigation */
    .nav-desktop {
        display: flex;
    }

    /* Hide mobile navigation elements */
    .nav-mobile-bottom {
        display: none !important;
    }

    .nav-hamburger-btn {
        display: none !important;
    }

    .nav-mobile-menu-overlay {
        display: none !important;
    }

    .nav-mobile-menu {
        display: none !important;
    }
}
