@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css');
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

:root {
    --ws-bg: #f8fafc;
    --ws-surface: #ffffff;
    --ws-border: #e2e8f0;
    --ws-primary: #1a73e8; /* Azul Google */
    --ws-primary-hover: #1557b0;
    --ws-text-main: #1f1f1f;
    --ws-text-muted: #5f6368;
    --ces-dark: #0d2c54;
}

/* CONFIGURACIÓN PARA FOOTER SIEMPRE ABAJO (STICKY FOOTER) */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body { 
    display: flex;
    flex-direction: column;
    font-family: 'Roboto', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; 
    background-color: var(--ws-bg);
    color: var(--ws-text-main);
    -webkit-font-smoothing: antialiased;
}

/* BARRA SUPERIOR ESTILO GOOGLE APP BAR */
.navbar { 
    background-color: var(--ws-surface); 
    color: var(--ws-text-main); 
    height: 64px;
    padding: 0 24px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    border-bottom: 1px solid var(--ws-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar-brand img {
    height: 64px;
    object-fit: contain;
}

.navbar-brand span {
    font-size: 18px;
    font-weight: 400;
    color: var(--ws-text-main);
}

/* BUSCADOR INTEGRADO CENTRAL (ESTILO GMAIL/DRIVE) */
.search-container-center {
    flex: 0 1 600px;
    margin: 0 20px;
}

.search-bar-ws {
    background-color: #f1f3f4;
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-radius: 8px;
    height: 46px;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.search-bar-ws:focus-within {
    background-color: var(--ws-surface);
    box-shadow: 0 1px 3px rgba(60,64,67,0.3), 0 4px 8px 3px rgba(60,64,67,0.15);
}

.search-bar-ws input {
    background: none;
    border: none;
    width: 100%;
    height: 100%;
    font-size: 15px;
    color: var(--ws-text-main);
    outline: none;
    padding-left: 12px;
}

/* MENÚ DE USUARIO */
.user-menu-container { 
    position: relative; 
}

.user-menu-btn { 
    background: none; 
    border: none; 
    font-size: 14px; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    padding: 6px 12px; 
    border-radius: 50px;
    border: 1px solid var(--ws-border);
    color: var(--ws-text-muted);
    transition: background 0.2s;
}

.user-menu-btn:hover { 
    background-color: #f1f3f4; 
}

.dropdown-content { 
    display: none; 
    position: absolute; 
    right: 0; 
    background-color: var(--ws-surface); 
    min-width: 220px; 
    box-shadow: 0 4px 16px rgba(0,0,0,0.12); 
    border-radius: 8px; 
    z-index: 10; 
    margin-top: 8px; 
    border: 1px solid var(--ws-border); 
    overflow: hidden;
}

.dropdown-header {
    padding: 12px 16px;
    background-color: #fafafa;
    border-bottom: 1px solid var(--ws-border);
}

.dropdown-header span {
    display: block;
    font-size: 11px;
    color: var(--ws-text-muted);
    margin-top: 2px;
}

.dropdown-content a, 
.dropdown-content button { 
    color: var(--ws-text-main); 
    padding: 12px 16px; 
    text-decoration: none; 
    display: flex; 
    align-items: center;
    gap: 10px;
    font-size: 14px; 
    width: 100%; 
    text-align: left; 
    background: none; 
    border: none; 
    box-sizing: border-box;
    font-family: inherit; 
    cursor: pointer; 
}

.dropdown-content a:hover, 
.dropdown-content button:hover { 
    background-color: #f1f3f4; 
}

.show { 
    display: block; 
}

/* CONTENEDOR PRINCIPAL */
.main-content { 
    padding: 24px; 
    max-width: 1500px; 
    margin: 0 auto; 
    box-sizing: border-box;
    width: 100%;
    flex: 1 0 auto; /* Empuja el footer hacia abajo */
}

/* CUADROS RESUMEN (KPI CARDS) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--ws-surface);
    border: 1px solid var(--ws-border);
    border-radius: 8px;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.stat-card .stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--ws-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 400;
    margin-top: 8px;
    color: var(--ws-text-main);
}

/* BARRA DE HERRAMIENTAS Y FILTROS */
.filter-toolbar { 
    background: var(--ws-surface); 
    padding: 12px 20px; 
    border-radius: 8px 8px 0 0; 
    border: 1px solid var(--ws-border); 
    border-bottom: none;
    display: flex; 
    flex-wrap: wrap;
    gap: 16px; 
    align-items: center; 
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-size: 13px;
    color: var(--ws-text-muted);
    font-weight: 500;
}

.filter-group select {
    background-color: var(--ws-surface);
    border: 1px solid var(--ws-border);
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--ws-text-main);
    outline: none;
    cursor: pointer;
    min-width: 140px;
}

.filter-group select:focus {
    border-color: var(--ws-primary);
}

/* CONTENEDOR TABLA MATERIAL */
.data-table-container {
    background: var(--ws-surface);
    border: 1px solid var(--ws-border);
    border-radius: 0 0 8px 8px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(60,64,67,0.05);
}

table { 
    width: 100%; 
    border-collapse: collapse; 
    text-align: left;
}

th { 
    background: #f8fafc; 
    color: var(--ws-text-muted); 
    font-weight: 500; 
    font-size: 13px; 
    padding: 14px 18px; 
    border-bottom: 1px solid var(--ws-border);
}

td { 
    padding: 14px 18px; 
    border-bottom: 1px solid var(--ws-border); 
    color: var(--ws-text-main);
    font-size: 14px;
    vertical-align: middle;
}

tr:hover td {
    background-color: #fdfdfd;
}

/* BADGES ESTILO MATERIAL */
.badge { 
    padding: 4px 10px; 
    border-radius: 4px; 
    font-size: 12px; 
    font-weight: 500; 
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.badge-pendiente { background-color: #fef3c7; color: #b45309; }
.badge-aprobado { background-color: #d1fae5; color: #065f46; }
.badge-rechazado { background-color: #fee2e2; color: #991b1b; }

.txt-rut { 
    font-family: monospace; 
    font-size: 13px; 
    color: #475569; 
    background: #f1f5f9; 
    padding: 2px 6px; 
    border-radius: 4px; 
}

/* BOTONES ACCIÓN */
.btn-action { 
    padding: 6px 12px; 
    font-size: 13px; 
    font-weight: 500;
    border-radius: 4px; 
    color: var(--ws-primary); 
    text-decoration: none; 
    background-color: transparent; 
    border: 1px solid var(--ws-border);
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-action:hover { 
    background-color: rgba(26, 115, 232, 0.04);
    border-color: var(--ws-primary);
}

/* PAGINACIÓN MATERIAL */
.pagination-container { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 14px 20px; 
    background: var(--ws-surface); 
    border-top: 1px solid var(--ws-border); 
}

.pagination-info {
    font-size: 13px; 
    color: var(--ws-text-muted);
}

.pagination-list { 
    display: flex; 
    gap: 4px; 
    list-style: none; 
    margin: 0;
    padding: 0;
}

.pagination-item a { 
    padding: 6px 12px; 
    border: 1px solid var(--ws-border); 
    border-radius: 4px; 
    text-decoration: none; 
    color: var(--ws-text-main); 
    font-size: 13px; 
    display: block;
}

.pagination-item:hover a {
    background-color: #f1f3f4;
}

.pagination-item.active a { 
    background-color: var(--ws-primary); 
    color: #fff; 
    border-color: var(--ws-primary); 
}

.pagination-item.disabled { 
    opacity: 0.4; 
    pointer-events: none; 
}

/* MODAL ESTILO GOOGLE DIALOG */
.modal { 
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0; 
    top: 0; 
    width: 100%; 
    height: 100%; 
    background-color: rgba(31,31,31,0.5); 
    align-items: center; 
    justify-content: center; 
    backdrop-filter: blur(2px); 
}

.modal-content { 
    background-color: #fff; 
    padding: 24px; 
    border-radius: 8px; 
    width: 100%; 
    max-width: 420px; 
    box-shadow: 0 24px 38px 3px rgba(0,0,0,0.14); 
    animation: scaleUp 0.2s ease; 
    box-sizing: border-box; 
}

@keyframes scaleUp { 
    from { transform: scale(0.95); opacity: 0; } 
    to { transform: scale(1); opacity: 1; } 
}

.form-group { 
    margin-bottom: 16px; 
    display: flex; 
    flex-direction: column; 
    gap: 6px; 
}

.form-group label { 
    display: block; 
    font-size: 12px; 
    color: var(--ws-text-muted); 
    font-weight: 500; 
    text-transform: uppercase; 
    letter-spacing: 0.3px; 
}

.form-group input { 
    width: 100%; 
    padding: 10px 12px; 
    border: 1px solid var(--ws-border); 
    border-radius: 4px; 
    box-sizing: border-box; 
    font-size: 14px; 
    outline: none; 
    transition: border-color 0.15s; 
}

.form-group input:focus { 
    border-color: var(--ws-primary); 
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.15); 
}

.btn { 
    padding: 8px 16px; 
    font-size: 14px; 
    font-weight: 500; 
    border-radius: 4px; 
    cursor: pointer; 
    border: none; 
}

.btn-secondary { 
    background: none; 
    color: var(--ws-text-muted); 
}

.btn-secondary:hover { 
    background-color: #f1f3f4; 
}

.btn-primary { 
    background-color: var(--ws-primary); 
    color: #fff; 
}

.btn-primary:hover { 
    background-color: var(--ws-primary-hover); 
}

.modal-overlay { 
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(31, 31, 31, 0.5); 
    backdrop-filter: blur(2px); 
    z-index: 9999; 
    justify-content: center; 
    align-items: center; 
}

.modal-container { 
    background: #fff; 
    border-radius: 8px; 
    width: 90%; 
    max-width: 650px; 
    box-shadow: 0 24px 38px 3px rgba(0,0,0,0.14); 
    border: 1px solid var(--ws-border, #e2e8f0); 
    overflow: hidden; 
}

.fila-rango input:focus {
    border-color: var(--ws-primary) !important;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15) !important;
}

.modal-close:hover {
    color: #ffffff !important;
    transform: scale(1.1);
}

/* FOOTER DEL DASHBOARD */
.dashboard-footer {
    background-color: #ffffff;
    border-top: 1px solid var(--ws-border, #e2e8f0);
    padding: 20px 0;
    width: 100%;
    text-align: center;
    flex-shrink: 0;
}

.footer-content {
    font-size: 13px;
    color: var(--ws-text-muted, #64748b);
    line-height: 1.6;
}

.footer-content p {
    margin: 0;
    font-weight: 400;
}

.footer-content strong {
    color: var(--ces-dark, #0d2c54);
    font-weight: 600;
}

.form-step {
    display: none;
}

.form-step.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}