@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-active: #ffffff;
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --page-bg: #f1f5f9;
    --card-bg: #ffffff;
    --text-primary: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
}

* {
    border-radius: 0 !important;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--page-bg);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
}

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

/* ===== SIDEBAR ===== */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    padding: 24px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand .brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-brand .brand-icon img {
    width: 34px;
    height: auto;
}

.sidebar-brand .brand-text {
    color: #fff;
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: 1px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.sidebar-nav .nav-item i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.sidebar-nav .nav-item:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-active);
}

.sidebar-nav .nav-item.active {
    background: var(--sidebar-hover);
    color: var(--sidebar-active);
    border-left: 3px solid var(--primary);
}

.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.06);
    margin: 8px 16px;
}

.sidebar-footer {
    padding: 12px 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--sidebar-text);
    font-size: 0.85rem;
}

.sidebar-footer .user-info i {
    width: 20px;
    text-align: center;
}

.badge-admin {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    flex-shrink: 0;
}

.badge-jefe {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    flex-shrink: 0;
}

.badge-serenazgo {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    flex-shrink: 0;
}

/* ===== MAIN AREA ===== */
.main-area {
    margin-left: 260px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ===== TOPBAR ===== */
.topbar {
    background: var(--card-bg);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    min-height: 64px;
}

.topbar h5 {
    margin: 0;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text-primary);
}

.topbar .topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar .topbar-right .user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ===== NOTIFICATIONS ===== */
.btn-notif {
    position: relative;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    padding: 6px 10px;
    cursor: pointer;
    transition: color 0.15s;
}

.btn-notif:hover {
    color: var(--text-primary);
}

.notif-badge {
    position: absolute;
    top: 0;
    right: 2px;
    background: var(--danger);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.notif-menu {
    width: 340px;
    padding: 0;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    margin-top: 8px !important;
}

.notif-header {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.notif-list {
    max-height: 280px;
    overflow-y: auto;
}

.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.1s;
}

.notif-item:hover {
    background: #f8fafc;
}

.notif-item .notif-icon {
    width: 36px;
    height: 36px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.9rem;
}

.notif-item .notif-body {
    flex: 1;
    min-width: 0;
}

.notif-item .notif-body .notif-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notif-item .notif-body .notif-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.notif-item .notif-body .notif-meta span {
    margin-right: 8px;
}

.notif-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.notif-footer {
    text-align: center;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--primary) !important;
    padding: 12px 16px !important;
    border-top: 1px solid var(--border-color);
}

.notif-footer:hover {
    background: #f8fafc !important;
}

.notif-item-new {
    background: #eff6ff;
}

.notif-item-new:hover {
    background: #dbeafe !important;
}

/* ===== CONTENT ===== */
.content {
    padding: 28px 32px;
    flex: 1;
}

/* ===== CARDS ===== */
.card {
    background: var(--card-bg);
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

.card-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 24px;
    font-weight: 600;
}

.card-header h5 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
}

.card-body {
    padding: 24px;
}

/* ===== STAT CARDS ===== */
.stat-card {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-card .stat-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-card .stat-icon.bg-primary-subtle {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
}

.stat-card .stat-icon.bg-warning-subtle {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.stat-card .stat-icon.bg-success-subtle {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

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

.stat-card .stat-info h3 {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0;
}

/* ===== TABLES ===== */
.table {
    margin: 0;
    font-size: 0.88rem;
}

.table thead th {
    background: #1e293b;
    color: #fff;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 16px;
    border: none;
}

.table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.table tbody tr:hover {
    background: #f8fafc;
}

/* ===== BADGES ===== */
.badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 12px;
    text-transform: capitalize;
}

.badge.bg-warning {
    background: #fef3c7 !important;
    color: #92400e;
}

.badge.bg-success {
    background: #dcfce7 !important;
    color: #166534;
}

/* ===== BUTTONS ===== */
.btn {
    font-weight: 500;
    font-size: 0.85rem;
    padding: 8px 18px;
    transition: all 0.15s ease;
}

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

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

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

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

.btn-outline-success {
    color: var(--success);
    border-color: var(--success);
}

.btn-outline-success:hover {
    background: var(--success);
    border-color: var(--success);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.8rem;
}

/* ===== PAGINATION ===== */
.pagination .page-link {
    color: var(--text-primary);
    border-color: var(--border-color);
    padding: 8px 14px;
    font-size: 0.85rem;
}

.pagination .page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.pagination .page-item.disabled .page-link {
    color: var(--text-muted);
}

/* ===== FORMS ===== */
.form-control, .form-select, .input-group-text {
    border: 1px solid var(--border-color);
    font-size: 0.88rem;
    padding: 8px 14px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.input-group-text {
    background: #f8fafc;
    color: var(--text-muted);
}

/* ===== MAP ===== */
#map {
    height: 600px;
    width: 100%;
    z-index: 1;
}

.custom-marker-icon {
    background: none !important;
    border: none !important;
}

/* ===== ALERT ===== */
.alert {
    border: none;
    font-size: 0.88rem;
    padding: 12px 16px;
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
}

.btn-success:hover {
    background: #16a34a;
    border-color: #16a34a;
}

.btn-secondary {
    background: #e2e8f0;
    border-color: #e2e8f0;
    color: #475569;
}

.btn-secondary:hover {
    background: #cbd5e1;
    border-color: #cbd5e1;
    color: #1e293b;
}

.btn-outline-secondary {
    border-color: #cbd5e1;
    color: #64748b;
}

.btn-outline-secondary:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #1e293b;
}

/* ===== LOGIN PAGE ===== */
body.login-page {
    background: linear-gradient(rgba(15, 23, 42, 0.88), rgba(15, 23, 42, 0.88)), url('../img/fondo_inicio.png');
    background-size: cover;
    background-position: center;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.login-card {
    max-width: 420px;
    width: 100%;
    background: #fff;
}

.login-card .card-body {
    padding: 48px 40px;
}

.login-card .login-icon {
    text-align: center;
    margin: 0 auto 24px;
}

.login-card .login-icon img {
    width: 90px;
    height: auto;
}

.login-card h3 {
    font-weight: 800;
    font-size: 1.5rem;
    color: var(--text-primary);
    letter-spacing: 1px;
}

.login-card .login-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 28px;
}

.login-card .form-label {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-primary);
    margin-bottom: 6px;
}

