:root {
    --primary-color: #646cff;
    --primary-dark: #535bf2;
    --primary-glow: rgba(100, 108, 255, 0.12);
    --primary-shadow: rgba(100, 108, 255, 0.35);
    --light-bg: #f1f5f9;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --text-secondary: #334155;
    --text-light: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --success-color: #22c55e;
    --success-bg: #dcfce7;
    --success-text: #166534;
    --warning-color: #f59e0b;
    --warning-bg: #fef9c3;
    --warning-text: #92400e;
    --danger-color: #ef4444;
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;
    --font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --border-radius: 8px;
    --border-radius-sm: 6px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--light-bg);
    color: var(--text-color);
    display: flex;
    font-size: 0.875rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Splash Screen --- */
#splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 50% 40%, #eef2ff 0%, #f1f5f9 70%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    transition: opacity 0.6s ease-out;
}

.splash-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

/* Contenedor del ícono con los anillos */
.splash-icon-wrapper {
    position: relative;
    width: 96px;
    height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Anillos pulsantes */
.splash-ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid #646cff;
    opacity: 0;
    animation: ringPulse 2.4s ease-out infinite;
}

.splash-ring-1 {
    width: 96px;
    height: 96px;
    animation-delay: 0s;
}

.splash-ring-2 {
    width: 96px;
    height: 96px;
    animation-delay: 0.8s;
}

@keyframes ringPulse {
    0% {
        transform: scale(0.7);
        opacity: 0.7;
    }
    100% {
        transform: scale(1.9);
        opacity: 0;
    }
}

/* Ícono central */
.splash-icon {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    background: linear-gradient(135deg, #646cff 0%, #a78bfa 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: white;
    box-shadow: 0 8px 32px rgba(100, 108, 255, 0.35);
    animation: iconFloat 3s ease-in-out infinite;
}

@keyframes iconFloat {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-5px); }
}

/* Título */
.splash-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    letter-spacing: -0.01em;
    margin: 0;
}

/* Puntos de carga */
.splash-dots {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
}

.splash-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #646cff;
    animation: dotBounce 1.2s ease-in-out infinite;
}

.splash-dots span:nth-child(1) { animation-delay: 0s; }
.splash-dots span:nth-child(2) { animation-delay: 0.2s; }
.splash-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotBounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* --- Sidebar --- */
.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    height: 100vh;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-right: 1px solid var(--border-color);
    flex-shrink: 0;
}

.logo {
    font-size: 1.05rem;
    font-weight: 800;
    margin-bottom: 40px;
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, #646cff 0%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo span {
    margin-right: 10px;
    display: flex;
    align-items: center;
}

.sidebar nav ul {
    list-style: none;
}

.sidebar nav ul li a {
    color: var(--text-light);
    text-decoration: none;
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--border-radius-sm);
    border-left: 3px solid transparent;
    margin-bottom: 4px;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
    font-weight: 500;
    font-size: 0.875rem;
}

.sidebar nav ul li a i {
    margin-right: 12px;
    width: 16px;
    text-align: center;
    font-size: 0.875rem;
}

.sidebar nav ul li a:hover {
    color: var(--primary-color);
    background-color: #f8fafc;
}

.sidebar nav ul li a.active {
    background-color: #eef2ff;
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 600;
}

.user-profile {
    padding: 12px 10px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#user-name {
    font-weight: 600;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
    color: var(--text-secondary);
    margin: 0 8px;
}

.btn-logout {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    transition: color 0.15s;
    padding: 4px;
}

.btn-logout:hover {
    color: var(--danger-color);
}

/* --- Main Content --- */
.main-content {
    flex-grow: 1;
    padding: 32px 40px;
    overflow-y: auto;
    height: 100vh;
}

header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 32px;
    color: var(--text-color);
    animation: fadeInDown 0.4s ease-out;
}

/* --- Cards --- */
.card {
    position: relative;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
    animation: fadeInUp 0.5s ease-out;
    animation-fill-mode: backwards;
}

.card h3 {
    font-weight: 600;
    margin-bottom: 20px;
    font-size: 0.95rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* --- Dashboard --- */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 18px 20px;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 6px;
    animation: fadeInUp 0.5s ease-out both;
}

.kpi-card:nth-child(1) { animation-delay: 0s; }
.kpi-card:nth-child(2) { animation-delay: 0.07s; }
.kpi-card:nth-child(3) { animation-delay: 0.14s; }
.kpi-card:nth-child(4) { animation-delay: 0.21s; }

.kpi-primary { border-left-color: #646cff; }
.kpi-success { border-left-color: var(--success-color); }
.kpi-warning { border-left-color: var(--warning-color); }
.kpi-danger  { border-left-color: var(--danger-color); }

.kpi-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-color);
    line-height: 1;
}

