/* Reset y base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #e85d04;
    --primary-dark: #d00000;
    --secondary: #2d5a47;
    --secondary-dark: #1e3d30;
    --text: #333;
    --text-light: #666;
    --bg: #fafafa;
    --bg-card: #fff;
    --border: #e0e0e0;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --radius: 8px;
}

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Navbar */
.navbar {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-dark) 100%);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    color: #fff;
    font-size: 1.5rem;
    font-weight: bold;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    flex-shrink: 0;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: #fff;
}

/* Page header */
.page-header {
    text-align: center;
    padding: 2rem 0;
}

.page-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.page-header p {
    color: var(--text-light);
}

/* Categories */
.categories {
    margin-bottom: 2rem;
}

.categories h2 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--text-light);
}

.category-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.875rem;
    color: var(--text);
    text-decoration: none;
    transition: all 0.2s;
}

.tag:hover {
    background: var(--primary);
}

/* Sort controls */
.sort-controls {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.sort-form {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.view-toggle {
    display: flex;
    gap: 0.5rem;
}

.view-btn {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    cursor: pointer;
    color: var(--text-light);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.view-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.sort-form label {
    font-weight: 500;
    color: var(--text);
}

.sort-form select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: #fff;
    cursor: pointer;
}

.sort-form select:focus {
    outline: none;
    border-color: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

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

/* Recipe grid */
.recipes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding-bottom: 2rem;
}

/* Recipe table */
.recipes-table-container {
    padding-bottom: 2rem;
    overflow-x: auto;
}

.recipes-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

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

.recipes-table th {
    background: var(--secondary);
    color: #fff;
    font-weight: 500;
    white-space: nowrap;
}

.recipes-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.recipes-table th.sortable:hover {
    background: var(--secondary-dark);
}

.recipes-table th .sort-icon {
    display: inline-block;
    margin-left: 0.5rem;
    opacity: 0.4;
}

.recipes-table th .sort-icon::after {
    content: '⇅';
    font-size: 0.8em;
}

.recipes-table th.sort-asc .sort-icon::after {
    content: '↑';
    opacity: 1;
}

.recipes-table th.sort-desc .sort-icon::after {
    content: '↓';
    opacity: 1;
}

.recipes-table th.sort-asc .sort-icon,
.recipes-table th.sort-desc .sort-icon {
    opacity: 1;
}

.recipes-table tbody tr {
    cursor: pointer;
    transition: background 0.2s;
}

.recipes-table tbody tr:hover {
    background: rgba(232, 93, 4, 0.05);
}

.recipes-table tbody tr:last-child td {
    border-bottom: none;
}

.td-nombre {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

.table-thumb {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
}

.td-desc {
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Recipe card */
.recipe-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.recipe-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.recipe-card a {
    text-decoration: none;
    color: inherit;
}

.recipe-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
}

.recipe-image.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--border);
    color: var(--text-light);
}

.recipe-content {
    padding: 1rem;
}

.recipe-content h3 {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.recipe-desc {
    font-size: 0.875rem;
    color: var(--text-light);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.recipe-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.category-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: var(--primary);
    color: #fff;
    border-radius: 4px;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.category-badge.large {
    font-size: 0.875rem;
    padding: 0.3rem 0.75rem;
}

/* Recipe detail */
.recipe-detail {
    max-width: 900px;
    margin: 0 auto;
    padding-bottom: 2rem;
}

.recipe-header {
    margin-bottom: 1.5rem;
}

.back-link {
    display: inline-block;
    color: var(--primary);
    text-decoration: none;
    margin-bottom: 1rem;
}

.recipe-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

/* Gallery */
.recipe-gallery {
    margin-bottom: 2rem;
}

.gallery-main img {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    border-radius: var(--radius);
}

.gallery-thumbs {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    overflow-x: auto;
}

.gallery-thumbs .thumb {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.gallery-thumbs .thumb:hover {
    opacity: 1;
}

/* Recipe info */
.recipe-info {
    margin-bottom: 2rem;
}

.description {
    font-size: 1.125rem;
    margin-bottom: 1.5rem;
}

.info-cards {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.info-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    text-align: center;
}

.info-card .label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-light);
    text-transform: uppercase;
}

.info-card .value {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--primary);
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Recipe columns */
.recipe-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

@media (max-width: 600px) {
    .recipe-columns {
        grid-template-columns: 1fr;
    }
}

.ingredients h2,
.nutrition h2,
.steps h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary);
}

/* Ingredients */
.ingredient-list {
    list-style: none;
}

