/* Estilos personalizados para Sistema Electoral */

:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    flex: 1;
}

footer {
    margin-top: auto;
}

/* Navbar personalizado */
.navbar-brand {
    font-weight: bold;
    font-size: 1.3rem;
}

/* Cards */
.card {
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 20px;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Jumbotron personalizado */
.jumbotron {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.jumbotron.bg-light {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%) !important;
    color: #333;
}

/* Tablas */
.table {
    background: white;
}

.table thead {
    background-color: #f8f9fa;
}

/* Botones */
.btn {
    border-radius: 5px;
    padding: 8px 20px;
    transition: all 0.3s;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Formularios */
.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Alerts */
.alert {
    border-radius: 8px;
    border: none;
}

/* Loading spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.spinner-overlay.active {
    display: flex;
}

/* Página de error */
.error-page {
    min-height: 400px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Responsividad */
@media (max-width: 768px) {
    .navbar-brand {
        font-size: 1rem;
    }

    .jumbotron h1 {
        font-size: 2rem;
    }

    .card {
        margin-bottom: 15px;
    }
}

/* Utilidades */
.cursor-pointer {
    cursor: pointer;
}

.text-small {
    font-size: 0.875rem;
}

.badge-custom {
    padding: 5px 10px;
    border-radius: 12px;
}

/* ========================================
   SIDEBAR LAYOUT
   ======================================== */
#wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

#sidebar-wrapper {
    height: 100vh;
    width: 260px;
    background: linear-gradient(180deg, #2c3e50 0%, #34495e 100%);
    transition: margin 0.3s ease-in-out;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

#sidebar-wrapper.toggled {
    margin-left: -260px;
}

/* Scrollbar personalizado para el sidebar */
#sidebar-wrapper::-webkit-scrollbar {
    width: 8px;
}

#sidebar-wrapper::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.2);
}

#sidebar-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 4px;
}

#sidebar-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.5);
}

#page-content-wrapper {
    width: 100%;
    margin-left: 260px;
    transition: margin 0.3s ease-in-out;
}

#page-content-wrapper.toggled {
    margin-left: 0;
}

/* Sidebar Header */
.sidebar-header {
    padding: 20px;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h3 {
    color: #fff;
    font-size: 1.3rem;
    margin: 0;
    font-weight: 600;
}

.sidebar-header h4 {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
}

.sidebar-brand-link {
    transition: background .2s;
    border-radius: 8px;
}
.sidebar-brand-link:hover {
    background: rgba(255,255,255,.07);
}

/* Sidebar Logo */
.sidebar-logo {
    max-width: 120px;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transition: transform 0.3s ease;
}

.sidebar-logo:hover {
    transform: scale(1.05);
}

/* Sidebar Menu */
.sidebar-menu {
    padding: 0;
    list-style: none;
    margin: 0;
}

.sidebar-menu li {
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-menu li a {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    color: #ecf0f1;
    text-decoration: none;
    transition: all 0.3s;
    font-size: 0.95rem;
}

.sidebar-menu li a:hover {
    background: rgba(255,255,255,0.1);
    padding-left: 25px;
    color: #fff;
}

.sidebar-menu li a.active {
    background: rgba(52, 152, 219, 0.3);
    border-left: 4px solid #3498db;
    color: #fff;
}

.sidebar-menu li a i {
    width: 25px;
    margin-right: 10px;
    text-align: center;
    font-size: 1.1rem;
}

/* Submenu */
.sidebar-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    background: rgba(0,0,0,0.2);
    display: none;
}

.sidebar-submenu.show {
    display: block;
}

.sidebar-submenu li a {
    padding: 12px 20px 12px 55px;
    font-size: 0.9rem;
    color: #bdc3c7;
}

.sidebar-submenu li a:hover {
    color: #fff;
    background: rgba(255,255,255,0.05);
}

/* Submenú colapsable (Bootstrap collapse) */
.submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    background: rgba(0,0,0,0.2);
}
.submenu li a {
    padding: 11px 20px 11px 52px;
    font-size: 0.875rem;
    color: #bdc3c7;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    transition: background .15s, padding-left .15s;
}
.submenu li a:hover,
.submenu li a.active {
    color: #fff;
    background: rgba(255,255,255,0.08);
    padding-left: 58px;
}
.submenu li a.active {
    border-left: 3px solid #3498db;
}

