/* ========================================= */
/* VARIABLES DE COLOR (PALETA JW)            */
/* ========================================= */
:root {
    /* Color principal basado en la imagen */
    --jw-purple: #5a3b8c;
    --jw-purple-dark: #412a66;
    --jw-purple-light: #7b58b5;
    
    /* Colores neutrales y fondos */
    --bg-body: #f4f5f8;
    --bg-card: #ffffff;
    --text-main: #333333;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    
    /* Colores de estado (Minimizados para ser elegantes) */
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;

    /* Diseño general */
    --radius: 10px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-hover: 0 10px 15px -3px rgba(0,0,0,0.1);
    
    /* Tipografía nativa (Se adapta a iOS, Android y Windows) */
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ========================================= */
/* RESETEO Y CUERPO PRINCIPAL                */
/* ========================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }

body { 
    font-family: var(--font-family); 
    background-color: var(--bg-body); 
    color: var(--text-main); 
    line-height: 1.6; 
    padding: 20px;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { color: var(--jw-purple); font-weight: 600; margin-bottom: 15px; }

/* ========================================= */
/* CONTENEDORES                              */
/* ========================================= */
.container, .login-container, .form-container { 
    width: 100%; 
    max-width: 1000px; 
    margin: 0 auto; 
    background: var(--bg-card); 
    padding: 30px; 
    border-radius: var(--radius); 
    box-shadow: var(--shadow-sm); 
    border: 1px solid var(--border-color);
}
.login-container, .form-container { max-width: 450px; margin-top: 4vh; }

/* ========================================= */
/* FORMULARIOS (Inputs y Selects)            */
/* ========================================= */
.form-group { margin-bottom: 20px; text-align: left; }
label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 14px; color: var(--text-main); }

input, select, textarea { 
    width: 100%; 
    padding: 12px 15px; 
    border: 1px solid var(--border-color); 
    border-radius: 8px; 
    font-size: 16px; /* 16px evita el zoom automático en iPhone */
    background-color: #fcfcfc;
    color: var(--text-main);
    transition: all 0.3s ease;
    font-family: inherit;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--jw-purple);
    background-color: var(--bg-card);
    box-shadow: 0 0 0 3px rgba(90, 59, 140, 0.15); /* Anillo de enfoque morado */
}

/* Bloques condicionales de cantidad */
.cantidad-group { display: none; margin-top: 12px; padding-left: 15px; border-left: 3px solid var(--jw-purple); }

/* ========================================= */
/* BOTONES Y ENLACES (Todos como botones)    */
/* ========================================= */
button, .btn { 
    display: inline-block;
    width: 100%;
    padding: 12px 20px; 
    border: none; 
    border-radius: 8px; 
    font-size: 16px; 
    font-weight: 600;
    text-align: center;
    text-decoration: none; 
    cursor: pointer; 
    transition: all 0.2s ease;
    /* Color por defecto: Morado JW */
    background-color: var(--jw-purple);
    color: #ffffff;
    margin-bottom: 10px;
}

button:hover, .btn:hover { background-color: var(--jw-purple-dark); transform: translateY(-1px); }
button:active, .btn:active { transform: translateY(1px); }

