:root {
    --primary-bg: #ffffff;
    /* Super Light Mode */
    --secondary-bg: rgba(255, 255, 255, 0.85);
    --primary-text: #0f172a;
    --secondary-text: #334155;
    --accent-color: #f97316;
    --error-color: #ef4444;
    --success-color: #22c55e;
    --border-radius: 16px;
    --transition-speed: 0.4s;
    --max-width: 1000px;
    --container-padding: 24px;
    --border-color: rgba(15, 23, 42, 0.08);
    /* Sophisticated subtle border */

    /* Glassmorphism Tokens - Optimized for Super Light Mode */
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(15, 23, 42, 0.06);
    --glass-shadow: 0 8px 32px 0 rgba(15, 23, 42, 0.04);
    --glass-blur: blur(12px);

    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
    --font-title: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background: var(--primary-bg);
    background-attachment: fixed;
    min-height: 100vh;
    padding: var(--container-padding);
    color: var(--secondary-text);
}

.container {
    max-width: var(--max-width);
    margin: 40px auto;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-radius: var(--border-radius);
    padding: 60px 40px;
    box-shadow: var(--glass-shadow);
    border: 1px solid var(--glass-border);
    position: relative;
    z-index: 1;
}

header {
    text-align: center;
    margin-bottom: 40px;
    position: relative;
}

.header-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
    max-width: 100%;
}

.title-background {
    font-family: var(--font-title);
    color: var(--accent-color);
    padding: 20px 40px;
    font-size: 5em;
    font-weight: 800;
    letter-spacing: -0.02em;
    /* Tighter for modern look */
    text-transform: lowercase;
    margin-bottom: 10px;
    position: relative;
    z-index: 10;
    text-shadow: 0 4px 12px rgba(249, 115, 22, 0.2);
}

.logo {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    max-width: 140%;
    /* Make it bigger for better background presence */
    width: 140%;
    height: auto;
    z-index: -1;
    pointer-events: none;
    opacity: 0.3;
    /* Boosted for significant prominence */
    filter: none;
    /* Removed blur to keep logo crisp */
    transition: opacity var(--transition-speed);
}

h1 {
    font-size: 4em;
    color: var(--accent-color);
    margin-bottom: 20px;
    margin-top: 0;
    display: none;
}

.tagline {
    font-size: 1.4em;
    color: var(--secondary-text);
    font-weight: 500;
    opacity: 0.9;
    letter-spacing: -0.01em;
}

.input-section h2 {
    color: var(--secondary-text);
    margin-bottom: 15px;
    font-size: 1.5em;
}

textarea {
    width: 100%;
    padding: 20px;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    font-size: 1.1em;
    font-family: inherit;
    resize: vertical;
    transition: all var(--transition-speed);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
    color: var(--secondary-text);
}

textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.1);
}

button {
    width: 100%;
    padding: 16px 32px;
    background: linear-gradient(135deg, var(--accent-color), #ea580c);
    color: var(--primary-text);
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.1em;
    font-family: var(--font-title);
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-speed) cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin-top: 15px;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.2);
}

button:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 10px 20px rgba(249, 115, 22, 0.3);
}

button:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--border-color);
    border-top: 5px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.slide-up-item {
    opacity: 0;
    animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.recipe-output {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 30px;
    border-radius: var(--border-radius);
    margin-top: 30px;
    border: 1px solid var(--glass-border);
    animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    box-shadow: var(--glass-shadow);
}

.recipe-output h2 {
    font-family: var(--font-title);
    color: var(--accent-color);
    margin-bottom: 20px;
    font-size: 2.2em;
    font-weight: 800;
}

#recipeContent {
    line-height: 1.8;
    color: var(--secondary-text);
}

#recipeContent p {
    margin-bottom: 15px;
}

#recipeContent strong {
    color: var(--accent-color);
    font-size: 1.1em;
}

.error {
    background: #ffebee;
    color: var(--error-color);
    padding: 15px;
    border-radius: var(--border-radius);
    margin-top: 20px;
    border-left: 4px solid var(--error-color);
}

.hidden {
    display: none;
}

footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 2px solid var(--border-color);
    color: var(--secondary-text);
    opacity: 0.7;
}