/* ===== MENU TOGGLE (MÓVIL) ===== */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    padding: 6px 10px;
    margin-right: 6px;
    cursor: pointer;
    line-height: 1;
}

.menu-toggle:focus {
    outline: none;
}

.topbar-left {
    display: flex;
    align-items: center;
    min-width: 0;
}

/* ===== BACKDROP SIDEBAR ===== */
.backdrop-sidebar {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 1040;
}

.backdrop-sidebar.visible {
    display: block;
}

/* ===== BANNER DE ALARMA ===== */
.alarma-banner {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 18px;
    z-index: 2000;
    display: flex;
    align-items: center;
    gap: 14px;
    background: #dc2626;
    color: #fff;
    padding: 12px 18px;
    box-shadow: 0 6px 24px rgba(220, 38, 38, 0.5);
    animation: alarma-pulso 1s ease-in-out infinite;
    max-width: calc(100vw - 24px);
}

.alarma-banner .alarma-banner-ic {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.alarma-banner .alarma-banner-txt {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.alarma-banner .alarma-banner-txt strong {
    font-size: 0.85rem;
}

.alarma-banner .alarma-banner-txt span {
    font-size: 0.78rem;
    opacity: 0.92;
}

.alarma-banner .btn-light {
    color: #dc2626;
    font-weight: 700;
    white-space: nowrap;
}

@keyframes alarma-pulso {
    0%, 100% { box-shadow: 0 6px 24px rgba(220, 38, 38, 0.5); }
    50% { box-shadow: 0 6px 34px rgba(220, 38, 38, 0.9); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 992px) {
    .content {
        padding: 18px 20px;
    }
}

@media (max-width: 768px) {
    .menu-toggle {
        display: inline-flex;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        width: 260px;
        box-shadow: none;
        z-index: 1050;
    }

    .sidebar.abierta {
        transform: translateX(0);
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.4);
    }

    .main-area {
        margin-left: 0;
    }

    .topbar {
        padding: 10px 12px;
        min-height: 56px;
    }

    .topbar h5 {
        font-size: 0.95rem;
        max-width: 45vw;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .topbar .topbar-right {
        gap: 6px;
    }

    .topbar .topbar-right .user-badge {
        font-size: 0.75rem;
    }

    .content {
        padding: 14px;
    }

    .notif-menu {
        width: auto;
        max-width: calc(100vw - 20px);
    }

    .login-card .card-body {
        padding: 32px 22px;
    }

    .card-header {
        padding: 12px 16px;
    }

    .card-body {
        padding: 16px;
    }

    .table thead th {
        font-size: 0.68rem;
        padding: 10px 10px;
    }

    .table tbody td {
        padding: 10px;
    }

    .stat-card {
        padding: 16px;
        gap: 14px;
    }

    .stat-card .stat-icon {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }

    .stat-card .stat-info h3 {
        font-size: 1.4rem;
    }
}

@media (max-width: 400px) {
    .sidebar-brand .brand-text {
        font-size: 1rem;
    }

    .topbar .topbar-right .user-badge {
        display: none;
    }
}

/* ── Avatar de evidencia (fotos de alertas) ─────────────── */
.alerta-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    cursor: pointer;
    transition: transform .15s ease;
}
.alerta-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
