@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Lora:ital,wght@0,400;0,500;0,600;1,400&display=swap');

:root {
    --bg-main: #FDFBF7;
    --bg-surface: #FFFFFF;
    --bg-surface-hover: #F9F7F1;
    --text-main: #3E3B39;
    --text-muted: #7A7571;
    --border-color: #EAE6DF;
    
    --accent-primary: #C47A6B;
    --accent-primary-hover: #A86558;
    
    --moncho-accent: #6FA3B1;
    --mimi-accent: #A886A2;
    --fav-accent: #E8AA42;
    
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --shadow-soft: 0 4px 24px rgba(62, 59, 57, 0.04);
    --shadow-hover: 0 12px 32px rgba(62, 59, 57, 0.08);
}

[data-theme="dark"] {
    --bg-main: #1A1918;
    --bg-surface: #242221;
    --bg-surface-hover: #2D2B29;
    --text-main: #EAE6DF;
    --text-muted: #9C9893;
    --border-color: #383533;
    
    --accent-primary: #D48C7E;
    --accent-primary-hover: #E3A397;
    
    --moncho-accent: #81B3C2;
    --mimi-accent: #B899B3;
    --fav-accent: #F0C06A;
    
    --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.2);
    --shadow-hover: 0 12px 32px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .editorial-text, legend {
    font-family: 'Lora', serif;
    font-weight: 500;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.hidden { display: none !important; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1.5rem; }
.pl-4 { padding-left: 2rem !important; }

/* Compact Header */
.compact-header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-titles h1 {
    font-size: 1.4rem;
    color: var(--text-main);
    letter-spacing: -0.02em;
    line-height: 1;
}

.header-titles p {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    font-family: 'Lora', serif;
    margin-top: 0.2rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.cats-avatars { display: flex; gap: -0.5rem; }
.cats-avatars img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--bg-surface);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-left: -8px;
}
.cats-avatars img:first-child { margin-left: 0; }

.theme-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.theme-toggle:hover { color: var(--accent-primary); background-color: var(--bg-main); }

.btn-primary {
    background-color: var(--accent-primary);
    color: #FFF;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 30px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(196, 122, 107, 0.2);
}
.btn-primary:hover { background-color: var(--accent-primary-hover); transform: translateY(-1px); }

.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.6rem 1.2rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
}
.btn-text:hover { color: var(--text-main); }
.text-danger { color: #d9534f; }
.text-danger:hover { color: #c9302c; }

/* Filters */
.filters-section {
    margin: 2rem 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.search-box input {
    width: 100%;
    max-width: 400px;
    padding: 0.8rem 1.2rem;
    border-radius: 30px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-surface);
    color: var(--text-main);
    font-size: 0.95rem;
}
.search-box input:focus { outline: none; border-color: var(--accent-primary); }

.filter-chips { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.chip {
    padding: 0.4rem 1rem;
    border-radius: 30px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
}
.chip.active { background: var(--text-main); color: var(--bg-main); border-color: var(--text-main); }

/* Form Structure */
.form-section { margin-bottom: 3rem; margin-top: 1rem; }
.form-card {
    background-color: var(--bg-surface);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-soft);
}
.form-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }
.btn-close { background: none; border: none; font-size: 1.8rem; color: var(--text-muted); cursor: pointer; }

.form-fieldset {
    border: none;
    border-top: 1px dashed var(--border-color);
    padding-top: 2rem;
    margin-top: 2rem;
    position: relative;
}
.form-fieldset:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }

