/* =====================================================
   COBRO360PRO - Estilos Principales
   Control Total de Tu Gestión de Cobranza
   ===================================================== */

:root {
    /* Colores de marca */
    --brand-navy: #1B2A4A;
    --brand-blue: #2D6EB5;
    --brand-light: #3B8DD4;
    --brand-gray: #7A8599;

    /* Sistema */
    --primary: #1B2A4A;
    --primary-light: #2D6EB5;
    --primary-lighter: #3B8DD4;
    --secondary: #E8505B;
    --accent: #16a085;

    /* Fondos */
    --bg-main: #F4F6FA;
    --bg-card: #FFFFFF;
    --bg-sidebar: #1B2A4A;
    --bg-sidebar-hover: #243557;
    --bg-sidebar-active: #2D6EB5;

    /* Texto */
    --text-primary: #1B2A4A;
    --text-secondary: #7A8599;
    --text-light: #B0BFCF;
    --text-white: #FFFFFF;

    /* Estados */
    --success: #00b894;
    --warning: #fdcb6e;
    --danger: #d63031;
    --info: #2D6EB5;

    /* Resultados de gestión */
    --gestion-pago: #22c55e;
    --gestion-promesa: #84cc16;
    --gestion-contacto: #eab308;
    --gestion-tercero: #f97316;
    --gestion-no-localizado: #ef4444;
    --gestion-rechazo: #dc2626;
    --gestion-otro: #8b5cf6;

    /* Gradientes */
    --gradient-brand: linear-gradient(135deg, #1B2A4A 0%, #2D6EB5 50%, #3B8DD4 100%);
    --gradient-sidebar: linear-gradient(180deg, #1B2A4A 0%, #162238 100%);
    --gradient-button: linear-gradient(135deg, #2D6EB5 0%, #3B8DD4 100%);

    /* Layout */
    --sidebar-width: 260px;
    --navbar-height: 56px;
    --bottom-nav-height: 60px;
}

/* ===== Reset & Base ===== */
* { box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6, .navbar-brand, .brand-text {
    font-family: 'Exo 2', sans-serif;
}

/* ===== Brand Logo Text ===== */
.brand-logo-text {
    font-family: 'Exo 2', sans-serif;
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: -0.02em;
}
.brand-logo-text .co { color: #fff; }
.brand-logo-text .bro360 { color: #8BB8E0; }
.brand-logo-text .pro { color: #fff; }

/* ===== Offline Bar ===== */
.offline-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1060;
    background: var(--danger);
    color: white;
    text-align: center;
    padding: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}
.offline-bar ~ .navbar { top: 32px; }
.offline-bar ~ .sidebar { top: calc(var(--navbar-height) + 32px); }
.offline-bar ~ .main-content { padding-top: calc(var(--navbar-height) + 32px); }

/* ===== Navbar ===== */
#main-navbar {
    background: var(--gradient-sidebar);
    height: var(--navbar-height);
    z-index: 1040;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--navbar-height));
    background: var(--gradient-sidebar);
    z-index: 1030;
    overflow-y: auto;
    transition: transform 0.3s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.sidebar-header {
    padding: 20px 16px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-user-avatar {
    font-size: 2rem;
    color: var(--brand-light);
}

.sidebar-user-name {
    color: var(--text-white);
    font-weight: 600;
    font-size: 0.9rem;
}

.sidebar-user-role {
    color: var(--text-light);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-nav {
    padding: 8px 0;
}

.sidebar-nav .nav-section {
    color: var(--text-light);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 16px 20px 6px;
    font-weight: 600;
}

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
    border-left: 3px solid transparent;
}

.sidebar-nav .nav-item:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-white);
}

.sidebar-nav .nav-item.active {
    background: var(--bg-sidebar-active);
    color: var(--text-white);
    border-left-color: var(--brand-light);
}

.sidebar-nav .nav-item i {
    width: 24px;
    margin-right: 12px;
    font-size: 1.1rem;
    text-align: center;
}

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1025;
}

/* ===== Main Content ===== */
.main-content {
    margin-left: var(--sidebar-width);
    padding-top: var(--navbar-height);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

/* ===== Bottom Navigation (Mobile/Cobrador) ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--bg-card);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 1030;
    border-top: 1px solid #e2e8f0;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.7rem;
    padding: 4px 12px;
    transition: color 0.2s;
}

.bottom-nav-item i { font-size: 1.3rem; margin-bottom: 2px; }
.bottom-nav-item.active { color: var(--primary-light); }
.bottom-nav-item:hover { color: var(--primary); }

.bottom-nav-add {
    background: var(--gradient-button);
    color: white !important;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    margin-top: -20px;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(45,110,181,0.4);
}
.bottom-nav-add i { font-size: 1.5rem; margin: 0; }
.bottom-nav-add span { display: none; }

/* ===== KPI Cards ===== */
.kpi-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid rgba(0,0,0,0.04);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.kpi-card .kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: white;
}

.kpi-card .kpi-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-card .kpi-value {
    font-family: 'Exo 2', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.kpi-card .kpi-change {
    font-size: 0.8rem;
    font-weight: 600;
}

.kpi-change.positive { color: var(--success); }
.kpi-change.negative { color: var(--danger); }

/* ===== Cards ===== */
.card-cobro {
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid rgba(0,0,0,0.04);
    overflow: hidden;
}

.card-cobro .card-header {
    background: transparent;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    padding: 16px 20px;
    font-family: 'Exo 2', sans-serif;
    font-weight: 600;
    color: var(--text-primary);
}

.card-cobro .card-body { padding: 20px; }

/* ===== Tables ===== */
.table-cobro {
    font-size: 0.9rem;
}

.table-cobro thead th {
    background: var(--bg-main);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e2e8f0;
    padding: 10px 12px;
    white-space: nowrap;
}

.table-cobro tbody td {
    padding: 12px;
    vertical-align: middle;
    border-color: #f0f2f5;
}

.table-cobro tbody tr:hover {
    background-color: rgba(45,110,181,0.04);
}

/* ===== Badges ===== */
.badge-estado {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-activo { background: #dcfce7; color: #166534; }
.badge-inactivo { background: #fef2f2; color: #991b1b; }
.badge-suspendido { background: #fefce8; color: #854d0e; }

/* ===== Buttons ===== */
.btn-primary-cobro {
    background: var(--gradient-button);
    border: none;
    color: white;
    font-weight: 600;
    border-radius: 8px;
    padding: 8px 20px;
    transition: transform 0.15s, box-shadow 0.15s;
}
.btn-primary-cobro:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(45,110,181,0.3);
    color: white;
}

/* ===== Toast ===== */
.toast-cobro {
    border-radius: 10px;
    border: none;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

/* ===== Page Header ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h2 {
    font-weight: 700;
    margin: 0;
    font-size: 1.5rem;
}

/* ===== Search & Filters ===== */
.search-box {
    position: relative;
}
.search-box input {
    padding-left: 36px;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
}
.search-box input:focus {
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px rgba(45,110,181,0.15);
}
.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

/* ===== Responsive ===== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .sidebar-overlay.show {
        display: block;
    }
    .main-content {
        margin-left: 0;
    }
}

@media (max-width: 767.98px) {
    .page-header h2 { font-size: 1.25rem; }
    .kpi-card .kpi-value { font-size: 1.4rem; }
    .kpi-card { padding: 14px; }

    /* Table responsive as cards */
    .table-responsive-cards thead { display: none; }
    .table-responsive-cards tbody tr {
        display: block;
        margin-bottom: 12px;
        background: var(--bg-card);
        border-radius: 8px;
        border: 1px solid #e2e8f0;
        padding: 12px;
    }
    .table-responsive-cards tbody td {
        display: flex;
        justify-content: space-between;
        padding: 4px 0;
        border: none;
    }
    .table-responsive-cards tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.8rem;
    }
}

/* Bottom nav visible only for cobrador on mobile */
body.role-cobrador .bottom-nav { display: flex !important; }
body.role-cobrador .main-content { padding-bottom: var(--bottom-nav-height); }
body.role-cobrador .sidebar { display: none; }
body.role-cobrador .main-content { margin-left: 0; }

/* ===== Loading Skeleton ===== */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}
@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a8a8a8; }

/* ===== Sync Animations ===== */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spin { animation: spin 1s linear infinite; display: inline-block; }

.syncing-bar {
    background: var(--brand-blue) !important;
    animation: pulse-bar 2s ease-in-out infinite;
}

.error-bar {
    background: var(--danger) !important;
}

@keyframes pulse-bar {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

/* Offline bar when NOT d-none adjusts layout */
.offline-bar:not(.d-none) ~ .navbar { top: 32px; }
.offline-bar:not(.d-none) ~ .sidebar { top: calc(var(--navbar-height) + 32px); }
.offline-bar:not(.d-none) ~ .main-content { padding-top: calc(var(--navbar-height) + 32px); }

/* Sync indicator pulse */
#sync-indicator:not(.d-none) {
    animation: pulse-indicator 1.5s ease-in-out infinite;
}

@keyframes pulse-indicator {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Pending count badge animation */
#pending-count:not(.d-none) {
    animation: bounce-badge 2s ease-in-out infinite;
}

@keyframes bounce-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Offline data indicator */
.offline-data-badge {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* ===== Map ===== */
.map-container {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.gestion-popup img {
    border-radius: 6px;
    margin-bottom: 8px;
}

.gestion-popup h6 {
    margin-bottom: 4px;
    color: var(--text-primary);
}

.gestion-popup p {
    margin-bottom: 2px;
    font-size: 0.85rem;
}