footer a {
    color: #000000;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Dark/Light Mode Toggle */
.theme-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.3em;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: transform var(--transition-speed);
    z-index: 1000;
    margin: 0;
    padding: 0;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

/* Dietary Preferences Dropdown */
.dietary-dropdown {
    margin: 15px 0;
}

.dietary-toggle {
    width: 100%;
    padding: 12px 15px;
    background: #f8f9fa;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.95em;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all var(--transition-speed);
    margin: 0;
    text-align: left;
    color: var(--secondary-text);
}

.dietary-toggle:hover {
    background: #e9ecef;
    border-color: var(--accent-color);
}

.dietary-toggle .dropdown-arrow {
    font-size: 0.8em;
    transition: transform var(--transition-speed);
    color: var(--accent-color);
}

.dietary-toggle.open .dropdown-arrow {
    transform: rotate(180deg);
}

.dietary-options {
    margin-top: 10px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: var(--border-radius);
    border: 2px solid var(--border-color);
    animation: slideDown 0.3s ease;
}

.dietary-options.hidden {
    display: none;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dietary-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    font-size: 0.9em;
}

.dietary-checkboxes label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    transition: background-color 0.2s;
    color: var(--secondary-text);
}

.dietary-checkboxes label:hover {
    background-color: rgba(255, 107, 26, 0.1);
}

.dietary-checkboxes input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

#dietaryCount {
    font-weight: normal;
    color: var(--secondary-text);
    opacity: 0.7;
    font-size: 0.9em;
}

/* Recipe Header Actions */
.recipe-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.recipe-header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.recipe-header-actions button {
    width: auto;
    padding: 8px 15px;
    font-size: 0.9em;
    margin: 0;
}

.print-btn,
.share-btn {
    background: #4caf50;
}

.print-btn:hover,
.share-btn:hover {
    background: #45a049;
}

/* Recipe Scaling */
.recipe-scaling {
    margin: 15px 0;
    padding: 10px;
    background: #f0f0f0;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.recipe-scaling label {
    font-weight: bold;
    color: var(--secondary-text);
}

.scale-btn {
    width: 35px;
    height: 35px;
    padding: 0;
    margin: 0;
    font-size: 1.2em;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#servingMultiplier {
    font-weight: bold;
    min-width: 40px;
    text-align: center;
}

.serving-info {
    color: var(--secondary-text);
    font-size: 0.9em;
}

/* Recipe Rating */
.recipe-rating {
    margin: 15px 0;
    padding: 10px;
    background: #fff3cd;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.recipe-rating label {
    font-weight: bold;
    color: var(--secondary-text);
}

.stars {
    display: flex;
    gap: 5px;
}

.star {
    font-size: 1.5em;
    cursor: pointer;
    color: #ffd700;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.star:hover {
    transform: scale(1.3) rotate(15deg);
}

.star.filled {
    color: #ffd700;
}


/* Structured Recipe Display */
.recipe-content-structured {
    line-height: 1.8;
    color: var(--secondary-text);
}

.recipe-content-structured .recipe-section {
    margin: 20px 0;
}

.recipe-content-structured .recipe-section h3 {
    color: var(--accent-color);
    font-size: 1.3em;
    margin-bottom: 10px;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 5px;
}

.recipe-content-structured .recipe-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin: 15px 0;
    padding: 15px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.recipe-content-structured .recipe-meta-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Center for more balanced look */
    text-align: center;
}

.recipe-content-structured .recipe-meta-label {
    font-weight: 600;
    color: var(--accent-color);
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.recipe-content-structured .recipe-meta-value {
    font-size: 1.1em;
    color: #2d3436;
    font-weight: 500;
}

.recipe-content-structured ul,
.recipe-content-structured ol {
    margin: 10px 0;
    padding-left: 25px;
}

.recipe-content-structured li {
    margin: 8px 0;
}

.recipe-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.recipe-actions button {
    flex: 1;
    min-width: 150px;
}

/* Print Styles */
@media print {
    body {
        background: white;
        color: black;
    }

    .container {
        box-shadow: none;
        padding: 0;
    }

    .history-toggle,
    .theme-toggle,
    .recipe-header-actions,
    .recipe-scaling,
    .recipe-rating,
    .recipe-actions,
    footer,
    header {
        display: none !important;
    }

    .recipe-output {
        border: none;
        padding: 0;
        page-break-inside: avoid;
    }

    .recipe-content-structured {
        font-size: 12pt;
        line-height: 1.6;
    }

    .recipe-content-structured .recipe-section {
        page-break-inside: avoid;
    }
}

/* Dark Mode Styles */
body.dark-mode {
    --primary-bg: #020617;
    --secondary-bg: rgba(15, 23, 42, 0.3);
    --primary-text: #f8fafc;
    --secondary-text: #f1f5f9;
    --border-color: rgba(255, 255, 255, 0.1);
    --glass-bg: rgba(15, 23, 42, 0.3);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
}

body.dark-mode {
    background: radial-gradient(circle at top right, #0f172a, #020617);
}

body.dark-mode .recipe-output {
    background: rgba(30, 41, 59, 0.5);
    border-color: var(--glass-border);
}

body.dark-mode textarea {
    background: rgba(15, 23, 42, 0.4);
    color: #f8fafc;
}

body.dark-mode .dietary-toggle,
body.dark-mode .dietary-options,
body.dark-mode .recipe-scaling,
body.dark-mode .recipe-content-structured .recipe-meta {
    background: rgba(30, 41, 59, 0.4);
    border-color: var(--glass-border);
}

body.dark-mode .recipe-rating {
    background: rgba(69, 39, 0, 0.3);
    /* Subtle dark orange for ratings */
}

body.dark-mode .history-panel {
    background: rgba(15, 23, 42, 0.95);
    border-left: 1px solid var(--glass-border);
}

body.dark-mode .history-header {
    border-bottom-color: #333;
}

body.dark-mode .history-search {
    background: #2a2a2a;
    color: #e0e0e0;
    border-color: #444;
}

body.dark-mode .close-history {
    color: #e0e0e0;
}

body.dark-mode .logo {
    opacity: 0.08;
}

/* History Panel Styles */
.history-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 1.5em;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: transform var(--transition-speed);
    z-index: 1000;
    margin: 0;
    padding: 0;
}

.history-toggle:hover {
    transform: scale(1.1);
}

.history-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 420px;
    height: 100vh;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.2);
    transition: right 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1001;
    overflow-y: auto;
    padding: 30px;
    border-left: 1px solid var(--glass-border);
}