legend {
    padding: 0 1rem;
    font-size: 1.2rem;
    color: var(--accent-primary);
    margin-left: -1rem;
    background: var(--bg-surface);
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.full-width { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }

label { font-size: 0.8rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.help-text { font-size: 0.8rem; color: var(--text-muted); font-style: italic; }

input, select, textarea {
    padding: 0.7rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-primary); }

.input-with-icon { position: relative; display: flex; align-items: center; }
.input-with-icon span { position: absolute; left: 1rem; color: var(--text-muted); }

/* Image Preview */
.image-input-group { position: relative; }
.image-preview-container {
    margin-top: 0.5rem;
    width: 100px;
    height: 100px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
}
.image-preview-container img { width: 100%; height: 100%; object-fit: cover; }

/* Ratings */
.ratings-container {
    display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem;
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: var(--bg-main);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}
.rating-box { display: flex; flex-direction: column; gap: 1rem; transition: opacity 0.3s; }
.rating-header { display: flex; align-items: center; gap: 0.8rem; }
.cat-avatar-small { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; border: 2px solid var(--bg-surface); }

/* Quick Chips */
.quick-chips { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.quick-chip {
    background: var(--bg-main); border: 1px solid var(--border-color);
    padding: 0.3rem 0.8rem; border-radius: 20px; font-size: 0.8rem;
    color: var(--text-muted); cursor: pointer; transition: all 0.2s;
}
.quick-chip:hover { background: var(--bg-surface-hover); color: var(--accent-primary); border-color: var(--primary); }

/* Form Details (Opcional) */
.form-details {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) var(--spacing-md);
    margin-top: 2.5rem;
    margin-bottom: 2rem;
}
.form-details summary {
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    user-select: none;
    outline: none;
    list-style: none; /* Hide default arrow in some browsers */
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.form-details summary::-webkit-details-marker {
    display: none;
}
.form-details summary::after {
    content: '+';
    font-size: 1.2rem;
    font-weight: normal;
    color: var(--text-muted);
}
.form-details[open] summary::after {
    content: '−';
}
.form-details .details-content {
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px dashed var(--border);
}

/* Modal Nutritional Info */
.composition-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
    background: var(--bg-main);
    padding: 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.nutritional-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: var(--bg-main);
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
}
.nutritional-table th, .nutritional-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.nutritional-table th {
    font-weight: 600;
    color: var(--text-main);
    background-color: var(--bg-surface);
    width: 40%;
}
.nutritional-table tr:last-child td {
    border-bottom: none;
}
.nutritional-table td:last-child {
    font-weight: 600;
}

/* Footer Legend */
.app-footer {
    text-align: center;
    padding: var(--spacing-lg) 0;
    margin-top: var(--spacing-xl);
    border-top: 1px solid var(--border);
}
.avatar-legend {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
}

/* Switches */
.decisions-fieldset { display: flex; gap: 1.5rem; }
.switch-card {
    flex: 1;
    display: flex; justify-content: space-between; align-items: center;
    padding: 1.2rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-main);
    cursor: pointer;
}
.switch-card.highlight { border-color: rgba(232, 170, 66, 0.4); background: rgba(232, 170, 66, 0.05); }
.switch-card-text { display: flex; flex-direction: column; }
.switch-card-text strong { font-size: 0.95rem; color: var(--text-main); }
.switch-card-text span { font-size: 0.8rem; color: var(--text-muted); }

.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--border-color); transition: .4s; border-radius: 24px;
}
.slider:before {
    position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px;
    background-color: white; transition: .4s; border-radius: 50%;
}
input:checked + .slider { background-color: var(--accent-primary); }
.highlight input:checked + .slider { background-color: var(--fav-accent); }
input:checked + .slider:before { transform: translateX(20px); }

/* Sticky Actions */
.sticky-actions {
    display: flex; justify-content: flex-end; gap: 1rem;
    margin-top: 2rem; padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Foods Grid */
.foods-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.5rem; padding-bottom: 4rem; }

.food-card { 
    background: var(--bg-surface); 
    border-radius: var(--radius-md); 
    border: 1px solid var(--border-color); 
    overflow: hidden; 
    display: flex; 
    flex-direction: column; 
    cursor: pointer; 
    position: relative; 
    transition: box-shadow 0.2s, border-color 0.2s;
}
.food-card:hover { border-color: var(--accent-primary); box-shadow: var(--shadow-hover); }
.food-card:focus { outline: 2px solid var(--accent-primary); outline-offset: 2px; }