.ingredient-list li {
    display: flex;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.ingredient-list .amount {
    min-width: 100px;
    font-weight: 500;
    color: var(--primary);
}

/* Nutrition table */
.nutrition-note {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.nutrition-table {
    width: 100%;
    border-collapse: collapse;
}

.nutrition-table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.nutrition-table td:last-child {
    text-align: right;
    font-weight: 500;
}

/* Steps */
.steps-list {
    padding-left: 1.5rem;
}

.steps-list li {
    padding: 0.75rem 0;
    padding-left: 0.5rem;
}

.steps-list li::marker {
    color: var(--primary);
    font-weight: bold;
}

/* Search */
.search-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.search-form .search-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.form-group {
    flex: 1;
    min-width: 200px;
}

.form-group.full {
    flex: 100%;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

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

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.advanced-filters {
    margin-bottom: 1rem;
}

.advanced-filters summary {
    cursor: pointer;
    color: var(--primary);
    font-weight: 500;
    margin-bottom: 1rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background 0.2s;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: #ccc;
}

/* Search results */
.search-results h2 {
    margin-bottom: 1rem;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    grid-column: 1 / -1;
}

.empty-state h3 {
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-light);
}

/* Error page */
.error-page {
    text-align: center;
    padding: 4rem 1rem;
}

.error-page h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.error-page p {
    color: var(--text-light);
    margin-bottom: 2rem;
}

/* Create form */
.create-section {
    max-width: 700px;
    margin: 0 auto;
    padding-bottom: 2rem;
}

.create-form {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.create-form textarea {
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    min-height: 120px;
}

.create-form textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-help {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 0.5rem;
}

.btn-large {
    width: 100%;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.spinner {
    animation: spin 1s linear infinite;
}

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

.examples {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.examples h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-light);
}

.examples ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.example-btn {
    padding: 0.5rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.example-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.alert-error {
    background: #fee2e2;
    border: 1px solid #ef4444;
    color: #b91c1c;
}

.alert-success {
    background: #dcfce7;
    border: 1px solid #22c55e;
    color: #15803d;
}

/* Edit form */
.edit-form {
    max-width: 800px;
    margin: 0 auto;
    padding-bottom: 2rem;
}

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

.form-section h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary);
}

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

.edit-form .form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.edit-form input[type="text"],
.edit-form input[type="number"],
.edit-form textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
}

.edit-form input:focus,
.edit-form textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.edit-form textarea {
    resize: vertical;
    min-height: 100px;
}

.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 150px;
}

.nutrition-row .form-group {
    min-width: 120px;
}

.form-actions-edit {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn-edit {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--secondary);
    color: #fff;
    border-radius: var(--radius);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.btn-edit:hover {
    background: var(--secondary-dark);
}

.btn-danger {
    background: #dc2626;
    color: #fff;
}

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

.recipe-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

/* Image edit */
.image-edit-container {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.current-image {
    flex-shrink: 0;
}

.current-image img {
    width: 200px;
    height: 150px;
    object-fit: cover;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.current-image .image-filename {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 0.5rem;
    text-align: center;
}

.no-image {
    width: 200px;
    height: 150px;
    background: var(--border);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
}

.image-edit-container .form-group {
    flex: 1;
    min-width: 250px;
}

input[type="file"] {
    padding: 0.5rem;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    width: 100%;
    cursor: pointer;
}

input[type="file"]:hover {
    border-color: var(--primary);
}

/* Weekly Menu */
.menu-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.menu-actions .btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.menu-stats {
    display: flex;
    gap: 2rem;
}

.menu-stats .stat {
    font-size: 0.9rem;
    color: var(--text-light);
}

.menu-stats .stat strong {
    color: var(--primary);
    font-size: 1.1rem;
}

.weekly-menu {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.day-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.day-name {
    background: var(--secondary);
    color: #fff;
    padding: 0.75rem 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.meals {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.meal {
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
}

.meal:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.meal-type {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-light);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.meal-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
    padding: 0.5rem;
    border-radius: var(--radius);
    transition: background 0.2s;
}

.meal-item:hover {
    background: rgba(232, 93, 4, 0.05);
}

.meal-item img {
    width: 60px;
    height: 45px;
    object-fit: cover;
    border-radius: 4px;
}

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

.meal-name {
    display: block;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.meal-kcal {
    display: block;
    font-size: 0.8rem;
    color: var(--text-light);
}

.meal-empty {
    padding: 0.5rem;
    color: var(--text-light);
    font-style: italic;
    font-size: 0.9rem;
}

.menu-legend {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.menu-legend h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-light);
}

.menu-legend ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.menu-legend li {
    font-size: 0.9rem;
    color: var(--text-light);
}

.menu-legend li strong {
    color: var(--text);
}

@media (max-width: 768px) {
    .weekly-menu {
        grid-template-columns: 1fr;
    }

    .menu-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .menu-stats {
        justify-content: center;
    }
}

/* Footer */
.footer {
    background: linear-gradient(135deg, var(--secondary-dark) 0%, var(--secondary) 100%);
    color: rgba(255,255,255,0.85);
    padding: 2rem 0;
    text-align: center;
    margin-top: 2rem;
}

/* Responsive */
@media (max-width: 768px) {
    .recipes-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }

    .info-cards {
        justify-content: center;
    }
}