/* Flecha del ítem con submenú */
.has-submenu {
    display: flex;
    align-items: center;
}
.submenu-arrow {
    font-size: .7rem;
    transition: transform .25s;
    margin-left: auto;
}
.has-submenu[aria-expanded="true"] .submenu-arrow {
    transform: rotate(180deg);
}

/* Sin accesos */
.sidebar-empty {
    display: block;
    padding: 14px 20px;
    color: rgba(255,255,255,.35);
    font-size: .85rem;
    font-style: italic;
}

/* Dropdown toggle */
.dropdown-toggle-sidebar::after {
    content: "\f078";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    float: right;
    transition: transform 0.3s;
    margin-left: 5px;
}

.dropdown-toggle-sidebar.active::after {
    transform: rotate(180deg);
}

/* Top Navbar */
.top-navbar {
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 999;
}

.menu-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #2c3e50;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 5px;
    transition: background 0.3s;
}

.menu-toggle:hover {
    background: #f8f9fa;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-menu .dropdown {
    position: relative;
}

.user-menu .dropdown-toggle {
    background: none;
    border: none;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 8px 15px;
    border-radius: 8px;
    transition: background 0.3s;
}

.user-menu .dropdown-toggle:hover {
    background: #f8f9fa;
}

.user-menu .dropdown-menu {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 10px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 200px;
    display: none;
}

.user-menu .dropdown-menu.show {
    display: block;
}

.user-menu .dropdown-menu a {
    display: block;
    padding: 10px 20px;
    color: #2c3e50;
    text-decoration: none;
    transition: background 0.3s;
}

.user-menu .dropdown-menu a:hover {
    background: #f8f9fa;
}

/* Responsive */
@media (max-width: 768px) {
    #sidebar-wrapper {
        margin-left: -260px;
    }

    #sidebar-wrapper.toggled {
        margin-left: 0;
    }

    #page-content-wrapper {
        margin-left: 0;
    }

    #page-content-wrapper.toggled {
        margin-left: 0;
    }
}

/* Main Content */
.main-content {
    padding: 30px;
    background: #f8f9fa;
    min-height: calc(100vh - 70px);
}

/* ========================================
   TOAST NOTIFICATION SYSTEM
   ======================================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast-notification {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateX(calc(100% + 30px));
    transition: opacity 0.3s ease, transform 0.3s ease;
    will-change: opacity, transform;
    min-width: 300px;
    border-left: 4px solid;
    pointer-events: none;
}

.toast-notification.show {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.toast-notification.hide {
    opacity: 0;
    transform: translateX(calc(100% + 30px));
    pointer-events: none;
}

.toast-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: 14px;
    color: #333;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    font-size: 18px;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.toast-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #333;
}

/* Toast Types */
.toast-notification.toast-success {
    border-left-color: #198754;
}

.toast-notification.toast-success .toast-icon {
    color: #198754;
}

.toast-notification.toast-error {
    border-left-color: #dc3545;
}

.toast-notification.toast-error .toast-icon {
    color: #dc3545;
}

.toast-notification.toast-warning {
    border-left-color: #ffc107;
}

.toast-notification.toast-warning .toast-icon {
    color: #ffc107;
}

.toast-notification.toast-info {
    border-left-color: #0dcaf0;
}

.toast-notification.toast-info .toast-icon {
    color: #0dcaf0;
}

/* Responsive Toast */
@media (max-width: 768px) {
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .toast-notification {
        min-width: auto;
        width: 100%;
    }
}

/* ========================================
   AUTOCOMPLETE DROPDOWN
   ======================================== */
.dropdown-autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ced4da;
    border-top: none;
    border-radius: 0 0 0.25rem 0.25rem;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1050;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-top: -1px;
}

