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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 250px;
    height: 100vh;
    background-color: #2c3e50;
    color: white;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 16px;
    background-color: #1a252f;
    border-bottom: 1px solid #34495e;
    text-align: center;
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.sidebar nav ul {
    list-style: none;
}

.sidebar nav ul li {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar nav ul li a {
    display: block;
    padding: 15px 20px;
    color: #ecf0f1;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 15px;
}

.sidebar nav ul li a:hover {
    background-color: rgba(255, 255, 255, 0.1);
    padding-left: 25px;
}

.sidebar nav ul li a.active {
    background-color: #3498db;
    border-left: 4px solid #2980b9;
}

/* Main Content */
.main-content {
    margin-left: 250px;
    padding: 0;
    min-height: 100vh;
    background-color: #f5f5f5;
}

.header {
    background-color: white;
    padding: 20px 30px;
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 24px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Content area */
.main-content > *:not(.header) {
    padding: 30px;
}

/* Cards */
.card {
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.card h2 {
    font-size: 20px;
    margin-bottom: 15px;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background-color: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    border-left: 4px solid #3498db;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.12);
}

.stat-card h3 {
    font-size: 13px;
    color: #7f8c8d;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .value {
    font-size: 32px;
    font-weight: 600;
    color: #2c3e50;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.table-container {
    overflow-x: auto;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
}

table thead {
    background-color: #34495e;
    color: white;
}

table th,
table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

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

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    background-color: #3498db;
    color: white;
    text-decoration: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn:hover {
    background-color: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.btn-success {
    background-color: #27ae60;
}

.btn-success:hover {
    background-color: #229954;
}

.btn-danger {
    background-color: #e74c3c;
}

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

.btn-warning {
    background-color: #f39c12;
}

.btn-warning:hover {
    background-color: #e67e22;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

/* === NUEVOS ESTILOS PARA BOTONES DE CATEGORÍA === */

/* Botón principal de crear categoría (junto a Nuevo Egreso, etc.) */
.btn-create-category {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #27ae60 0%, #1e8449 100%);
    color: white;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.3);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(39, 174, 96, 0.3);
    }
    50% {
        box-shadow: 0 6px 20px rgba(39, 174, 96, 0.5);
    }
}

.btn-create-category:hover {
    background: linear-gradient(135deg, #229954 0%, #186a3b 100%);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 20px rgba(39, 174, 96, 0.4);
}

.btn-create-category .icon-plus {
    font-size: 20px;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.2);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

/* === FIN DE ESTILOS PARA BOTONES DE CATEGORÍA === */

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #2c3e50;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s ease;
}

/* Modal sobre modal - z-index más alto */
.modal.modal-over-modal {
    z-index: 2100;
}

#citaModal {
    z-index: 2100;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    animation: slideDown 0.3s ease;
    display: flex;
    flex-direction: column;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px;
    background-color: #3498db;
    color: white;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 22px;
    border: none;
    padding: 0;
}

.close {
    color: white;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
}

.close:hover,
.close:focus {
    color: #ecf0f1;
}

.modal-content form {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
}

/* Modal inputs - ensure they're editable */
.modal input:not([type="checkbox"]),
.modal select,
.modal textarea {
    background-color: white !important;
    cursor: text !important;
    pointer-events: auto !important;
}

.modal input:disabled,
.modal select:disabled,
.modal textarea:disabled {
    background-color: #f5f5f5 !important;
    cursor: not-allowed !important;
}

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

/* Calendar Simple */
.calendar-container {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
}

.calendar-day {
    padding: 15px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.calendar-day:hover {
    background-color: #ecf0f1;
}

.calendar-day.today {
    background-color: #3498db;
    color: white;
}

/* List Items */
.list-item {
    background-color: white;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 6px;
    border-left: 4px solid #3498db;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.list-item:hover {
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transform: translateX(5px);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background-color: #d5f4e6;
    color: #27ae60;
}

.badge-warning {
    background-color: #fef5e7;
    color: #f39c12;
}

.badge-danger {
    background-color: #fadbd8;
    color: #e74c3c;
}

.badge-info {
    background-color: #d6eaf8;
    color: #3498db;
}

/* Bottom navigation - hidden on desktop */
.bottom-nav {
    display: none;
}

/* Overlay - hidden by default */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 950;
}

body.sidebar-open .overlay {
    display: block;
}

/* Logo en sidebar (uploader) */
.logo-box {
    width: 100%;
    max-width: 260px;
    height: 90px;
    margin: 0 auto 8px auto;
    border: 2px dashed #9aa3ad;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: #f8fafc;
    transition: background-color 0.15s ease;
}

.logo-box:hover {
    background: #f1f5f9;
}

.logo-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

.logo-placeholder {
    color: #94a3b8;
    font-weight: 600;
    font-size: 14px;
}

.logo-hint {
    font-size: 12px;
    color: #64748b;
    margin: 4px 0 0;
    text-align: center;
}

/* Ocultar recuadro y textos cuando hay logo */
.logo-box.logo-loaded {
    border: none;
    background: none;
    cursor: pointer;
}

.logo-box.logo-loaded .logo-placeholder,
.logo-box.logo-loaded .logo-hint {
    display: none !important;
}

/* Responsive Media Queries */
@media (max-width: 768px) {
    /* Hide desktop sidebar on mobile */
    .sidebar {
        display: none;
    }
    
    /* Adjust main content */
    .main-content {
        margin-left: 0;
        padding-bottom: 80px; /* Space for bottom nav */
    }
    
    /* Fix header for mobile */
    .header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 900;
        padding: 12px 16px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }
    
    .header h1 {
        font-size: 18px;
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Add padding to content for fixed header */
    .main-content > *:not(.header) {
        padding: 16px;
    }
    
    .main-content {
        padding-top: 64px; /* Space for fixed header */
    }
    
    /* Show bottom navigation */
    .bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        display: flex;
        gap: 4px;
        background: #ffffff;
        border-top: 1px solid #e5e7eb;
        padding: 8px;
        z-index: 1000;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }
    
    .bottom-nav a {
        flex: 0 0 auto;
        padding: 10px 14px;
        border-radius: 8px;
        color: #374151;
        text-decoration: none;
        font-weight: 500;
        font-size: 13px;
        background: #f9fafb;
        white-space: nowrap;
        transition: all 0.2s ease;
    }
    
    .bottom-nav a.active {
        background: #3498db;
        color: white;
    }
    
    /* Adjust cards and grids */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .grid-2 {
        grid-template-columns: 1fr;
    }
    
    .card {
        border-radius: 6px;
        padding: 16px;
    }
    
    /* Tables responsive */
    .table-container,
    .table-responsive {
        margin: 0 -16px;
        border-radius: 0;
    }
    
    table th,
    table td {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    /* Button adjustments */
    .btn {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    .btn-sm {
        padding: 6px 12px;
        font-size: 13px;
    }

    /* Ajustes para botones de categoría en móvil */
    .btn-create-category {
        font-size: 13px;
        padding: 10px 18px;
    }
    
    /* Form inputs larger for mobile */
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 12px;
    }
    
    /* Modal adjustments for mobile */
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
    
    .modal-header h2 {
        font-size: 18px;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
    }

    /* Ajustes en móviles (sidebar oculta) */
    .logo-box {
        max-width: 100%;
        height: 80px;
    }
}

/* iOS safe area support */
@supports (padding: env(safe-area-inset-top)) {
    @media (max-width: 768px) {
        .header {
            padding-top: max(12px, env(safe-area-inset-top));
        }
        
        .main-content {
            padding-top: calc(64px + env(safe-area-inset-top));
        }
        
        .bottom-nav {
            padding-bottom: calc(8px + env(safe-area-inset-bottom));
        }
        
        .main-content {
            padding-bottom: calc(80px + env(safe-area-inset-bottom));
        }
    }
}

/* Prevent horizontal scroll */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

/* Responsive images and media */
img, video, canvas, svg {
    max-width: 100%;
    height: auto;
}

/* Ensure form elements don't overflow */
input, select, textarea, button {
    max-width: 100%;
}

/* === Extensiones para configurador de recetas === */
.logo-hint { font-size: 12px; color: #64748b; margin-top: 6px; }
.modal-over-modal { z-index: 2100; }
.welcome-card { background: white; border-radius: 8px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin-bottom: 16px; }
/* === Estilos para modal de configuración mejorado === */
.upload-section {
    text-align: center;
    padding: 32px 24px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 16px;
    border: 2px dashed #667eea;
}

.upload-icon {
    font-size: 64px;
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.upload-section h3 {
    font-size: 20px;
    color: #2d3748;
    margin: 0 0 8px 0;
    font-weight: 600;
}

.upload-description {
    color: #4a5568;
    font-size: 14px;
    margin-bottom: 24px;
}

.btn-upload {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 32px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-upload:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.4);
}

.file-name {
    display: none;
    margin-top: 12px;
    padding: 8px 16px;
    background: white;
    border-radius: 6px;
    color: #2d3748;
    font-size: 14px;
    font-weight: 500;
}

.upload-hint {
    margin-top: 20px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    font-size: 13px;
    color: #4a5568;
    line-height: 1.6;
}

.upload-hint strong {
    color: #667eea;
}

/* === Modal de vista de receta === */
#modal-vista-receta .modal-content {
    background: #f8f9fa;
}

#modal-vista-receta img {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}