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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f5f7;
    color: #1d1d1f;
    line-height: 1.5;
}

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

/* Header with language toggle */
.header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 40px;
}

.header-center {
    text-align: center;
    flex: 1;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.subtitle {
    color: #86868b;
}

.lang-toggle {
    display: flex;
    gap: 4px;
    background: #e5e5e5;
    border-radius: 8px;
    padding: 3px;
}

.lang-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    color: #86868b;
    transition: all 0.2s;
}

.lang-btn.active {
    background: white;
    color: #1d1d1f;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.lang-btn:hover:not(.active) {
    color: #1d1d1f;
}

/* Form Styles */
.form-section {
    background: white;
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    max-width: 600px;
    margin: 0 auto;
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.form-group {
    flex: 1;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.form-group input[type="number"],
.form-group input[type="text"],
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #0071e3;
}

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

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

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

.radio-group {
    display: flex;
    gap: 20px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.radio-label input {
    width: 18px;
    height: 18px;
}

.slider-group input[type="range"] {
    width: 100%;
    height: 6px;
    margin-top: 8px;
}

.generate-btn {
    width: 100%;
    padding: 16px;
    background: #0071e3;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 12px;
}

.generate-btn:hover {
    background: #0077ed;
}

.generate-btn:disabled {
    background: #86868b;
    cursor: not-allowed;
}

.test-btn {
    display: block;
    margin: 20px auto;
    padding: 10px 20px;
    background: #86868b;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
}

.test-btn:hover {
    background: #6e6e73;
}

.test-btn:disabled {
    background: #c7c7cc;
    cursor: not-allowed;
}

.randomness-results {
    max-width: 600px;
    margin: 20px auto;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.randomness-results h3 {
    margin-bottom: 16px;
}

.randomness-results h4 {
    margin-top: 16px;
    margin-bottom: 8px;
}

.randomness-results ol {
    padding-left: 20px;
}

.randomness-results li {
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.progress-bar-bg {
    width: 100%;
    height: 20px;
    background: #e5e5e5;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #0071e3, #34c759);
    border-radius: 10px;
    transition: width 0.3s ease;
    width: 0%;
}

#progress-text {
    text-align: center;
    font-size: 0.9rem;
    color: #86868b;
}

/* Results Styles */
.results-section {
    margin-top: 40px;
}

.stats-bar {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 24px;
    background: white;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.stat {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    color: #86868b;
    margin-bottom: 4px;
}

.stat-range {
    display: block;
    font-size: 0.7rem;
    color: #86868b;
    margin-bottom: 2px;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 600;
}

/* Week Grid */
.week-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.day-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
}

.day-card h3 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e5e5e5;
}

/* Meal slot sections within a day card */
.meal-slot {
    margin-bottom: 10px;
}

.meal-slot:last-child {
    margin-bottom: 0;
}

.slot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0 4px 0;
    border-bottom: 1px solid #e5e5e5;
    margin-bottom: 2px;
}

.slot-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: #0071e3;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.slot-macros {
    font-size: 0.73rem;
    color: #86868b;
}

.meal-slot .food-list {
    margin-bottom: 0;
}

.food-list {
    list-style: none;
    margin-bottom: 16px;
    flex: 1;
}

.food-list li {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f5f5f7;
}

.food-list li:last-child {
    border-bottom: none;
}

.food-name {
    font-size: 0.9rem;
}

.food-amount {
    color: #86868b;
    font-size: 0.85rem;
}

.day-macros {
    display: flex;
    justify-content: space-between;
    padding-top: 12px;
    border-top: 1px solid #e5e5e5;
    font-size: 0.85rem;
    margin-top: auto;
}

/* Highlight Colors */
.highlight-cal {
    color: #ff9500;
    font-weight: 600;
}

.highlight-protein {
    color: #34c759;
    font-weight: 600;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    justify-content: center;
}

.tab-btn {
    padding: 12px 24px;
    border: none;
    background: #e5e5e5;
    cursor: pointer;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: #d5d5d5;
}