/* Variantes de Botones */
.btn-primary { background-color: var(--jw-purple); }
.btn-success { background-color: var(--success); }
.btn-success:hover { background-color: #059669; }
.btn-danger { background-color: var(--danger); }
.btn-danger:hover { background-color: #dc2626; }
.btn-warning { background-color: var(--warning); color: #fff; }

/* Botón secundario (Estilo contorno, ideal para "Volver" o "Cancelar") */
.btn-outline {
    background-color: transparent;
    color: var(--jw-purple);
    border: 1.5px solid var(--jw-purple);
}
.btn-outline:hover { background-color: rgba(90, 59, 140, 0.05); color: var(--jw-purple-dark); }

/* Para alinear botones lado a lado en PC */
.botones-inline { display: flex; gap: 10px; flex-wrap: wrap; }
.botones-inline .btn { width: auto; flex: 1; }

/* Botón de WhatsApp */
.btn-whatsapp { 
    background-color: #25D366; 
    color: white; 
    padding: 8px 15px; 
    font-size: 14px;
    width: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-whatsapp:hover { background-color: #1DA851; }

/* ========================================= */
/* DASHBOARD Y TARJETAS                      */
/* ========================================= */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-top: 20px; }

.card { 
    background: var(--bg-card); 
    border: 1px solid var(--border-color); 
    border-top: 4px solid var(--jw-purple); /* Acento superior */
    border-radius: var(--radius); 
    padding: 25px 20px; 
    text-align: center; 
    transition: all 0.3s ease; 
    box-shadow: var(--shadow-sm);
}
.card h3 { font-size: 16px; color: var(--text-muted); margin-bottom: 10px; font-weight: 500; }
.card p { font-size: 32px; font-weight: 700; color: var(--jw-purple); }

.clickable-card { cursor: pointer; }
.clickable-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); border-top-color: var(--jw-purple-light); }

/* ========================================= */
/* TABLAS PROFESIONALES                      */
/* ========================================= */
.table-responsive { width: 100%; overflow-x: auto; margin-top: 20px; border-radius: var(--radius); border: 1px solid var(--border-color); background: var(--bg-card); }
table { width: 100%; border-collapse: collapse; min-width: 700px; }
th, td { border-bottom: 1px solid var(--border-color); padding: 15px; text-align: left; font-size: 14px; }
th { background-color: #f9fafb; font-weight: 600; color: var(--text-muted); text-transform: uppercase; font-size: 12px; letter-spacing: 0.5px; }
tr:last-child td { border-bottom: none; }
tr:hover { background-color: #f9fafb; }

/* ========================================= */
/* FILTROS Y CABECERAS                       */
/* ========================================= */
.header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); padding-bottom: 15px; margin-bottom: 25px; flex-wrap: wrap; gap: 15px; }

.filtros-container { 
    background: #f9fafb; 
    padding: 20px; 
    border-radius: var(--radius); 
    display: flex; 
    gap: 15px; 
    align-items: flex-end; 
    margin-bottom: 25px; 
    flex-wrap: wrap; 
    border: 1px solid var(--border-color);
}
.filtros-container div { flex: 1; min-width: 200px; }
.filtros-container button { margin-bottom: 0; width: auto; }

/* ========================================= */
/* MODAL (Ventanas Emergentes)               */
/* ========================================= */
.modal { display: none; position: fixed; z-index: 100; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(17, 24, 39, 0.6); backdrop-filter: blur(4px); }
.modal-content { background-color: var(--bg-card); margin: 10vh auto; padding: 30px; border-radius: var(--radius); width: 90%; max-width: 500px; max-height: 80vh; overflow-y: auto; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1); }
.close { color: var(--text-muted); float: right; font-size: 28px; font-weight: bold; cursor: pointer; line-height: 1; transition: color 0.2s; }
.close:hover { color: var(--danger); }
.lista-pendientes { list-style: none; padding: 0; margin-top: 15px; }
.lista-pendientes li { padding: 12px 0; border-bottom: 1px solid var(--border-color); }
.lista-pendientes li:last-child { border-bottom: none; }

/* Mensajes Flash / Alertas */
.alert { padding: 15px; border-radius: 8px; margin-bottom: 20px; font-weight: 500; font-size: 14px; }
.alert-success { background-color: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background-color: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ========================================= */
/* MEDIA QUERIES (CELULARES Y TABLETS)       */
/* ========================================= */
@media (max-width: 768px) {
    body { padding: 10px; }
    .container, .login-container, .form-container { padding: 20px; border-radius: 12px; }
    
    .header { flex-direction: column; text-align: center; }
    
    /* En celulares, todos los botones ocupan el 100% de ancho para fácil toque */
    .btn, button { width: 100% !important; margin-right: 0; margin-bottom: 12px; padding: 14px 20px; }
    .botones-inline { flex-direction: column; gap: 0; }
    
    .filtros-container { flex-direction: column; align-items: stretch; padding: 15px; }
    .filtros-container div { width: 100%; }
    
    .cards { grid-template-columns: 1fr; gap: 15px; }
    
    /* Para perfil: secciones pegadas */
    .seccion-perfil { padding: 15px; }
}

/* =========================================
   NUEVO LAYOUT PROFESIONAL (SIDEBAR)
   ========================================= */

/* Paleta de colores sobrios */
:root {
    --bg-app: #f4f7f6; /* Gris muy claro para el fondo */
    --sidebar-bg: #1e2b3c; /* Azul/Gris oscuro muy elegante */
    --sidebar-text: #a5b4cb;
    --sidebar-hover: #2c3e50;
    --primary-blue: #3b82f6; /* Azul profesional para acentos */
}

/* Contenedor principal */
.app-container {
    display: flex;
    min-height: 100vh;
    background-color: var(--bg-app);
}

/* Sidebar (Menú Lateral) */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: white;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
}

.sidebar-header {
    padding: 20px;
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    color: white;
    letter-spacing: 1px;
}

.sidebar-nav {
    flex-grow: 1;
    padding-top: 15px;
    overflow-y: auto;
}

.sidebar-link {
    display: block;
    padding: 12px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    font-size: 14px;
}

.sidebar-link:hover, .sidebar-link.active {
    background-color: var(--sidebar-hover);
    color: white;
    border-left-color: var(--primary-blue);
}

/* Contenido Principal */
.main-content {
    flex-grow: 1;
    margin-left: 260px; /* Deja espacio para el menú lateral */
    padding: 20px;
    transition: margin-left 0.3s ease;
    width: calc(100% - 260px);
}

/* Barra superior limpia (Topbar) */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

/* Botón Hamburguesa para Móviles */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-main);
    padding: 0;
}

/* Overlay oscuro para móviles */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

/* --- MAGIA RESPONSIVE (CELULARES Y TABLETS) --- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%); /* Oculto por defecto en celular */
    }
    .sidebar.active {
        transform: translateX(0); /* Se muestra al presionar el botón */
    }
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 15px;
    }
    .menu-toggle {
        display: block; /* Aparece el botón hamburguesa */
    }
    .sidebar-overlay.active {
        display: block; /* Aparece la sombra de fondo */
    }
}

/* Limpieza de tarjetas para que se vean más corporativas */
.card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
