:root {
    --bg-dark: #f8fafc;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(0, 0, 0, 0.1);
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --text-main: #0f172a;
    --text-muted: #475569;
    --font-family: 'Inter', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-family);
}

body {
    background: var(--bg-dark);
    background-image: 
        radial-gradient(at 0% 0%, hsla(210,100%,95%,1) 0, transparent 50%), 
        radial-gradient(at 50% 0%, hsla(220,100%,90%,0.4) 0, transparent 50%), 
        radial-gradient(at 100% 0%, hsla(330,100%,95%,0.4) 0, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.hidden { display: none !important; }
.active { display: flex !important; }

/* --- Glassmorphism Panels --- */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.1);
    padding: 40px;
    width: 100%;
}

/* --- Login Screen --- */
#login-container {
    max-width: 450px;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: fadeIn 0.5s ease-out;
}

#login-container .logo {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 20px;
}

#login-container h2 { margin-bottom: 10px; font-weight: 600; }
#login-container p { color: var(--text-muted); margin-bottom: 30px; }

#login-form { width: 100%; }

/* --- Inputs --- */
.input-group {
    position: relative;
    margin-bottom: 20px;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* --- Premium Stats Cards --- */
.stats-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.stat-card {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-card.total { border-left: 4px solid var(--primary-color); }
.stat-card.total .stat-icon { color: var(--primary-color); background: rgba(37, 99, 235, 0.1); }

.stat-card.activas { border-left: 4px solid var(--success-color); }
.stat-card.activas .stat-icon { color: var(--success-color); background: rgba(16, 185, 129, 0.1); }

.stat-card.inactivas { border-left: 4px solid var(--danger-color); }
.stat-card.inactivas .stat-icon { color: var(--danger-color); background: rgba(239, 68, 68, 0.1); }

.stat-card.bloqueadas { border-left: 4px solid #f59e0b; }
.stat-card.bloqueadas .stat-icon { color: #f59e0b; background: rgba(245, 158, 11, 0.1); }

.stat-details h4 {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-details h2 {
    margin: 5px 0 0 0;
    font-size: 1.8rem;
    color: var(--text-main);
    font-weight: 700;
}

.table-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-main);
}

.input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

#login-form .input-group input { padding-left: 45px; }

input {
    width: 100%;
    padding: 12px 15px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    color: var(--text-main);
    font-size: 1rem;
    transition: all 0.3s ease;
    outline: none;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}

input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

/* --- Buttons --- */
.btn {
    display: inline-block;
    width: 100%;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    width: 100%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-sm {
    width: auto !important;
    padding: 8px 15px;
    font-size: 0.9rem;
}

.btn-block {
    width: 100% !important;
}

.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--primary-color); color: white; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: var(--secondary-color); color: white; }
.btn-secondary:hover { background: var(--secondary-hover); }

.btn-success { background: var(--success-color); color: white; width: auto; }
.btn-success:hover { background: #059669; }

.btn-icon {
    width: auto;
    padding: 8px;
    background: transparent;
    color: var(--text-muted);
    box-shadow: none;
}
.btn-icon:hover { color: var(--text-main); background: rgba(0,0,0,0.05); }
.btn-icon.delete:hover { color: var(--danger-color); background: rgba(239, 68, 68, 0.1); }
.btn-icon.edit:hover { color: var(--primary-color); background: rgba(37, 99, 235, 0.1); }

/* --- Dashboard --- */
#dashboard-container {
    width: 100%;
    max-width: 1350px;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.5s ease-out;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--glass-border);
    flex-wrap: wrap;
    gap: 15px;
}

header .brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

header h2 { font-size: 1.5rem; color: var(--primary-color); display: flex; align-items: center; gap: 8px;}

header .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

header #user-display { color: var(--text-muted); font-size: 0.9rem; font-weight: 500; }

.action-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-start;
}

.action-buttons .btn {
    padding: 6px 12px;
    width: auto !important;
}

.dashboard-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 30px;
    align-items: start;
}

