/* ==========================================
   VARIABLES CORPORATIVAS (Colores fijos)
========================================== */
:root {
    --primary-dark: #0A4734; /* Verde oscuro */
    --primary-light: #84f553; /* Verde lima */
    --primary-light-bg: #e8fcdd; /* Fondo verde muy claro */
    --white: #ffffff;
    --bg-gray: #f3f4f6; /* Fondo gris claro general */
    
    /* Variables de diseño estándar profesional */
    --text-dark: #111827;
    --text-muted: #6b7280;
    --border-color: #d1d5db; /* Gris estándar para bordes de inputs */
    --danger: #ef4444; /* Rojo para borrar o estados de espera */
    --success: var(--primary-light);
    
    /* Sombra suave profesional */
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* ==========================================
   RESET COMPLETO
========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-gray);
    color: var(--text-dark);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* ==========================================
   LAYOUT PRINCIPAL
========================================== */
#app-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.view {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    animation: fadeInPage 0.3s ease-in-out;
}

/* ==========================================
   VISTA: LOGIN (Fondo verde, letras blancas)
========================================== */
#view-login {
    background-color: var(--primary-dark);
    justify-content: center;
    align-items: center;
    margin: -1.5rem; /* Oculta padding de .view para llenar toda la pantalla */
    padding: 1.5rem;
}

#login-container {
    width: 100%;
    max-width: 350px;
    text-align: center;
}

#login-title {
    color: var(--white);
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    margin-bottom: -5px;
}

#login-subtitle {
    color: var(--primary-light);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    margin-bottom: 2.5rem;
}

#login-form {
    width: 100%;
}

#login-password {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--white);
    text-align: center;
    border-radius: 9999px; /* Input redondeado para moderno */
    width: 100%;
    padding: 1rem;
    font-size: 1.15rem;
}

#login-password::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

#login-password:focus {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(132, 245, 83, 0.3);
}

#login-form .primary-btn {
    background-color: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 9999px;
    font-weight: 800;
    margin-top: 0.5rem;
}

#login-form .primary-btn:hover {
    background-color: #72db45;
}

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

/* ==========================================
   NAVBAR GLOBAL (imagen 1)
========================================== */
#global-navbar {
    background-color: var(--white);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--border-color);
}

#menu-btn {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 1.25rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

#menu-btn:hover {
    background-color: #f9fafb;
}

#navbar-title {
    flex: 1;
    text-align: center;
    color: var(--primary-dark);
    font-size: 1.25rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ==========================================
   FORMULARIOS Y CAMPOS DE ENTRADA (Reset profesional)
   Corrección: Diseño limpio estándar
========================================== */
form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

/* Etiquetas de formularios estándar profesional */
form label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-dark);
}

/* Inputs estándar profesionales (imagen 3/4 corregida) */
input[type="text"], input[type="number"], input[type="email"], input[type="password"]:not(#login-password), select, textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color); /* Bordes grises estándar */
    border-radius: 0.5rem; /* Curvas suaves estándar, no super redondeado */
    font-size: 1rem;
    color: var(--text-dark);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: var(--white);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary-dark);
    box-shadow: 0 0 0 3px rgba(10, 71, 52, 0.15); /* Halo verde oscuro suave */
}

textarea {
    resize: none;
    height: 5rem;
}

/* Input file (imagen 3 corregida) */
.file-drop-area {
    background-color: var(--primary-light-bg);
    border: 2px dashed var(--primary-light);
    border-radius: 0.75rem;
    padding: 2rem;
    text-align: center;
    position: relative;
    cursor: pointer;
    transition: background-color 0.2s;
    min-height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.file-drop-area:hover {
    background-color: #dcfce7;
}

.file-drop-area span {
    color: var(--primary-dark);
    font-weight: 600;
    font-size: 0.8rem;
}

.file-drop-area input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Select de Rol especial (imagen 4 corregida) */
#team-role {
    color: #2563eb; /* Texto azul profesional */
    font-weight: 600;
    text-align-last: center; /* Centrar texto */
}

