/* ============================================
   Central de Monitoreo — Plus Seguridad
   Design System: Clean, thin lines, professional
   ============================================ */

:root {
    --green-900: #004d1a;
    --green-800: #005924;
    --green-700: #1a6b1a;
    --green-600: #228b22;
    --green-500: #339933;
    --green-400: #4db84d;
    --green-100: #e8f5e9;
    --green-50: #f1f8f1;
    --gray-900: #111827;
    --gray-800: #1f2937;
    --gray-700: #374151;
    --gray-600: #4b5563;
    --gray-500: #6b7280;
    --gray-400: #9ca3af;
    --gray-300: #d1d5db;
    --gray-200: #e5e7eb;
    --gray-100: #f3f4f6;
    --gray-50: #f9fafb;
    --white: #ffffff;
    --red-500: #ef4444;
    --red-100: #fee2e2;
    --yellow-500: #f59e0b;
    --yellow-100: #fef3c7;
    --blue-500: #3b82f6;
    --blue-100: #dbeafe;
    --sidebar-width: 250px;
    --sidebar-collapsed: 64px;
    --topbar-height: 56px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --radius: 6px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
    --transition: 0.2s ease;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font); background: var(--gray-50); color: var(--gray-800); line-height: 1.5; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ---- LAYOUT ---- */
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--green-800);
    color: rgba(255,255,255,0.9);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    transition: transform var(--transition);
}
.sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 16px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand-logo {
    background: #fff;
    border-radius: 12px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.sidebar-brand img { height: 44px; width: auto; }
.sidebar-brand span {
    margin-top: 10px;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.5);
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }
.nav-section {
    padding: 16px 20px 6px;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.4);
    font-weight: 600;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.65);
    transition: all var(--transition);
    border-left: 3px solid transparent;
    cursor: pointer;
}
.nav-item:hover {
    color: rgba(255,255,255,0.95);
    background: rgba(255,255,255,0.06);
}
.nav-item.active {
    color: #fff;
    background: rgba(255,255,255,0.1);
    border-left-color: var(--green-400);
    font-weight: 500;
}
.nav-item .icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    opacity: 0.8;
}
.nav-item.active .icon { opacity: 1; }
.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 0.75rem;
    color: rgba(255,255,255,0.35);
}

/* Main content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Top bar */
.topbar {
    height: var(--topbar-height);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 40;
    gap: 16px;
}
.topbar-left { display: flex; align-items: center; gap: 8px; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--gray-500); }
.breadcrumb a:hover { color: var(--green-600); }
.breadcrumb .sep { font-size: 0.7rem; }
.breadcrumb .current { color: var(--gray-800); font-weight: 500; }
.btn-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--gray-600);
    padding: 4px;
}
.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--gray-600);
    padding: 6px 12px;
    border-radius: var(--radius);
    transition: background var(--transition);
    cursor: pointer;
    position: relative;
}
.user-info:hover { background: var(--gray-100); }
.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--green-500);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}
.user-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    min-width: 160px;
    z-index: 100;
}
.user-info:hover .user-dropdown { display: block; }
.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 0.8rem;
    color: var(--gray-700);
    transition: background var(--transition);
}
.user-dropdown a:hover { background: var(--gray-50); }

/* Page content */
.page-content { padding: 24px; flex: 1; }
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-title { font-size: 1.35rem; font-weight: 600; color: var(--gray-900); }

/* ---- COMPONENTS ---- */

/* Cards / Box */
.card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-header h3 { font-size: 0.9rem; font-weight: 600; color: var(--gray-800); }
.card-body { padding: 18px; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--gray-100); }

/* Stat cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
}
.stat-label { font-size: 0.75rem; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 500; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--gray-900); margin-top: 4px; }
.stat-change { font-size: 0.75rem; margin-top: 4px; }
.stat-change.up { color: var(--green-600); }
.stat-change.down { color: var(--red-500); }

/* Tables */
.table-container { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
thead th {
    text-align: left;
    padding: 10px 14px;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-500);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}
tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}
tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid transparent;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn-primary { background: var(--green-600); color: #fff; }
.btn-primary:hover { background: var(--green-700); }
.btn-secondary { background: var(--white); color: var(--gray-700); border-color: var(--gray-300); }
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-danger { background: var(--white); color: var(--red-500); border-color: var(--red-500); }
.btn-danger:hover { background: var(--red-100); }
.btn-sm { padding: 4px 10px; font-size: 0.75rem; }
.btn-icon {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    background: var(--white);
    border: 1px solid var(--gray-200);
    color: var(--gray-500);
    transition: all var(--transition);
}
.btn-icon:hover { border-color: var(--gray-400); color: var(--gray-700); }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.badge-alta { background: var(--red-100); color: #dc2626; }
.badge-media { background: var(--yellow-100); color: #b45309; }
.badge-baja { background: var(--green-100); color: var(--green-700); }
.badge-success { background: var(--green-100); color: var(--green-700); }
.badge-warning { background: var(--yellow-100); color: #b45309; }
.badge-danger { background: var(--red-100); color: #dc2626; }
.badge-info { background: var(--blue-100); color: #1d4ed8; }
.badge-neutral { background: var(--gray-100); color: var(--gray-600); }
.badge-gold { background: #fef3c7; color: #92400e; }
.badge-silver { background: var(--gray-100); color: var(--gray-600); }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 4px;
}
.form-control {
    width: 100%;
    padding: 7px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--gray-800);
    background: var(--white);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
.form-control:focus {
    border-color: var(--green-500);
    box-shadow: 0 0 0 3px rgba(51,153,51,0.1);
}
.form-control::placeholder { color: var(--gray-400); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-inline { display: flex; gap: 8px; align-items: flex-end; }

/* Search input */
.search-box {
    position: relative;
    max-width: 280px;
}
.search-box input {
    padding-left: 34px;
}
.search-box .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    font-size: 16px;
    pointer-events: none;
}

/* Filters bar */
.filters-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 16px;
}
.filters-bar .form-group { margin-bottom: 0; }
.filters-bar .form-control { min-width: 140px; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-100);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close {
    background: none;
    border: none;
    color: var(--gray-400);
    font-size: 20px;
    padding: 4px;
    line-height: 1;
}
.modal-close:hover { color: var(--gray-700); }
.modal-body { padding: 20px; }
.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--gray-100);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 16px;
}
.pagination button, .pagination a {
    padding: 5px 10px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--white);
    font-size: 0.78rem;
    color: var(--gray-600);
    cursor: pointer;
    transition: all var(--transition);
}
.pagination button:hover, .pagination a:hover { border-color: var(--green-500); color: var(--green-600); }
.pagination .active { background: var(--green-600); color: #fff; border-color: var(--green-600); }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--gray-400);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 0.85rem; }

/* Alerts / Toast */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.alert-success { background: var(--green-100); color: var(--green-800); border: 1px solid #a7f3d0; }
.alert-error { background: var(--red-100); color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: var(--yellow-100); color: #92400e; border: 1px solid #fde68a; }

/* Live indicator */
.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green-500);
    animation: pulse 2s infinite;
    display: inline-block;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Loading spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--green-500);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--green-800) 0%, var(--green-900) 100%);
    padding: 20px;
}
.login-card {
    background: var(--white);
    border-radius: 10px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
    padding: 40px 32px;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo img { height: 56px; }
.login-title {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 6px;
}
.login-subtitle {
    text-align: center;
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-bottom: 24px;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .btn-menu-toggle { display: flex; }
    .page-content { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .filters-bar { flex-direction: column; }
    .filters-bar .form-control { min-width: 100%; }
    .modal { max-width: 100%; margin: 10px; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
}

/* Overlay for mobile menu */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 45;
}
.sidebar-overlay.active { display: block; }

/* Utility */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 0.78rem; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.hidden { display: none; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
