/* =================================================================
   1. ESTILOS BASE Y TIPOGRAFÍA
================================================================= */
body { 
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #333; 
    line-height: 1.6; 
    margin: 0; 
}
body.main-layout {
    background-color: #ecf0f5;
    padding: 0;
}
body.login-page {
    padding: 20px;
}
h2 { font-size: 24px; margin: 0 0 20px 0; font-weight: 400; color: #333; border-bottom: none; }
h3 { color: #333; }
h4 { margin-top: 0; font-weight: 600; }
a { text-decoration: none; }

/* =================================================================
   2. PÁGINA DE LOGIN
================================================================= */
body.login-page { 
    display: flex; justify-content: center; align-items: center; min-height: 100vh; 
    background: #f0f2f5; background-image: linear-gradient(135deg, #e6e9f0 0%, #eef1f5 100%); 
}
.login-form { background: #ffffff; padding: 40px; border-radius: 10px; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1); width: 100%; max-width: 400px; border-top: 4px solid #3c8dbc; }
.login-logo { text-align: center; margin-bottom: 20px; }
.login-form h2 { text-align: center; border-bottom: none; margin-bottom: 25px; color: #333; }
.login-form input[type="submit"] { width: 100%; transition: background-color 0.3s ease; font-weight: bold; }
.login-form input[type="submit"]:hover { background-color: #2980b9; opacity: 1; }

/* =================================================================
   3. LAYOUT PRINCIPAL (SIDEBAR + CONTENT)
================================================================= */
.main-wrapper { display: flex; }
.sidebar {
    width: 250px;
    background-color: #222d32;
    color: #b8c7ce;
    min-height: 100vh;
    transition: transform 0.3s ease-in-out;
    position: relative;
    z-index: 1001;
    flex-shrink: 0;
}
.content-wrapper { flex-grow: 1; display: flex; flex-direction: column; width: calc(100% - 250px); }
.top-bar { display: none; background-color: #3c8dbc; color: white; padding: 10px 15px; align-items: center; box-shadow: 0 2px 5px rgba(0,0,0,0.1); position: sticky; top: 0; z-index: 999; }
.top-bar h1 { font-size: 20px; margin: 0; padding: 0; border: none; color: white; }
.hamburger-btn { background: none; border: none; color: white; font-size: 20px; margin-right: 15px; cursor: pointer; }
.main-content { flex-grow: 1; padding: 20px; background-color: #ecf0f5; overflow-y: auto; }
.content-view { display: none; }
.content-view.active { display: block; animation: fadeIn 0.5s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* =================================================================
   4. ESTILOS DEL MENÚ LATERAL
================================================================= */
.sidebar-header { padding: 20px; background-color: #1a2226; text-align: center; }
.sidebar-header .user-info h4 { margin: 10px 0 5px 0; color: #fff; font-weight: 600; }
.sidebar-header .user-info p { margin: 0; font-size: 12px; }
.sidebar-header .user-info .status-dot { display: inline-block; width: 8px; height: 8px; background-color: #00a65a; border-radius: 50%; margin-right: 5px; }
.main-navigation { padding: 15px 0; border-bottom: 1px solid #1a2226; }
.main-navigation-header { padding: 0 15px 10px 15px; font-size: 12px; color: #4b646f; font-weight: bold; text-transform: uppercase; }
.sidebar-menu { list-style: none; margin: 0; padding: 0; }
.sidebar-menu li a { display: block; color: #b8c7ce; padding: 12px 15px; text-decoration: none; transition: background-color 0.2s, color 0.2s; border-left: 3px solid transparent; }
.sidebar-menu li a:hover, .sidebar-menu li.active > a { background-color: #1e282c; color: #fff; border-left-color: #3c8dbc; }
.sidebar-menu li a .fa-angle-down { float: right; transition: transform 0.2s; margin-top: 3px; }
.sidebar-menu li.active > a .fa-angle-down { transform: rotate(-180deg); }
.sidebar-menu li .fa { margin-right: 10px; width: 20px; text-align: center; }
.submenu { list-style: none; padding-left: 15px; background-color: #2c3b41; display: none; }
.sidebar-menu li.active .submenu { display: block; }
.submenu li a { padding: 10px 15px 10px 30px; font-size: 14px; }
.submenu li a:hover, .submenu li.active a { background-color: #35444b; border-left: none; }
.submenu li a::before { content: "\f10c"; font-family: "Font Awesome 6 Free"; font-weight: 400; margin-right: 8px; font-size: 8px; }
.submenu li.active a::before { font-weight: 900; }

/* =================================================================
   5. COMPONENTES GENERALES (Cajas, Tablas, Formularios, etc.)
================================================================= */
.container { max-width: 1200px; margin: auto; padding: 20px; }
.container > header { background-color: #fff; padding: 15px 20px; border-radius: 8px; box-shadow: 0 1px 1px rgba(0,0,0,0.1); display: flex; justify-content: space-between; align-items: center; border-bottom: none; margin-bottom: 20px; }
.container > header h1 { margin: 0; color: #333; }
.manage-link { display: inline-block; color: #3c8dbc; text-decoration: none; font-weight: bold; margin-left: 20px; }
.manage-link:hover { text-decoration: underline; }

.dashboard-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-box { display: block; color: white; padding: 20px; border-radius: 8px; position: relative; overflow: hidden; text-decoration: none; transition: transform 0.2s ease-in-out; }
.stat-box:hover { transform: translateY(-5px); text-decoration: none; color: white; }
.stat-box .inner { position: relative; z-index: 10; }
.stat-box h3 { font-size: 38px; font-weight: bold; margin: 0 0 5px 0; padding: 0; border: none; color: white; }
.stat-box p { font-size: 16px; margin: 0; }
.stat-box .icon { position: absolute; top: 50%; right: 20px; transform: translateY(-50%); font-size: 70px; color: rgba(0, 0, 0, 0.15); z-index: 1; transition: transform 0.3s ease; }
.stat-box:hover .icon { transform: translateY(-50%) scale(1.1); }
.stat-box-footer { position: absolute; bottom: 0; left: 0; width: 100%; text-align: center; padding: 5px 0; background-color: rgba(0, 0, 0, 0.1); font-size: 14px; }
.bg-blue { background-color: #0073b7; }
.bg-green { background-color: #00a65a; }
.bg-orange { background-color: #f39c12; }
.bg-red { background-color: #dd4b39; }
.bg-grey { background-color: #6c757d; }

.quick-lists-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; margin-top: 30px; }
.quick-list { background-color: #fff; border-radius: 8px; padding: 20px; box-shadow: 0 1px 1px rgba(0,0,0,0.1); }
.quick-list h4 { margin-top: 0; font-weight: 600; border-bottom: 1px solid #f4f4f4; padding-bottom: 10px; margin-bottom: 10px; }
.quick-list h4 .fas { margin-right: 8px; }
.quick-list ul { list-style: none; padding: 0; margin: 0; max-height: 250px; overflow-y: auto; }
.quick-list li { display: flex; justify-content: space-between; padding: 8px 5px; border-bottom: 1px solid #f4f4f4; font-size: 14px; }
.quick-list li:last-child { border-bottom: none; }
.quick-list .date { font-weight: bold; color: #555; }
.icon-red { color: #dd4b39; }
.icon-orange { color: #f39c12; }
.quick-list-action { margin-top: 15px; text-align: center; }

.form-container { background: #fff; box-shadow: 0 1px 1px rgba(0,0,0,0.1); border-radius: 4px; padding: 25px; max-width: 600px; }
input[type="text"], input[type="password"], input[type="email"], input[type="tel"], input[type="date"], select, .search-box, textarea { width: 100%; padding: 10px; margin-bottom: 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; font-size: 16px; font-family: 'Poppins', sans-serif; }
button, input[type="submit"] { background-color: #3c8dbc; color: white; padding: 10px 15px; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; transition: background-color 0.2s; }
button:hover, input[type="submit"]:hover { background-color: #2a6a9b; opacity: 1; }
.form-container label { display: block; margin-top: 15px; font-weight: 600; }
.panels-container.four-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.table-container { background: #fff; padding: 20px; border-radius: 4px; box-shadow: 0 1px 1px rgba(0,0,0,0.1); width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid #ddd; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; border: 1px solid #ddd; text-align: left; white-space: nowrap; }
th { background-color: #f2f2f2; font-weight: 600; }
tr:nth-child(even) { background-color: #f9f9f9; }

.filter-container { background: #fff; padding: 15px; border-radius: 4px; margin-bottom: 20px; border: 1px solid #dee2e6; box-shadow: 0 1px 1px rgba(0,0,0,0.1); }
.filter-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 15px; }
.filter-form .form-group { display: flex; flex-direction: column; }
.filter-form .form-group label { margin-bottom: 5px; font-size: 14px; font-weight: bold; color: #495057; }
.filter-form .form-group .search-box, .filter-form .form-group select { margin-bottom: 0; }
.filter-form .form-actions { display: flex; gap: 10px; }
.search-btn { background-color: #3c8dbc; }
.clear-btn { padding: 10px 15px; background-color: #7f8c8d; color: white; border: none; border-radius: 4px; cursor: pointer; text-decoration: none; display: inline-block; font-size: 16px; line-height: 1.5; text-align: center; }
.clear-btn:hover { background-color: #95a5a6; color: white; }
.action-btn {
    padding: 5px 10px;
    border-radius: 4px;
    text-decoration: none;
    color: white;
    font-size: 14px;
    border: none;
    cursor: pointer;
    vertical-align: middle;
    background-color: #3c8dbc; /* LÍNEA AÑADIDA: Color de fondo azul por defecto */
}
.action-btn.activar, .action-btn.notificar { background-color: #00a65a; }
.action-btn.editar, .action-btn.notificar-expirado { background-color: #f39c12; }
.action-btn.borrar, .cancel-btn { background-color: #dd4b39; }
.action-btn.whatsapp { background-color: #25D366; padding: 5px 9px; }
.cancel-btn { border-radius: 50%; width: 24px; height: 24px; font-size: 16px; line-height: 24px; text-align: center; padding: 0; font-weight: bold; }

.mensaje { padding: 15px; margin-bottom: 20px; border-radius: 5px; }
.mensaje.exito { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.mensaje.error { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.status-expirado { color: #dd4b39; font-weight: bold; }
.status-activo { color: #00a65a; font-weight: bold; }
.status-pending { display: flex; align-items: center; justify-content: space-between; }

.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.6); }
.modal-content { background-color: #fefefe; margin: 10% auto; padding: 20px 30px; border: 1px solid #888; width: 80%; max-width: 500px; border-radius: 8px; position: relative; box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2); }
.close-btn { color: #aaa; float: right; font-size: 28px; font-weight: bold; cursor: pointer; }
.anuncio-contenido { line-height: 1.6; }
.anuncio-contenido h3 { margin: 1.5em 0 0.5em 0; }
.anuncio-contenido p { margin: 0 0 1em 0; }

.import-section { background-color: #fff; border-radius: 4px; padding: 20px; margin-bottom: 30px; box-shadow: 0 1px 1px rgba(0,0,0,0.1); }
.import-container { display: flex; gap: 30px; flex-wrap: wrap; }
.import-step { flex: 1; min-width: 250px; }

/* --- ESTILOS RESTAURADOS PARA PAGINACIÓN Y BOTÓN WHATSAPP --- */
.pagination { margin-top: 20px; text-align: center; }
.pagination a { color: #3c8dbc; padding: 8px 16px; text-decoration: none; border: 1px solid #ddd; margin: 0 4px; border-radius: 4px; transition: background-color .3s; }
.pagination a.active { background-color: #3c8dbc; color: white; border-color: #3c8dbc; }
.pagination a:hover:not(.active) { background-color: #f2f2f2; }
.whatsapp-btn { display: inline-block; padding: 8px 12px; background-color: #25D366; color: white; border-radius: 5px; text-decoration: none; font-weight: bold; margin-left: 15px; vertical-align: middle; }
.whatsapp-btn:hover { background-color: #128C7E; color: white; }

/* =================================================================
   6. LÓGICA RESPONSIVA FINAL
================================================================= */
@media screen and (max-width: 992px) {
    body:not(.login-page) { padding: 0; }
    .main-wrapper { flex-direction: column; }
    .sidebar { position: fixed; height: 100%; transform: translateX(-250px); box-shadow: 0 0 15px rgba(0,0,0,0.3); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .top-bar { display: flex; }
    .content-wrapper { width: 100%; margin-left: 0; }
    .overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); z-index: 1000; }
    body.sidebar-open .overlay { display: block; }
    .container > header { display: none; }
    .panels-container.four-panels { grid-template-columns: 1fr; }
}
/* --- Ajuste para 3 columnas en Quick Lists --- */
.quick-lists-container.three-columns {
    /* En pantallas grandes, usamos 3 columnas */
    grid-template-columns: repeat(3, 1fr);
}

/* Icono verde para la nueva lista */
.icon-green { color: #00a65a; }

/* En pantallas más pequeñas, volvemos a una sola columna */
@media screen and (max-width: 992px) {
    .quick-lists-container.three-columns {
        grid-template-columns: 1fr;
    }
}
/* --- Estilos para Notificaciones en Tiempo Real --- */
.top-bar {
    display: flex;
    justify-content: space-between; /* Alinea los elementos a los extremos */
    align-items: center;
}
.top-bar-right {
    position: relative;
}
.notification-area a {
    color: white;
    font-size: 20px;
    position: relative;
    padding: 10px;
}
.notification-area .badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: #dd4b39; /* Rojo */
    color: white;
    font-size: 10px;
    font-weight: bold;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 1;
}
.notification-dropdown {
    display: none; /* Oculto por defecto */
    position: absolute;
    right: 0;
    top: 100%;
    width: 320px;
    background-color: #fff;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    border-radius: 4px;
    color: #333;
    z-index: 1010;
}
.notification-dropdown.show {
    display: block;
}
.notification-dropdown .dropdown-header {
    padding: 10px 15px;
    font-weight: bold;
    border-bottom: 1px solid #eee;
}
.notification-dropdown .dropdown-body {
    max-height: 300px;
    overflow-y: auto;
}
.notification-dropdown .notification-item {
    display: block;
    padding: 10px 15px;
    font-size: 14px;
    border-bottom: 1px solid #f4f4f4;
    color: #555;
    text-decoration: none;
    white-space: normal;
}
.notification-dropdown .notification-item:hover {
    background-color: #f9f9f9;
}
.notification-item .notification-text {
    display: block;
}
.notification-item .notification-user {
    font-weight: bold;
}