.history-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.history-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.history-panel.open {
    right: 0;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

.history-header h3 {
    color: var(--accent-color);
    margin: 0;
}

.close-history {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: var(--secondary-text);
    width: auto;
    padding: 5px 10px;
    margin: 0;
}

.close-history:hover {
    transform: none;
    box-shadow: none;
}

.history-controls {
    margin-bottom: 20px;
}

.history-search {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 10px;
}

.history-buttons {
    display: flex;
    gap: 10px;
}

.history-buttons button {
    flex: 1;
    padding: 8px 12px;
    font-size: 0.9em;
    margin: 0;
}

.recipe-item {
    background: rgba(255, 255, 255, 0.3);
    padding: 20px;
    margin-bottom: 15px;
    border-radius: var(--border-radius);
    cursor: pointer;
    border: 1px solid var(--glass-border);
    transition: all var(--transition-speed);
    animation: scaleIn 0.4s ease-out forwards;
}

.recipe-item:hover {
    background: rgba(255, 255, 255, 0.5);
    border-color: var(--accent-color);
    transform: translateX(-5px) scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.recipe-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.recipe-name {
    font-weight: bold;
    color: var(--secondary-text);
    font-size: 1em;
    margin: 0;
}

.favorite-btn {
    background: none;
    border: none;
    font-size: 1.3em;
    cursor: pointer;
    padding: 0;
    width: auto;
    margin: 0;
    transition: transform var(--transition-speed);
}

.favorite-btn:hover {
    transform: scale(1.2);
    box-shadow: none;
}

.recipe-timestamp {
    font-size: 0.8em;
    color: #777;
}

.recipe-ingredients-preview {
    font-size: 0.85em;
    color: #666;
    margin-top: 5px;
    font-style: italic;
}

.empty-history {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.recipe-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.recipe-header h2 {
    margin: 0;
}

.favorite-toggle-btn {
    margin: 0;
    padding: 10px 20px;
    font-size: 1em;
    background: white;
    color: var(--secondary-text);
    border: 2px solid var(--border-color);
    width: auto;
}

.favorite-toggle-btn.favorited {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

@media (max-width: 768px) {
    .history-panel {
        width: 90%;
        max-width: 400px;
        right: -100%;
    }

    .history-toggle {
        width: 50px;
        height: 50px;
        font-size: 1.2em;
    }

    .recipe-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .favorite-toggle-btn {
        width: 100%;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 20px;
    }

    .header-wrapper {
        max-width: 100%;
    }

    .title-background {
        font-size: 2.2em;
        padding: 20px 10px;
        line-height: 1.2;
        letter-spacing: 0;
    }

    .logo {
        max-width: 100%;
        opacity: 0.1;
    }

    .theme-toggle {
        top: 10px;
        left: 10px;
        width: 40px;
        height: 40px;
        font-size: 1.1em;
    }

    .history-toggle {
        top: 10px;
        right: 10px;
        width: 45px;
        height: 45px;
        font-size: 1.3em;
    }

    h1 {
        font-size: 2.8em;
    }

    .tagline {
        font-size: 1em;
        padding: 0 10px;
    }
}

/* Toast Styles */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.9em;
    font-weight: 500;
    z-index: 9999;
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55), opacity 0.3s;
    opacity: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

body.dark-mode .toast {
    background: var(--accent-color);
}