.dropdown-item-autocomplete {
    padding: 10px 15px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid #f0f0f0;
}

.dropdown-item-autocomplete:last-child {
    border-bottom: none;
}

.dropdown-item-autocomplete:hover {
    background-color: #f8f9fa;
}

.dropdown-item-autocomplete strong {
    color: #2c3e50;
    display: block;
    margin-bottom: 2px;
}

.dropdown-item-autocomplete small {
    color: #6c757d;
    font-size: 0.85rem;
}

/* Scrollbar para dropdown */
.dropdown-autocomplete::-webkit-scrollbar {
    width: 8px;
}

.dropdown-autocomplete::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.dropdown-autocomplete::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.dropdown-autocomplete::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ========================================
   COMPONENTES COMUNES DE VISTAS
   ======================================== */

/* Utilidad */
.text-xs { font-size: .78rem; }

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #adb5bd;
}
.empty-state i { font-size: 2rem; margin-bottom: 10px; display: block; }
.empty-state p { margin: 0; font-size: .9rem; }

/* ── KPI Cards (Dashboard) ── */
.kpi-card {
    border-radius: 14px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    overflow: hidden;
    color: #fff;
    min-height: 120px;
}
.kpi-card::after {
    content: '';
    position: absolute;
    width: 100px; height: 100px;
    border-radius: 50%;
    background: rgba(255,255,255,.1);
    top: -20px; right: -20px;
}
.kpi-primary { background: linear-gradient(135deg,#0d6efd,#0a58ca); }
.kpi-success { background: linear-gradient(135deg,#198754,#146c43); }
.kpi-warning { background: linear-gradient(135deg,#e67e22,#d35400); }
.kpi-teal    { background: linear-gradient(135deg,#0d9488,#0f766e); }
.kpi-danger  { background: linear-gradient(135deg,#dc3545,#b02a37); }
.kpi-icon    { font-size: 1.6rem; opacity: .85; }
.kpi-value   { font-size: 2rem; font-weight: 700; line-height: 1; }
.kpi-label   { font-size: .82rem; opacity: .85; }

/* ── Dash Cards ── */
.dash-card {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
    overflow: hidden;
}
.dash-card-header {
    padding: 14px 18px;
    font-weight: 600;
    font-size: .9rem;
    border-bottom: 1px solid #f0f0f0;
    background: #fafafa;
}
.dash-card-body { padding: 16px 18px; }

/* ── Dash Table ── */
.dash-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.dash-table th {
    padding: 10px 14px;
    text-align: left;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #6c757d;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
}
.dash-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f4f4f4;
    vertical-align: middle;
}
.dash-table tr:last-child td { border-bottom: none; }
.dash-table tr:hover td      { background: #fafafa; }

/* ── Hab Row (filas de resumen) ── */
.hab-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 0;
    font-size: .9rem;
    border-bottom: 1px solid #f4f4f4;
}
.hab-row:last-child { border-bottom: none; }

/* ── Sync badges ── */
.sync-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    text-transform: capitalize;
}
.sync-pendiente    { background:#fef3c7; color:#92400e; }
.sync-sincronizado { background:#d1fae5; color:#065f46; }
.sync-conflicto    { background:#fee2e2; color:#991b1b; }

/* ── Avatares de usuario ── */
.usr-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    color: #fff;
    font-size: .9rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.avatar-sm {
    width: 42px; height: 42px;
    border-radius: 50%;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ── Cards de usuario en móvil ── */
.usr-card-item {
    padding: 13px 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background .12s;
}
.usr-card-item:last-child { border-bottom: none; }
.usr-card-item:active     { background: #f8f9fa; }

/* ── Feature cards (Home) ── */
.feature-card {
    border: none;
    border-radius: 14px;
    box-shadow: 0 2px 12px rgba(0,0,0,.07);
    background: #fff;
    height: 100%;
    transition: transform .25s, box-shadow .25s;
}
.feature-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 10px 30px rgba(0,0,0,.12);
}
.feature-icon {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
}
