/* Mealz Recipe Manager Styles */

:root {
    --primary-color: rgb(51 181 229 / 100%);
    --secondary-color: rgb(51 181 229 / 80%);
    --accent-color: rgb(51 181 229 / 60%);
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --dark-color: #343a40;
    --light-color: rgb(51 181 229 / 5%);
    --background-color: #f8fafb;
    --border-color: #e9e9e9;
    --text-color: #333;
    --text-muted: #666;
    --white: #fff;
    --shadow: 0 2px 8px rgb(51 181 229 / 10%);
    --border-radius: 8px;
    --transition: all 0.2s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
}

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

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 1.5rem 2rem;
    box-shadow: var(--shadow);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

#main-nav {
    display: flex;
    gap: 2rem;
}

.nav-link {
    color: white;
    text-decoration: none;
    font-weight: 500;
    font-size: 1.1rem;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
    border: 2px solid transparent;
}

.nav-link:hover {
    background: rgb(255 255 255 / 10%);
    text-decoration: none;
}

.nav-link.active {
    background: rgb(255 255 255 / 20%);
    border-color: rgb(255 255 255 / 30%);
}

header h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

#auth-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-email {
    font-size: 0.85rem;
    color: rgb(255 255 255 / 90%);
    font-weight: 500;
}

#user-name {
    font-weight: 500;
}

/* Buttons */
button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

button:hover {
    box-shadow: var(--shadow);
}

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

.primary:hover {
    background-color: #e55a2b;
}

#sign-in-btn {
    background-color: rgb(255 255 255 / 20%);
    color: white;
    border: 1px solid rgb(255 255 255 / 30%);
}

#sign-in-btn:hover {
    background-color: rgb(255 255 255 / 30%);
}

#sign-out-btn {
    background: transparent;
    color: white;
    border: 2px solid transparent;
    font-weight: 500;
    font-size: 1.1rem;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
}

#sign-out-btn:hover {
    background: rgb(255 255 255 / 10%);
    box-shadow: none;
}

/* Main content */
main {
    flex: 1;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.section {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.section h2 {
    margin-bottom: 1rem;
    color: var(--dark-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
}

/* Sheet controls */
.sheet-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.url-input-group {
    display: flex;
    gap: 0.75rem;
    align-items: stretch;
    flex-wrap: wrap;
}

.url-input {
    flex: 1;
    min-width: 300px;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.95rem;
    font-family: inherit;
}

.url-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgb(51 181 229 / 20%);
}

.url-input::placeholder {
    color: #999;
    font-style: italic;
}

.sheet-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.help-text {
    color: #666;
    font-size: 0.9rem;
    margin: 0;
}

.current-sheet-info {
    padding: 0.75rem;
    background: var(--light-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
}

.current-sheet-info.hidden {
    display: none;
}

/* Removed - replaced with URL input styles above */

/* Recipe controls */
.recipe-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.search-filter {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

#search-input, #nutrient-filter {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
}

#search-input {
    min-width: 200px;
}

/* Table */
#recipe-table-container {
    overflow-x: auto;
}

#recipes-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

#recipes-table th,
#recipes-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

#recipes-table th {
    background-color: var(--light-color);
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 10;
}

#recipes-table th:hover {
    background-color: #e9ecef;
}

#recipes-table tr:hover {
    background-color: #f8f9fa;
}

.recipe-image {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: var(--border-radius);
}

.nutrient-tag {
    display: inline-block;
    background-color: var(--primary-color);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    margin: 0.1rem;
}

.recipe-url {
    color: var(--primary-color);
    text-decoration: none;
}

.recipe-url:hover {
    text-decoration: underline;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgb(0 0 0 / 50%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

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

.modal-content {
    background: white;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgb(0 0 0 / 20%);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    margin: 0;
    border: none;
    padding: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: var(--danger-color);
    box-shadow: none;
}

/* Form */
#recipe-form {
    padding: 1.5rem;
}

/* Import from URL section */
.import-section {
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: #f8f9fa;
}

.import-section.hidden { display: none; }

.import-section label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--dark-color);
}

.import-row {
    display: flex;
    gap: 0.5rem;
}

