/* assets/css/style.css */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #161e33;
    --primary-light: #242f4c;
    --white: #ffffff;
    --light-bg: #f5f7fa;
    --text-color: #333333;
    --text-muted: #888888;
    --red-alert: #e63946;
    --green-success: #2a9d8f;
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

body {
    background-color: var(--light-bg);
    color: var(--text-color);
    min-height: 100vh;
}

/* --- REGLA DE SEGURIDAD PARA SVGS --- */
svg {
    width: 24px;
    height: 24px;
    max-width: 100%;
    display: inline-block;
    flex-shrink: 0; /* Evita que el SVG se deforme o achique */
}

/* --- CONTENEDOR DEL LOGIN --- */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 100vh;
    padding: 20px;
    background-color: var(--primary-color);
}

.login-card {
    background-color: var(--white);
    padding: 40px;
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 420px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    text-align: center;
    animation: fadeIn 0.6s ease;
}

.login-logo {
    width: 190px;
    height: auto;
    margin-bottom: 10px;
    border-radius: 50%;
    border: 3px solid var(--primary-color);
    padding: 5px;
    position: relative;
    top: -15px;
    left: -12px;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 15px;
    fill: var(--text-muted);
    width: 18px;
    height: 18px;
}

.form-input {
    width: 100%;
    padding: 14px 15px 14px 45px;
    border: 1.5px solid #e2e8f0;
    border-radius: var(--border-radius);
    font-size: 14px;
    outline: none;
    transition: var(--transition);
}

.form-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(22, 30, 51, 0.1);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    background-color: var(--primary-light);
    transform: translateY(-1px);
}

.alert-error {
    background-color: #ffeef0;
    color: var(--red-alert);
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 20px;
    text-align: left;
    border-left: 4px solid var(--red-alert);
}

/* --- ESTRUCTURA GENERAL DEL APP (LAYOUT) --- */
.app-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
    position: relative;
}

/* Sidebar Estilo Desktop */
.sidebar {
    width: 260px;
    background-color: var(--primary-color);
    color: var(--white);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    flex-shrink: 0;
    transition: var(--transition);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header {
    display: flex;
    align-items: center;
    padding: 0 24px;
    margin-bottom: 25px;
}

.sidebar-logo {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    margin-right: 12px;
    border: 1.5px solid rgba(255,255,255,0.2);
}

.sidebar-brand {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.user-profile-info {
    padding: 0 24px;
    margin-bottom: 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 15px;
}

.profile-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-role {
    font-size: 11px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 20px;
    display: inline-block;
    margin-top: 4px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0 12px;
}

.nav-link {
    display: flex;
    align-items: center;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 8px;
    transition: var(--transition);
}

.nav-link svg {
    width: 20px;
    height: 20px;
    fill: rgba(255, 255, 255, 0.7);
    margin-right: 15px;
}

.nav-link span {
    font-size: 14px;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--white);
}

.nav-link:hover svg {
    fill: var(--white);
}

.nav-link.active {
    background-color: var(--white);
    color: var(--primary-color);
    font-weight: 500;
}

.nav-link.active svg {
    fill: var(--primary-color);
}

.nav-link-logout {
    color: #ff6b6b;
}
.nav-link-logout svg {
    fill: #ff6b6b;
}
.nav-link-logout:hover {
    background-color: rgba(255, 107, 107, 0.1);
}

/* Área de contenido principal */
.main-content {
    flex-grow: 1;
    background-color: var(--light-bg);
    padding: 30px;
    overflow-y: auto;
    width: calc(100% - 260px);
}

/* Botón Hamburguesa Móvil */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 15px;
    right: 15px;
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    z-index: 999;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.mobile-toggle svg {
    width: 24px;
    height: 24px;
    fill: var(--white);
}

/* --- ELEMENTOS DE DASHBOARD --- */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.content-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--primary-color);
}

.welcome-msg {
    font-size: 14px;
    color: var(--text-muted);
}

/* Rejilla de Tarjetas métricas (KPIs) */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 35px;
}

.metric-card {
    background-color: var(--white);
    border-radius: var(--border-radius);
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    border-left: 5px solid var(--primary-color);
    transition: var(--transition);
}

.metric-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.06);
}