/* ==========================================
   BOTONES
========================================== */
.primary-btn {
    background-color: var(--primary-dark);
    color: var(--white);
    font-weight: 600;
    padding: 0.8rem 1.5rem;
    border-radius: 0.5rem; /* Botones estándar, no cápsulas */
    border: none;
    width: 100%;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

.primary-btn:hover {
    background-color: #073325;
}

.danger-btn { background-color: var(--danger); color: var(--white); font-weight: 600; padding: 0.8rem; border-radius: 0.5rem; border: none; width: 100%; cursor: pointer; }
.danger-btn:hover { background-color: #dc2626; }

.secondary-btn { background-color: #e5e7eb; color: #1f2937; font-weight: 600; padding: 0.8rem; border-radius: 0.5rem; border: none; width: 100%; cursor: pointer; }
.secondary-btn:hover { background-color: #d1d5db; }

.danger-text-btn { background: none; border: none; color: var(--danger); font-weight: 600; font-size: 0.875rem; cursor: pointer; text-decoration: underline; margin-top: 0.5rem; }

/* Botón flotante '+' (imagen 3 corregida) */
.floating-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 3.5rem;
    height: 3.5rem;
    background-color: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 9999px; /* Botón flotante sí es circular */
    border: none;
    font-size: 2rem;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: 30;
    transition: transform 0.2s, background-color 0.2s;
}

.floating-btn:hover {
    transform: scale(1.05) translateY(-3px);
    background-color: #72db45;
}

/* ==========================================
   FILTROS (Pedidos - imagen 1 corregida)
========================================== */
#orders-header {
    background-color: #e5e7eb;
    border-radius: 1rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

#orders-filters-type, #orders-filters-status {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.filter-type, .filter-status {
    background-color: var(--white);
    color: var(--text-dark);
    border: 1px solid #d1d5db;
    padding: 0.5rem 1.25rem;
    border-radius: 9999px; /* Filtros sí son cápsulas */
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-type:hover, .filter-status:hover {
    background-color: #f9fafb;
    border-color: #c0c4cc;
}

.filter-type.active, .filter-status.active {
    background-color: var(--primary-dark);
    color: var(--white);
    border-color: var(--primary-dark);
}

#orders-date {
    text-align: center;
    color: #9ca3af;
    font-style: italic;
    font-weight: 700;
    font-size: 1.2rem;
}

/* ==========================================
   TABLAS (imagen 1 corregida)
   Corrección: Diseño limpio estándar
========================================== */
.table-container {
    background-color: var(--white);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    overflow-x: auto;
    flex: 1;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
    text-align: left;
}

th {
    background-color: #f9fafb;
    color: var(--primary-dark);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1rem;
    position: sticky;
    top: 0;
    border-bottom: 1px solid var(--border-color);
    z-index: 1;
}

td {
    padding: 1rem;
    font-size: 0.9rem;
    border-bottom: 1px solid #f3f4f6;
    white-space: nowrap;
    color: #374151;
}

tbody tr:hover {
    background-color: #f9fafb;
    cursor: pointer;
}

/* Columnas especificas de la tabla (imagen 1 corregida) */
.col-time { color: var(--text-muted); font-weight: 500; }
.col-name { font-weight: 600; color: var(--text-dark); }
.col-phone { color: var(--text-muted); font-size: 0.85rem; }
.col-total { font-weight: 700; color: var(--text-dark); font-size: 1rem; }
.col-desc { max-width: 200px; overflow: hidden; text-overflow: ellipsis; color: var(--text-muted); }
.col-price { color: var(--primary-dark); font-weight: 800; font-size: 1rem; }

/* Botones de acción en tabla */
.btn-outline { background: var(--white); border: 1px solid #d1d5db; border-radius: 0.375rem; padding: 0.35rem 0.6rem; font-size: 0.8rem; cursor: pointer; font-weight: 500; }
.btn-outline:hover { background-color: #f9fafb; }

.btn-edit { background: none; border: none; color: #2563eb; cursor: pointer; margin-right: 0.75rem; font-weight: 600; text-decoration: underline; }
.btn-edit:hover { color: #1e40af; }

.btn-del { background: none; border: none; color: var(--danger); cursor: pointer; font-weight: 600; text-decoration: underline; }
.btn-del:hover { color: #dc2626; }

/* Estilos de tabla extra */
.col-category { font-size: 0.8rem; font-weight: 600; text-transform: capitalize; color: var(--primary-dark); }
.category-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background-color: var(--primary-light-bg);
    border-radius: 9999px;
    border: 1px solid var(--primary-light);
}

/* Cápsulas de estado de tabla (imagen 1 corregida) */
.col-status, .col-role {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px; /* Cápsulas redondeadas */
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: none;
}

.status-waiting {
    background-color: var(--danger); /* Rojo En espera */
    color: var(--white);
    cursor: pointer;
}

.status-completed {
    background-color: var(--primary-light); /* Verde lima Completado */
    color: var(--primary-dark);
}

/* Helper de Roles del equipo apoyando main.js (imagen 4 corregida) */
.bg-yellow-100 { background-color: #fef9c3; } /* Fondo amarillo pálido Admin */
.text-yellow-800 { color: #854d0e; } /* Texto amarillo oscuro */
.border-yellow-300 { border-color: #fde047; }
.bg-blue-100 { background-color: #dbeafe; } /* Fondo azul pálido Empleado */
.text-blue-800 { color: #1e40af; } /* Texto azul oscuro */
.border-blue-300 { border-color: #93c5fd; }

.col-role {
    border: 1px solid transparent;
}

/* Scrollbar para Tablas */
.table-container::-webkit-scrollbar { height: 6px; width: 6px; }
.table-container::-webkit-scrollbar-track { background: var(--bg-gray); }
.table-container::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* ==========================================
   MODALES (imágenes 2, 6, 7 corregidas)
   Corrección: Centrado y diseño profesional
========================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.7); /* Fondo más oscuro para enfoque */
    backdrop-filter: blur(4px);
    z-index: 50;
    padding: 1.5rem;
    
    /* === CORRECCIÓN DE CENTRADO EN PC === */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* === CORRECCIÓN DE RESET PARA ETIQUETA <DIALOG> === */
/* Evitar el comportamiento nativo del navegador que causa el marco negro y esquina */
dialog.modal-overlay {
    border: none; /* Quitar marco negro nativo */
    margin: 0;
    padding: 0;
    max-width: 100vw;
    max-height: 100vh;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.7);
    /* Volver a aplicar flex cuando no esté hidden */
    display: flex; 
}

/* Forzar flex cuando está visible y no usar hidden nativo de dialog */
dialog.modal-overlay:not(.hidden) {
    display: flex !important;
}

.modal-content {
    background-color: var(--white);
    border-radius: 1.25rem; /* Curvas suaves estándar */
    padding: 2rem; /* Más espaciado */
    width: 100%;
    max-width: 28rem; /* Ligeramente más ancho en PC */
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: modalPopIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-height: 90vh; /* Scroll interno si es muy alto */
    overflow-y: auto;
}

@keyframes modalPopIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.close-modal {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    background: none;
    border: none;
    font-size: 1.75rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.close-modal:hover { color: var(--danger); }

.modal-content h2 { 
    color: var(--primary-dark); 
    font-size: 1.5rem; /* Títulos más grandes profesional */
    text-align: center; 
    margin-bottom: 1.5rem; 
    font-weight: 700;
}

.modal-content p { 
    text-align: center; 
    color: var(--text-muted); 
    font-size: 0.95rem; 
    margin-bottom: 1.5rem; 
    line-height: 1.5;
}

/* Iconos de ubicación (imagen 2, 7 corregidas) */
.icon-placeholder {
    background-color: var(--primary-light-bg);
    color: var(--primary-dark);
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 9999px; /* Círculos estándar */
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.75rem;
    margin: 0 auto 1.5rem auto;
    border: 1px solid rgba(10, 71, 52, 0.1);
}

/* Texto de dirección (imagen 2 corregida) */
#loc-address { background-color: var(--bg-gray); padding: 0.75rem 1.25rem; border-radius: 0.5rem; margin-bottom: 1.5rem; text-align: center; font-size: 0.9rem; font-weight: 500; border: 1px solid #e5e7eb; color: var(--text-dark); }

/* Total grande de status (imagen 7 corregida) */
#status-total { font-size: 2.5rem; color: var(--text-dark); text-align: center; margin-bottom: 2rem; font-weight: 800; }

/* Lista de Artículos de Pedido (imagen 6 corregida) */
#items-list {
    margin-bottom: 1.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 0.5rem 1rem;
    background-color: #f9fafb;
}

.item-row { display: flex; justify-content: space-between; padding: 0.75rem 0; border-bottom: 1px solid var(--border-color); font-size: 0.9rem; }
.item-row:last-child { border-bottom: none; }
.item-row span:first-child { font-weight: 500; color: var(--text-dark); }
.item-row span:last-child { color: var(--primary-dark); font-weight: bold; }

.modal-footer { display: flex; justify-content: space-between; padding-top: 1rem; margin-top: 0.5rem; font-weight: bold; font-size: 1rem; color: var(--text-dark); }
#items-total { color: var(--primary-dark); font-size: 1.1rem; }

/* ==========================================
   SIDEBAR MENÚ (imagen 8 - Flotante o Standard)
   Corrección: Diseño limpio estándar
========================================== */
#modal-sidebar.modal-overlay {
    justify-content: flex-start; /* Alinear a la izquierda */
    padding: 0;
}

.sidebar-content {
    background-color: var(--white);
    width: 17rem; /* Ancho específico */
    height: 100vh; /* Alto completo profesional */
    padding: 2rem;
    display: flex;
    flex-direction: column;
    box-shadow: 10px 0 25px rgba(0,0,0,0.1);
    animation: slideInLeft 0.3s ease-out; /* Animación lateral profesional */
    border-radius: 0 1.5rem 1.5rem 0; /* Curvas solo a la derecha */
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

.sidebar-content h2 {
    color: var(--primary-dark);
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 3rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.nav-link {
    background: none;
    border: none;
    text-align: left;
    font-size: 1.125rem; /* Texto estándar profesional */
    color: var(--text-dark);
    font-weight: 600; /* Texto en negrita profesional */
    cursor: pointer;
    transition: color 0.2s;
}

.nav-link:hover { color: var(--primary-dark); }

#logout-btn { 
    background: none; border: none;
    color: var(--text-muted); 
    margin-top: auto; 
    font-size: 1rem; 
    font-weight: 600;
    cursor: pointer;
    text-align: left;
}
#logout-btn:hover { color: var(--danger); text-decoration: underline; }

#close-sidebar.close-btn { 
    background: none; border: none; 
    color: var(--text-muted); 
    align-self: flex-end; 
    margin-bottom: -1rem;
    margin-top: -1rem;
    cursor: pointer; 
    font-size: 2rem;
    line-height: 1;
}
#close-sidebar:hover { text-decoration: underline; }

/* ==========================================
   RESPONSIVO CELULAR (Móvil)
========================================== */
@media (max-width: 768px) {
    /* Ajustes generales del layout móvil */
    .view {
        padding: 1rem 0.5rem;
    }
    
    #view-login {
        margin: -1rem -0.5rem; /* Ajustar el margen negativo en celular */
        padding: 1.5rem;
    }
    
    /* Adaptar botones y barra */
    #global-navbar {
        padding: 0.75rem 1rem;
    }
    
    .floating-btn {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 3rem;
        height: 3rem;
        font-size: 1.75rem;
    }

    /* Modificar Tablas para Móvil: Reducir espacio pero mantener diseño HTML */
    .table-container {
        border-radius: 0.5rem;
        box-shadow: none; /* Carga más ligera */
        margin: 0;
    }
    
    table {
        min-width: 100%; /* Eliminar el scroll horizontal forzado de 800px */
    }
    
    th, td {
        padding: 0.75rem 0.5rem; /* Reducir márgenes internos de celdas */
        font-size: 0.8rem; /* Letras un poco más pequeñas */
        white-space: normal; /* Permitir que textos largos bajen de renglón en vez de estirar la tabla */
    }
    
    .col-time {
        font-size: 0.75rem;
    }
    
    .col-name {
        font-size: 0.85rem;
        max-width: 100px; /* Forzar wrap natural */
    }
    
    .col-status, .col-role {
        padding: 0.2rem 0.4rem;
        font-size: 0.6rem;
    }
    
    .col-total, .col-price {
        font-size: 0.9rem;
    }
    
    .col-desc {
        max-width: 100px;
    }
    
    .btn-outline {
        padding: 0.25rem 0.4rem;
        font-size: 0.7rem;
    }
    
    /* Botones de acción apretados */
    .btn-edit, .btn-del {
        margin-right: 0.4rem;
        font-size: 0.8rem;
    }
    
    /* Ajustar modales a 100% de pantalla */
    .modal-content {
        padding: 1.5rem;
        max-width: 100%;
        border-radius: 1rem;
    }
}