.import-row input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.85rem;
}

.import-row button {
    white-space: nowrap;
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
}

.import-status {
    margin: 0.3rem 0 0;
    font-size: 0.8rem;
    color: #666;
    min-height: 1.2em;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--dark-color);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgb(255 107 53 / 20%);
}

/* Nutrient suggestions */
.nutrient-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.suggestion {
    background-color: var(--light-color);
    color: var(--dark-color);
    padding: 0.3rem 0.6rem;
    border-radius: 15px;
    font-size: 0.8rem;
    cursor: pointer;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

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

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Loading */
#loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgb(255 255 255 / 90%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

#loading.hidden {
    display: none !important;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--light-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Messages */
#message-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
}

.message {
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
    box-shadow: var(--shadow);
    animation: slide-in 0.3s ease;
    max-width: 300px;
}

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

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

.message.warning {
    background-color: var(--warning-color);
    color: var(--dark-color);
}

@keyframes slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

/* Content Sections */
.content-section {
    display: none;
}

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

/* Weekly Meal Plan */
.meal-plan-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.week-controls {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.week-navigation {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.week-navigation button {
    background-color: var(--light-color);
    color: var(--dark-color);
    border: 1px solid var(--border-color);
}

.week-navigation button:hover {
    background-color: var(--border-color);
}

#current-week-label {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--dark-color);
}

.weekly-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.day-row {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 2px 8px rgb(51 181 229 / 10%);
    transition: all 0.2s ease;
    display: flex;
    min-height: 250px;
    border: 1px solid #e9e9e9;
}

.day-row.current-day {
    box-shadow: 0 4px 12px rgb(51 181 229 / 20%);
    border: 2px solid rgb(51 181 229 / 30%);
}

.day-header-left {
    background: rgb(51 181 229 / 10%);
    color: #333;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    width: 80px;
    min-width: 80px;
    max-width: 80px;
    border-right: 1px solid #e9e9e9;
}

.day-header-left .day-name {
    font-weight: 600;
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: #333;
}

.day-header-left .day-date {
    font-weight: 400;
    font-size: 0.9rem;
    color: #666;
}

.nutrient-hints {
    margin-top: 0.4rem;
    font-size: 0.85rem;
    opacity: 0.7;
    letter-spacing: 1px;
}

.meals-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    flex: 1;
}

.meal-slot {
    position: relative;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.meal-slot:last-child {
    border-right: none;
}

.meal-slot.lunch {
    background-color: white;
}

.meal-slot.dinner {
    background-color: #e9e9e9;
}

.meal-card {
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.meal-card:hover {
    box-shadow: 0 4px 12px rgb(51 181 229 / 15%);
}

.meal-card.empty {
    border: 2px dashed var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-style: italic;
}

.meal-card.empty:hover {
    border-color: rgb(51 181 229 / 50%);
    background-color: rgb(51 181 229 / 5%);
}

.meal-image {
    width: 100%;
    flex: 1;
    background-size: cover;
    background-position: center;
    min-height: 0;
}

.meal-nutrients-top {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.3rem;
    z-index: 2;
}

.meal-title-bottom {
    padding: 0.5rem;
    color: #333;
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.meal-title-text {
    flex: 1;
    min-width: 0;
}

.meal-title-nutrients {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.fallback-warning {
    flex-shrink: 0;
    font-size: 0.85rem;
    cursor: help;
}

.nutrient-emoji {
    font-size: 1.1rem;
    padding: 2px 4px;
    border-radius: 4px;
    margin-right: 4px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgb(0 0 0 / 10%);
    box-shadow: 0 1px 3px rgb(0 0 0 / 20%);
}

.empty-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    height: 100%;
    color: var(--text-muted);
}

.assign-meal-btn {
    padding: 0.5rem 1rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

/* Responsive design - consolidated */
@media (width <= 768px) {
    /* Header and navigation */
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    #main-nav {
        width: 100%;
        border-radius: var(--border-radius);
    }
    
    .nav-link {
        padding: 0.75rem 1rem;
        font-size: 1rem;
        min-width: 60px;
    }

    header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }

    main {
        padding: 1rem;
    }

    /* Recipe controls */
    .recipe-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .search-filter {
        flex-direction: column;
    }

    /* Meal plan responsive */
    .meal-plan-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .week-controls {
        flex-direction: column;
        gap: 1rem;
    }
    
    .week-navigation {
        justify-content: center;
    }
    
    .day-row {
        flex-direction: column;
        min-height: auto;
    }
    
    .day-header-left {
        flex-direction: row;
        justify-content: space-between;
        padding: 1rem;
        min-width: auto;
    }
    
    .meals-container {
        grid-template-columns: 1fr;
    }
    
    .meal-slot {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        min-height: 200px;
    }
    
    .meal-slot:last-child {
        border-bottom: none;
    }
    
    .meal-image {
        height: calc(100% - 60px);
    }

    /* Additional responsive rules */
    #search-input {
        min-width: auto;
    }

    .sheet-controls {
        flex-direction: column;
        align-items: stretch;
    }


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

    #recipes-table {
        font-size: 0.8rem;
    }

    #recipes-table th,
    #recipes-table td {
        padding: 0.5rem;
    }
}