.form-section {
    background: rgba(255, 255, 255, 0.6);
    padding: 25px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.form-section h3 { margin-bottom: 5px; color: var(--text-main); }
.form-section .subtitle { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 20px; }

.form-actions { display: flex; gap: 10px; }

/* --- Table --- */
.table-section {
    background: rgba(255, 255, 255, 0.6);
    padding: 25px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.table-header h3 { color: var(--text-main); margin: 0; }

.table-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    flex: 1;
    justify-content: flex-end;
}

.search-box {
    position: relative;
    width: 100%;
    max-width: 300px;
}

.pdf-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.table-responsive {
    overflow-x: auto;
    flex-grow: 1;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-main);
}

th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td { font-size: 0.95rem; }

tr:last-child td { border-bottom: none; }
tr:hover { background: rgba(0, 0, 0, 0.02); }

.actions-cell {
    display: flex;
    gap: 5px;
}

/* --- Toasts --- */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.toast {
    background: white;
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease-out forwards;
    opacity: 0;
    transform: translateX(100%);
    font-weight: 500;
}

.toast.success { border-left: 4px solid var(--success-color); }
.toast.error { border-left: 4px solid var(--danger-color); }
.toast.info { border-left: 4px solid var(--primary-color); }

.toast.fade-out { animation: slideOut 0.3s ease-in forwards; }

/* --- Selects & Search --- */
.form-select {
    width: 100%;
    padding: 12px 15px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
}

.search-box {
    position: relative;
    flex-grow: 1;
    max-width: 300px;
}
.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}
.search-box input {
    padding-left: 35px;
    padding-top: 8px;
    padding-bottom: 8px;
}

.pdf-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    border: none;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 110px;
}
.status-badge option { background: #fff; color: #333; }
.status-activa { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.status-inactiva { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.status-bloqueada { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }

.status-select {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    background: transparent;
}
.status-activa { 
    color: var(--success-color) !important; 
    border-color: var(--success-color) !important; 
    background-color: rgba(16, 185, 129, 0.1) !important;
}
.status-inactiva { 
    color: var(--danger-color) !important; 
    border-color: var(--danger-color) !important; 
    background-color: rgba(239, 68, 68, 0.1) !important;
}

/* --- Custom Botones Enterprise --- */
.nav-btn, .action-btn {
    padding: 6px 12px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    color: #fff;
    background: var(--primary-color);
    transition: all 0.3s ease;
    margin-left: 5px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.nav-btn:hover, .action-btn:hover {
    filter: brightness(0.9);
    transform: translateY(-1px);
}
.nav-btn.danger, .action-btn.danger { background: var(--danger-color); }
.nav-btn.success, .action-btn.success { background: var(--success-color); }

/* --- Utilities --- */
/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideOut {
    to { opacity: 0; transform: translateX(100%); }
}

/* --- Responsive (Smartphones & Tablets) --- */
@media (max-width: 1024px) {
    .dashboard-content { grid-template-columns: 1fr; }
    .table-section { min-width: 0; overflow: hidden; }
}

@media (max-width: 768px) {
    body { padding: 8px; }
    .glass-panel { padding: 15px; border-radius: 12px; }
    
    header { flex-direction: column; align-items: center; gap: 12px; margin-bottom: 20px; padding-bottom: 15px; }
    header .brand { justify-content: center; width: 100%; text-align: center; }
    header h2 { font-size: 1.3rem; justify-content: center; }
    header .user-info { flex-direction: column; gap: 10px; width: 100%; }
    header .user-info button { width: 100% !important; justify-content: center; }
    header #user-display { display: block; text-align: center; width: 100%; margin-bottom: 5px; }
    
    .stats-container { grid-template-columns: 1fr; gap: 12px; margin-bottom: 20px; }
    .stat-card { padding: 15px; }
    
    .table-header { flex-direction: column; align-items: stretch; gap: 15px; }
    .table-actions { flex-direction: column; align-items: stretch; gap: 10px; }
    .search-box { max-width: 100%; }
    .pdf-buttons { flex-direction: column; width: 100%; gap: 8px; }
    .pdf-buttons button { width: 100% !important; justify-content: center; }
    
    th, td { padding: 10px 8px; font-size: 0.85rem; }
    
    /* Evitar que la tabla se rompa o se encoja */
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table { min-width: 600px; /* Obliga el scroll horizontal en móviles muy finos */ }
    
    .action-buttons { flex-direction: row; gap: 5px; }
}

@media (max-width: 480px) {
    .stat-details h2 { font-size: 1.5rem; }
    .table-header h3 { font-size: 1.2rem; text-align: center; }
}