.card-summary { position: relative; }
.card-img-container { height: 160px; background: var(--bg-main); position: relative; border-bottom: 1px solid var(--border-color); }
.card-img { width: 100%; height: 100%; object-fit: cover; }
.no-img { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-muted); font-family: 'Lora', serif; font-style: italic; font-size: 1.1rem; background-image: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(122, 117, 113, 0.03) 10px, rgba(122, 117, 113, 0.03) 20px); }
.fav-badge { position: absolute; top: 1rem; right: 1rem; background: var(--bg-surface); color: var(--fav-accent); padding: 0.5rem; border-radius: 50%; box-shadow: 0 4px 12px rgba(0,0,0,0.1); font-size: 1.1rem; line-height: 1; border: 1px solid var(--border-color); }

.card-content-summary { padding: 1.2rem; position: relative; }
.card-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.3rem; }
.card-brand { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; }
.card-summary-ratings { display: flex; gap: -4px; margin-right: 2rem; }
.rating-avatar-micro { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; border: 1px solid var(--bg-surface); margin-left: -6px; }
.rating-avatar-micro:first-child { margin-left: 0; }

.card-title { font-size: 1.2rem; margin-bottom: 0.2rem; line-height: 1.3; padding-right: 2rem; }
.card-flavor { font-size: 0.9rem; color: var(--text-muted); font-family: 'Lora', serif; font-style: italic; }

.expand-chevron { 
    position: absolute; right: 1.2rem; top: 1.2rem; 
    background: none; border: none; color: var(--text-muted); 
    transition: transform 0.3s ease; pointer-events: none; 
}
.food-card.expanded .expand-chevron { transform: rotate(180deg); color: var(--accent-primary); }

.card-expanded-content {
    background: var(--bg-main);
    border-top: 1px dashed var(--border-color);
}
.card-expanded-content.hidden { display: none !important; }
.card-expanded-inner { padding: 1.2rem; display: flex; flex-direction: column; gap: 1.2rem; }

.expanded-section h4 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 0.5rem; font-family: 'Inter', sans-serif; }
.card-ratings-full { display: flex; flex-direction: column; gap: 0.5rem; }
.rating-row { display: flex; align-items: center; gap: 0.8rem; }
.rating-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; border: 1px solid var(--bg-surface); }
.rating-text { font-size: 0.85rem; font-weight: 500; color: var(--text-main); }

.details-list { list-style: none; padding: 0; margin: 0; font-size: 0.85rem; color: var(--text-main); }
.details-list li { margin-bottom: 0.3rem; }
.details-list strong { color: var(--text-muted); font-weight: 500; margin-right: 0.3rem; }

.card-notes { font-size: 0.85rem; color: var(--text-main); line-height: 1.4; background: var(--bg-surface); padding: 0.8rem; border-radius: var(--radius-sm); border: 1px solid var(--border-color); }
.card-notes strong { color: var(--text-muted); display: block; margin-bottom: 0.2rem; font-weight: 500; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 1.5rem;
    opacity: 1;
    transition: opacity 0.3s ease;
}
.modal-overlay.hidden { display: none !important; }
.modal-content {
    background: var(--bg-main);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--bg-main);
    z-index: 10;
}
.modal-header h2 { font-size: 1.3rem; line-height: 1.2; }
.modal-body { padding: 1.5rem; display: flex; flex-direction: column; gap: 1.5rem; }
.modal-img { width: 100%; height: 200px; object-fit: cover; border-radius: var(--radius-md); border: 1px solid var(--border-color); }
.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    background: var(--bg-surface);
}
.btn-secondary {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.6rem 1.2rem;
    border-radius: 30px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
}
.btn-secondary:hover { background: var(--bg-surface-hover); border-color: var(--text-main); }

.state-message { text-align: center; padding: 3rem 1rem; color: var(--text-muted); font-family: 'Lora', serif; font-size: 1.1rem; font-style: italic; }

@media (max-width: 768px) {
    .header-container { flex-direction: column; align-items: flex-start; gap: 1rem; }
    .header-actions { width: 100%; justify-content: space-between; }
    .form-card { padding: 1.5rem; }
    .form-grid, .ratings-container, .decisions-fieldset { grid-template-columns: 1fr; flex-direction: column; }
    .ratings-container { padding: 1rem; gap: 1rem; }
    .switch-card { width: 100%; }
    .modal-overlay { padding: 1rem; }
}