.tab-btn.active {
    background: #0071e3;
    color: white;
}

.error {
    color: #ff3b30;
    font-weight: 500;
}

.success {
    color: #34c759;
    font-weight: 500;
}

/* Responsive */
@media (max-width: 600px) {
    .form-row {
        flex-direction: column;
        gap: 12px;
    }

    .stats-bar {
        gap: 16px;
    }

    .stat {
        min-width: 80px;
    }

    .tabs {
        flex-direction: column;
    }

    .header-row {
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }

    .lang-toggle {
        order: -1;
        align-self: flex-end;
    }
}

/* ============ DATABASE EDITOR TAB ============ */
#editor-tab {
    max-width: 1200px;
    margin: 0 auto;
}

.editor-controls {
    background: white;
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

.editor-search {
    flex: 1;
    min-width: 200px;
}

.editor-search input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    font-size: 0.95rem;
}

.editor-search input:focus {
    outline: none;
    border-color: #0071e3;
}

.editor-count {
    color: #86868b;
    font-size: 0.9rem;
    white-space: nowrap;
}

.editor-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.editor-card {
    background: white;
    border: 2px solid #e5e5e5;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: all 0.2s;
}

.editor-card.modified {
    border-color: #ff9500;
    background: #fffbf5;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e5e5e5;
}

.card-header-info {
    flex: 1;
    margin-right: 8px;
}

.card-title {
    display: block;
    font-weight: 600;
    font-size: 0.95rem;
    color: #1d1d1f;
    line-height: 1.3;
}

.card-category {
    display: block;
    font-size: 0.7rem;
    color: #86868b;
    margin-top: 2px;
}

.card-notes {
    font-size: 0.75rem;
    color: #6e6e73;
    font-style: italic;
    margin-bottom: 8px;
}

.card-actions {
    display: flex;
    gap: 6px;
}

.card-actions button {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-delete {
    background: #ffebee;
}

.btn-delete:hover {
    background: #ff3b30;
    color: white;
}

/* Tags and badges */
.card-tags-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 10px;
}

.slot-tag {
    display: inline-block;
    padding: 2px 8px;
    background: #e8f0fe;
    color: #1a73e8;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
}

.diet-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
}

.diet-tag.veg {
    background: #e8f5e9;
    color: #2e7d32;
}

.diet-tag.vegan {
    background: #f1f8e9;
    color: #558b2f;
}

.diet-tag.halal {
    background: #fce4ec;
    color: #c62828;
}

.diet-tag.side {
    background: #fff3e0;
    color: #e65100;
}

.card-section {
    margin-bottom: 10px;
}

.card-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: #86868b;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.editor-card .card-row {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
}

.editor-card .card-field {
    flex: 1;
}

.editor-card .card-field label {
    display: block;
    font-size: 0.7rem;
    color: #86868b;
    margin-bottom: 2px;
}

.editor-card .card-field input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #d2d2d7;
    border-radius: 6px;
    font-size: 0.85rem;
}

.editor-card .card-field input:focus {
    outline: none;
    border-color: #0071e3;
}

.editor-card .checkbox-field {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #e5e5e5;
}

.editor-card .checkbox-field label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #1d1d1f;
    cursor: pointer;
}

.editor-card .checkbox-field input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.btn-save-card {
    width: 100%;
    padding: 10px;
    background: #34c759;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
}

.btn-save-card:hover {
    background: #2db84d;
}

.editor-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 500;
    display: none;
    z-index: 1000;
    animation: fadeIn 0.3s;
}

.editor-status.success {
    background: #34c759;
    color: white;
}

.editor-status.error {
    background: #ff3b30;
    color: white;
}

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

/* Responsive editor */
@media (max-width: 768px) {
    .editor-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .editor-search {
        min-width: 100%;
    }

    .editor-cards-grid {
        grid-template-columns: 1fr;
    }
}