.metric-info h3 {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.metric-info p {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.metric-icon-container {
    background-color: rgba(22, 30, 51, 0.05);
    padding: 12px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
}

.metric-icon-container svg {
    width: 24px;
    height: 24px;
    fill: var(--primary-color);
}

.card-blue { border-left-color: var(--primary-color); }
.card-green { border-left-color: var(--green-success); }
.card-red { border-left-color: var(--red-alert); }
.card-orange { border-left-color: #f39c12; }

/* Dashboard Layout Columnas */
.dashboard-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 25px;
}

.card-panel {
    background-color: var(--white);
    border-radius: var(--border-radius);
    padding: 25px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

.panel-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-title svg {
    width: 20px;
    height: 20px;
    fill: var(--primary-color);
}

/* Tablas */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

.custom-table th {
    background-color: #f8fafc;
    color: var(--primary-color);
    font-weight: 600;
    padding: 16px;
    border-bottom: 2px solid #edf2f7;
}

.custom-table td {
    padding: 16px;
    border-bottom: 1px solid #edf2f7;
    color: #4a5568;
}

.custom-table tr:hover {
    background-color: #fcfdfe;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
}

.badge-reçu { background-color: #ebf8ff; color: #2b6cb0; }
.badge-en-cours { background-color: #fef3c7; color: #d97706; }
.badge-terminé { background-color: #ecfdf5; color: #059669; }

.badge-livré { background-color: #eff6ff; color: #1d4ed8; }
.badge-récupéré { background-color: #f5f3ff; color: #6d28d9; }

/* Botones */
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background-color: var(--white);
    color: var(--primary-color);
    border: 1.5px solid var(--primary-color);
    padding: 10px 18px;
    border-radius: var(--border-radius);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    background-color: var(--primary-color);
    color: var(--white);
}

.btn-secondary svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* --- ANIMACIÓN --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- DISEÑO RESPONSIVO --- */
@media (max-width: 992px) {
    .dashboard-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .mobile-toggle {
        display: block;
    }
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        z-index: 998;
        box-shadow: 5px 0 15px rgba(0,0,0,0.1);
    }
    .sidebar.active {
        left: 0;
    }
    .main-content {
        width: 100%;
        padding: 80px 15px 20px 15px;
    }
}

/* --- MODALES Y FORMULARIOS DE REGISTRO --- */

/* Fondo del Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(16, 24, 40, 0.4);
    backdrop-filter: blur(4px); /* Efecto difuminado de fondo */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Caja de contenido del Modal */
/* Caja de contenido del Modal (Reducida, bordes muy redondeados y con scroll) */
.modal-box {
    background-color: var(--white);
    border-radius: 20px; /* Bordes más redondeados */
    width: 100%;
    max-width: 430px; /* Reducimos el ancho para que sea más compacto */
    max-height: 80vh; /* Altura máxima del 80% de la pantalla */
    overflow-y: auto; /* Activa el scroll (ascensor) si el contenido es muy alto */
    padding: 24px; /* Padding más compacto */
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

/* Estilo elegante y redondeado para el "ascensor" (barra de desplazamiento) */
.modal-box::-webkit-scrollbar {
    width: 6px;
}
.modal-box::-webkit-scrollbar-track {
    background: transparent;
}
.modal-box::-webkit-scrollbar-thumb {
    background-color: rgba(22, 30, 51, 0.2); /* Color del scroll acorde a la app */
    border-radius: 10px;
}
.modal-box::-webkit-scrollbar-thumb:hover {
    background-color: rgba(22, 30, 51, 0.4);
}

.modal-overlay.active .modal-box {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-close svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

/* Campos de Formulario */
.form-select {
    width: 100%;
    padding: 12px 15px;
    border: 1.5px solid #e2e8f0;
    border-radius: var(--border-radius);
    font-size: 14px;
    outline: none;
    background-color: var(--white);
    transition: var(--transition);
}

.form-select:focus {
    border-color: var(--primary-color);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 25px;
}

/* Botón de Agregar Principal */
.btn-add {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    padding: 12px 20px;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-add:hover {
    background-color: var(--primary-light);
}

.btn-add svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Botones de acción dentro de tablas */
.btn-delete {
    background: none;
    border: none;
    color: var(--red-alert);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    padding: 5px;
    border-radius: 6px;
    transition: var(--transition);
}

.btn-delete:hover {
    background-color: rgba(230, 57, 70, 0.1);
}

.btn-delete svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* --- FILTROS DE BÚSQUEDA --- */
.filter-row {
    display: flex;
    gap: 15px;
    background-color: var(--white);
    padding: 15px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 25px;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--primary-color);
}

.filter-input {
    padding: 8px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    background-color: var(--white);
}

/* Enlace telefónico táctil */
.phone-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.phone-link:hover {
    text-decoration: underline;
}

.phone-link svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Selectores rápidos para Repartidores */
.quick-select {
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 1.5px solid #edf2f7;
    outline: none;
    cursor: pointer;
    background-color: var(--white);
    transition: var(--transition);
}

.quick-select-statut.reçu { color: #2b6cb0; background-color: #ebf8ff; }
.quick-select-statut.en-cours { color: #d97706; background-color: #fef3c7; }
.quick-select-statut.terminé { color: #059669; background-color: #ecfdf5; }

.quick-select-avoir.livré { color: #1d4ed8; background-color: #eff6ff; }
.quick-select-avoir.récupéré { color: #6d28d9; background-color: #f5f3ff; }