@media (width <= 480px) {
    .meal-title-bottom {
        font-size: 0.9rem;
        padding: 0.8rem;
    }

    #search-input {
        min-width: auto;
    }

    .sheet-controls {
        flex-direction: column;
        align-items: stretch;
    }


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

    #recipes-table {
        font-size: 0.8rem;
    }

    #recipes-table th,
    #recipes-table td {
        padding: 0.5rem;
    }
}

@media (width <= 480px) {
    .modal-content {
        width: 95%;
        margin: 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }
}

/* Button utilities */
.btn-edit {
    margin-right: 0.5rem;
}

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

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

.public-mode-indicator {
    background: #e8f4fd;
    color: #06c;
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 0.9em;
    margin-bottom: 10px;
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

.text-center {
    text-align: center;
}

/* Nutrient emoji color classes */

.nutrient-emoji.pork {
    background-color: rgb(255 192 203 / 70%); /* Pink */
}

.nutrient-emoji.beef {
    background-color: rgb(165 42 42 / 70%); /* Brown */
}

.nutrient-emoji.poultry {
    background-color: rgb(255 215 0 / 70%); /* Gold */
}

.nutrient-emoji.dairy {
    background-color: rgb(255 248 220 / 70%); /* Cornsilk */
}

.nutrient-emoji.grains {
    background-color: rgb(210 180 140 / 70%); /* Tan */
}

.nutrient-emoji.vegetables {
    background-color: rgb(144 238 144 / 70%); /* Light green */
}

.nutrient-emoji.legumes {
    background-color: rgb(139 69 19 / 70%); /* Saddle brown */
}

.nutrient-emoji.fish {
    background-color: rgb(173 216 230 / 70%); /* Light blue */
}

.nutrient-emoji.eggs {
    background-color: rgb(255 255 224 / 70%); /* Light yellow */
}

.nutrient-emoji.default {
    background-color: rgb(108 117 125 / 70%); /* Default gray */
}

/* Meal title nutrient background classes */
.meal-title-bottom.nutrient-pork {
    background-color: rgb(255 192 203 / 30%);
}

.meal-title-bottom.nutrient-beef {
    background-color: rgb(165 42 42 / 30%);
}

.meal-title-bottom.nutrient-poultry {
    background-color: rgb(255 215 0 / 30%);
}

.meal-title-bottom.nutrient-dairy {
    background-color: rgb(255 248 220 / 50%);
}

.meal-title-bottom.nutrient-grains {
    background-color: rgb(210 180 140 / 30%);
}

.meal-title-bottom.nutrient-vegetables {
    background-color: rgb(144 238 144 / 30%);
}

.meal-title-bottom.nutrient-legumes {
    background-color: rgb(139 69 19 / 30%);
}

.meal-title-bottom.nutrient-fish {
    background-color: rgb(173 216 230 / 30%);
}

.meal-title-bottom.nutrient-eggs {
    background-color: rgb(255 255 224 / 50%);
}