.kpi-primary .kpi-value { color: #646cff; }
.kpi-success .kpi-value { color: var(--success-color); }
.kpi-warning .kpi-value { color: var(--warning-color); }
.kpi-danger  .kpi-value { color: var(--danger-color); }

.charts-container {
    height: 320px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 24px;
}

/* --- Alerts Page Layout --- */
.content-wrapper {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 24px;
}

.content-wrapper.full-width {
    grid-template-columns: 1fr;
}

/* --- Form --- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

input[type="text"],
input[type="date"],
input[type="number"],
textarea,
.control-select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background-color: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-family: var(--font-family);
    font-size: 0.875rem;
    color: var(--text-color);
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

input[type="text"]:focus,
input[type="date"]:focus,
input[type="number"]:focus,
textarea:focus,
.control-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background-color: #ffffff;
}

input[type="text"]:disabled,
input[type="date"]:disabled,
input[type="number"]:disabled,
textarea:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* --- Buttons --- */
.btn {
    padding: 0.55rem 1.1rem;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.15s;
    letter-spacing: 0.01em;
}

.btn-primary {
    background: linear-gradient(135deg, #646cff 0%, #535bf2 100%);
    color: white;
    box-shadow: 0 2px 8px var(--primary-shadow);
}

.btn-primary:hover {
    opacity: 0.9;
    box-shadow: 0 4px 12px var(--primary-shadow);
    transform: translateY(-1px);
}

.form-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn-primary, .btn-secondary {
    flex-grow: 1;
}

.btn-secondary {
    background-color: #f1f5f9;
    color: var(--text-light);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: #e2e8f0;
    color: var(--text-secondary);
}

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

.btn.btn-danger:hover {
    background-color: #dc2626;
}

/* --- Table --- */
#alerts-table, #logs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

#logs-table {
    table-layout: fixed;
}

#alerts-table thead th, #logs-table thead th {
    text-align: left;
    padding: 0.75rem 1rem;
    background-color: #f8fafc;
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

#alerts-table tbody tr, #logs-table tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: background-color 0.15s;
}

#alerts-table tbody tr:hover, #logs-table tbody tr:hover {
    background-color: #f8fafc;
}

#alerts-table td, #logs-table td {
    padding: 0.75rem 1rem;
    border: none;
    color: var(--text-secondary);
}

#logs-table td {
    word-wrap: break-word;
}

#alerts-table small {
    color: var(--text-muted);
    font-size: 0.78rem;
}

/* Centrar columnas específicas */
#alerts-table th:nth-child(2),
#alerts-table td:nth-child(2),
#alerts-table th:nth-child(3),
#alerts-table td:nth-child(3),
#alerts-table th:nth-child(4),
#alerts-table td:nth-child(4),
#alerts-table th:nth-child(5),
#alerts-table td:nth-child(5) {
    text-align: center;
}

/* --- Status Badges --- */
.status-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    margin-top: 5px;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.status-ok {
    background-color: var(--success-bg);
    color: var(--success-text);
}

.status-warning {
    background-color: var(--warning-bg);
    color: var(--warning-text);
}

.status-expired {
    background-color: var(--danger-bg);
    color: var(--danger-text);
}

/* --- Action Buttons (table) --- */
.edit-btn, .delete-btn {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    color: var(--text-light);
    margin-right: 6px;
    font-size: 0.875rem;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.edit-btn:hover {
    background-color: #eef2ff;
    border-color: #c7d2fe;
    color: var(--primary-color);
}

.delete-btn:hover {
    background-color: var(--danger-bg);
    border-color: #fca5a5;
    color: var(--danger-color);
}

/* --- Card Header & Search --- */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-header h3 {
    margin-bottom: 0;
}

.search-container {
    display: flex;
    align-items: center;
    width: 280px;
}

.search-container input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
}

.search-container .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    padding: 0.6rem 1rem;
    background-color: var(--primary-color);
    color: white;
    border: 1px solid var(--primary-color);
}

.search-container .btn:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* --- Pagination --- */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.pagination-controls .form-group {
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagination-controls .form-group label {
    margin-bottom: 0;
    white-space: nowrap;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    font-weight: 600;
    color: var(--text-light);
}

.control-select {
    width: auto;
    min-width: 80px;
    padding: 0.45rem 2rem 0.45rem 0.7rem;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2364748b' width='18px' height='18px'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3Cpath d='M0 0h24v24H0z' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    background-size: 16px;
    cursor: pointer;
}

.pagination-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination-container .btn {
    margin: 0;
    padding: 0.45rem 0.9rem;
    font-size: 0.8rem;
}

#log-page-info {
    color: var(--text-light);
    font-weight: 500;
    margin: 0 12px;
    font-size: 0.8rem;
}

/* --- Loading Indicator --- */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    border-radius: var(--border-radius);
    backdrop-filter: blur(2px);
}

.loading-spinner {
    border: 3px solid rgba(0, 0, 0, 0.08);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    animation: modalSlideUp 0.3s ease-out;
}

.modal-content h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-color);
    text-transform: none;
    letter-spacing: 0;
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, #f8fafc 0%, #fff 100%);
}

.modal-content p {
    color: var(--text-light);
    padding: 1.25rem 1.5rem;
    font-size: 0.875rem;
    line-height: 1.6;
    margin: 0;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background-color: #f8fafc;
}

.modal-buttons .btn {
    flex-grow: 1;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideUp {
    from { transform: translateY(16px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
