/* ============================================
   Random Recipe Mixer - Styles
   ============================================ */

/* CSS Variables */
:root {
    --primary-color: #ff6b35;
    --primary-dark: #e55a2b;
    --primary-light: #ff8c5a;
    --secondary-color: #2ec4b6;
    --secondary-dark: #25a99d;
    --accent-color: #ffbe0b;
    --background-color: #f8f9fa;
    --surface-color: #ffffff;
    --text-primary: #2d3436;
    --text-secondary: #636e72;
    --text-light: #b2bec3;
    --border-color: #dfe6e9;
    --success-color: #00b894;
    --error-color: #d63031;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.3s ease;
}

/* Reset & Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 30px 0;
    text-align: center;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 10px;
}

.logo-icon {
    font-size: 2.5rem;
}

.logo h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.tagline {
    opacity: 0.9;
    font-size: 1.1rem;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 30px 0;
}

/* Navigation Tabs */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 30px;
    background: var(--surface-color);
    padding: 8px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.tab-btn:hover {
    background: var(--background-color);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
}

.tab-icon {
    font-size: 1.2rem;
}

/* Tab Panels */
.tab-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

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

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

.panel-header {
    margin-bottom: 25px;
}

.panel-header h2 {
    font-size: 1.75rem;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.panel-header p {
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--background-color);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.btn-large {
    padding: 16px 32px;
    font-size: 1.1rem;
}

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

.btn-danger:hover {
    background: #c0392b;
}

/* Search Box */
.search-box {
    position: relative;
    flex: 1;
}

.search-box input {
    width: 100%;
    padding: 14px 20px 14px 50px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.search-box .search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
}

.search-box.large input {
    padding: 18px 24px 18px 55px;
    font-size: 1.1rem;
}

/* Form Controls */
select, input[type="text"], input[type="number"] {
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    background: var(--surface-color);
    transition: var(--transition);
}

select:focus, input[type="text"]:focus, input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Library Controls */
.library-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.filter-dropdown select {
    min-width: 180px;
}

/* Add Ingredient Form */
.add-ingredient-form {
    background: var(--surface-color);
    padding: 25px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 30px;
}

.add-ingredient-form h3 {
    margin-bottom: 20px;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.form-row input, .form-row select {
    flex: 1;
    min-width: 150px;
}

.nutrition-inputs input {
    min-width: 100px;
    flex: 1;
}

/* Ingredient Grid */
.ingredient-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.ingredient-card {
    background: var(--surface-color);
    padding: 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
}

.ingredient-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.ingredient-card .category-badge {
    display: inline-block;
    padding: 4px 10px;
    background: var(--background-color);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 20px;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.ingredient-card h4 {
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.ingredient-card .nutrition-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.ingredient-card .nutrition-info span {
    display: inline-block;
    margin-right: 10px;
}

.ingredient-card .delete-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0;
    transition: var(--transition);
}

.ingredient-card:hover .delete-btn {
    opacity: 1;
}

.ingredient-card.custom {
    border: 2px dashed var(--primary-light);
}

/* Recipe Search */
.search-controls {
    margin-bottom: 30px;
}

.filter-tags {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.filter-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.filter-tag {
    padding: 8px 16px;
    border: 2px solid var(--border-color);
    border-radius: 20px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.filter-tag:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.filter-tag.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Recipe Grid */
.recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.recipe-card {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
}

.recipe-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.recipe-card .recipe-image {
    height: 180px;
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
}

.recipe-card .recipe-info {
    padding: 20px;
}

.recipe-card h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.recipe-card .recipe-meta {
    display: flex;
    gap: 15px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.recipe-card .recipe-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.recipe-card .tag {
    padding: 4px 10px;
    background: var(--background-color);
    color: var(--text-secondary);
    font-size: 0.75rem;
    border-radius: 15px;
}

/* Mixer Controls */
.mixer-controls {
    background: var(--surface-color);
    padding: 30px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    text-align: center;
    margin-bottom: 30px;
}

.mixer-options {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    justify-content: center;
    margin-bottom: 30px;
}

.option-group {
    text-align: left;
}

.option-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--text-primary);
}

.option-group input[type="range"] {
    width: 200px;
    margin-right: 10px;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: normal;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
}

/* Mixer Result */
.mixer-result {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.mixer-result.hidden {
    display: none;
}

.result-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
}

.result-header h3 {
    font-size: 1.5rem;
}

.result-header .btn-small {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
}

.result-header .btn-small:hover {
    background: rgba(255, 255, 255, 0.3);
}

.result-content {
    padding: 30px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.ingredients-section h4, .nutrition-section h4 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.ingredients-section ul {
    list-style: none;
}

.ingredients-section li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.ingredients-section li:last-child {
    border-bottom: none;
}

.ingredients-section .ingredient-emoji {
    font-size: 1.3rem;
}

/* Nutrition Grid */
.nutrition-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.nutrition-item {
    background: var(--background-color);
    padding: 20px;
    border-radius: var(--radius-md);
    text-align: center;
}

.nutrition-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.nutrition-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.result-actions {
    padding: 25px;
    background: var(--background-color);
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Saved Recipes */
.saved-recipes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.saved-recipe-card {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: var(--transition);
}

.saved-recipe-card:hover {
    box-shadow: var(--shadow-md);
}

.saved-recipe-header {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    color: white;
    padding: 20px;
}

.saved-recipe-header h3 {
    font-size: 1.2rem;
    margin-bottom: 5px;
}

.saved-recipe-header .date {
    font-size: 0.85rem;
    opacity: 0.9;
}

.saved-recipe-body {
    padding: 20px;
}

.saved-recipe-body .ingredients-preview {
    margin-bottom: 15px;
}

.saved-recipe-body .ingredients-preview h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.saved-recipe-body .ingredients-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.saved-recipe-body .ingredient-chip {
    padding: 4px 10px;
    background: var(--background-color);
    border-radius: 15px;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.saved-recipe-body .nutrition-summary {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.saved-recipe-body .nutrition-summary span {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.saved-recipe-body .nutrition-summary strong {
    color: var(--text-primary);
}

.saved-recipe-actions {
    padding: 15px 20px;
    background: var(--background-color);
    display: flex;
    gap: 10px;
}

.saved-recipe-actions .btn {
    flex: 1;
    padding: 10px;
    font-size: 0.9rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 15px;
}

.empty-state p {
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.empty-hint {
    font-size: 0.95rem;
    color: var(--text-light);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 35px;
    height: 35px;
    border: none;
    background: var(--background-color);
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 10;
}

.modal-close:hover {
    background: var(--error-color);
    color: white;
}

#modal-body {
    padding: 30px;
}

#modal-body h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    padding-right: 40px;
}

#modal-body .modal-section {
    margin-bottom: 25px;
}

#modal-body .modal-section h4 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    font-weight: 600;
}

#modal-body .ingredient-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

#modal-body .ingredient-list span {
    padding: 6px 12px;
    background: var(--background-color);
    border-radius: 20px;
    font-size: 0.9rem;
}

#modal-body .nutrition-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    background: var(--background-color);
    padding: 20px;
    border-radius: var(--radius-md);
}

#modal-body .nutrition-bar div {
    text-align: center;
}

#modal-body .nutrition-bar strong {
    display: block;
    font-size: 1.2rem;
    color: var(--primary-color);
}

#modal-body .nutrition-bar span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: white;
    padding: 15px 30px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1001;
    animation: toastIn 0.3s ease;
}

.toast.hidden {
    display: none;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Footer */
.footer {
    background: var(--text-primary);
    color: var(--text-light);
    padding: 25px 0;
    text-align: center;
    margin-top: auto;
}

.footer a {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.footer a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        padding: 20px 0;
    }

    .logo h1 {
        font-size: 1.5rem;
    }

    .tagline {
        font-size: 0.95rem;
    }

    .tabs {
        gap: 5px;
        padding: 5px;
    }

    .tab-btn {
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    .tab-text {
        display: none;
    }

    .tab-icon {
        font-size: 1.4rem;
    }

    .library-controls {
        flex-direction: column;
    }

    .form-row {
        flex-direction: column;
    }

    .form-row input, .form-row select {
        min-width: 100%;
    }

    .ingredient-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    .recipe-grid {
        grid-template-columns: 1fr;
    }

    .mixer-options {
        flex-direction: column;
        align-items: center;
    }

    .result-content {
        grid-template-columns: 1fr;
    }

    .nutrition-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .nutrition-item {
        padding: 15px 10px;
    }

    .nutrition-value {
        font-size: 1.2rem;
    }

    .saved-recipes-grid {
        grid-template-columns: 1fr;
    }

    #modal-body .nutrition-bar {
        grid-template-columns: repeat(2, 1fr);
    }

    .checkbox-group {
        flex-direction: column;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }

    .main-content {
        padding: 20px 0;
    }

    .panel-header h2 {
        font-size: 1.4rem;
    }

    .btn-large {
        width: 100%;
        padding: 14px 24px;
    }

    .ingredient-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .ingredient-card {
        padding: 15px;
    }

    .result-header {
        flex-direction: column;
        text-align: center;
    }

    .result-actions {
        flex-direction: column;
    }

    .result-actions .btn {
        width: 100%;
    }

    .nutrition-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Print Styles */
@media print {
    .header, .tabs, .mixer-controls, .result-actions, .footer {
        display: none;
    }

    .mixer-result {
        box-shadow: none;
        border: 1px solid var(--border-color);
    }
}
