﻿/* ============================================================
   CERFIN CRM - Estilos Principales
   Azul Marino: #1B2866  |  Dorado: #C8880E
   Fuentes: Raleway (titulos) + DM Sans (cuerpo)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Raleway:wght@400;600;700;900&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
    --primary:       #1B2866;
    --primary-dark:  #121B4D;
    --primary-light: #2A3E9F;
    --gold:          #C8880E;
    --gold-light:    #E5A020;
    --gold-pale:     #FFF3DC;
    --sidebar-w:     262px;
    --bg:            #EEF1FA;
    --white:         #FFFFFF;
    --text:          #1A1F36;
    --text-muted:    #7A869A;
    --border:        #E2E8F0;
    --success:       #27AE60;
    --danger:        #E74C3C;
    --warning:       #F39C12;
    --info:          #2980B9;
    --shadow:        0 2px 14px rgba(27,40,102,.10);
    --shadow-lg:     0 8px 32px rgba(27,40,102,.18);
    --radius:        10px;
    --radius-lg:     16px;
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    overflow-x: hidden;
}
h1,h2,h3,h4,h5,h6 { font-family: 'Raleway', sans-serif; font-weight: 700; }
a { text-decoration: none; }

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

/* ============================================================
   SIDEBAR
   ============================================================ */
#sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--primary);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    z-index: 100;
    box-shadow: 4px 0 20px rgba(0,0,0,.18);
    transition: transform .3s ease;
}

/* Logo */
.sidebar-header {
    padding: 20px 18px 14px;
    border-bottom: 1px solid rgba(255,255,255,.10);
}
.sidebar-logo { display: flex; align-items: center; gap: 12px; }
.logo-icon {
    width: 42px; height: 42px;
    background: var(--gold);
    border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 20px;
    box-shadow: 0 4px 14px rgba(200,136,14,.45);
    flex-shrink: 0;
}
.logo-name {
    display: block;
    font-family: 'Raleway', sans-serif;
    font-weight: 900; font-size: 23px;
    color: #fff; line-height: 1;
    letter-spacing: .5px;
}
.logo-slogan {
    display: block;
    font-size: 10px;
    color: var(--gold-light);
    font-style: italic;
    font-weight: 400;
}

/* Usuario en sidebar */
.sidebar-user {
    padding: 12px 18px;
    display: flex; align-items: center; gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    background: rgba(0,0,0,.18);
}
.user-avatar {
    width: 36px; height: 36px;
    background: var(--gold);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 15px; flex-shrink: 0;
}
.user-name  { display: block; color: #fff; font-weight: 600; font-size: 13px; line-height: 1.3; }
.user-role  { font-size: 10px; color: var(--gold-light); font-weight: 500; }

/* Nav */
.sidebar-nav { list-style: none; padding: 6px 0; margin: 0; flex: 1; overflow-y: auto; }
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 3px; }

.nav-section-title {
    padding: 14px 20px 3px;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: rgba(255,255,255,.32);
}
.sidebar-nav li a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 18px;
    color: rgba(255,255,255,.72);
    font-size: 13.5px; font-weight: 500;
    border-left: 3px solid transparent;
    transition: all .18s;
    margin: 1px 0;
}
.sidebar-nav li a i { width: 18px; text-align: center; font-size: 14px; }
.sidebar-nav li a:hover {
    background: rgba(255,255,255,.08);
    color: #fff; border-left-color: var(--gold);
}
.sidebar-nav li.active > a {
    background: rgba(200,136,14,.18);
    color: var(--gold-light);
    border-left-color: var(--gold);
    font-weight: 700;
}

/* Logout */
.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.10); }
.logout-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 14px;
    color: rgba(255,255,255,.58);
    border-radius: 8px; font-size: 13px;
    transition: all .2s;
}
.logout-btn:hover { background: rgba(231,76,60,.20); color: #ff8080; }

/* ============================================================
   CONTENT AREA
   ============================================================ */
#content {
    margin-left: var(--sidebar-w);
    width: calc(100% - var(--sidebar-w));
    min-height: 100vh;
    display: flex; flex-direction: column;
}

/* TOP BAR */
.topbar {
    background: var(--white);
    padding: 12px 28px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,.05);
    position: sticky; top: 0; z-index: 99;
}
.topbar-title h4 {
    margin: 0; font-size: 18px;
    color: var(--primary);
    font-family: 'Raleway', sans-serif; font-weight: 700;
}
.topbar-title .breadcrumb { margin: 0; font-size: 12px; }
.topbar-title .breadcrumb-item a { color: var(--gold); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-date { font-size: 12px; color: var(--text-muted); }

/* Contenido */
.page-content { padding: 24px 28px; flex: 1; }

/* ============================================================
   CARDS
   ============================================================ */
.card-cerfin {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: none; overflow: hidden;
}
.card-cerfin .card-header {
    background: var(--primary);
    color: white;
    padding: 13px 20px;
    font-family: 'Raleway', sans-serif;
    font-weight: 700; font-size: 14.5px;
    border: none;
    display: flex; align-items: center;
}
.card-cerfin .card-header .header-icon {
    background: rgba(255,255,255,.14);
    width: 30px; height: 30px; border-radius: 7px;
    display: inline-flex; align-items: center; justify-content: center;
    margin-right: 10px; font-size: 13px; flex-shrink: 0;
}

/* STAT CARDS */
.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 18px 22px;
    display: flex; align-items: center; gap: 16px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
    transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card.gold    { border-left-color: var(--gold); }
.stat-card.success { border-left-color: var(--success); }
.stat-card.danger  { border-left-color: var(--danger); }
.stat-card.warning { border-left-color: var(--warning); }

.stat-icon {
    width: 50px; height: 50px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 21px; flex-shrink: 0;
    background: rgba(27,40,102,.08); color: var(--primary);
}
.stat-card.gold    .stat-icon { background: var(--gold-pale);           color: var(--gold);    }
.stat-card.success .stat-icon { background: rgba(39,174,96,.10);        color: var(--success); }
.stat-card.danger  .stat-icon { background: rgba(231,76,60,.10);        color: var(--danger);  }
.stat-card.warning .stat-icon { background: rgba(243,156,18,.10);       color: var(--warning); }

.stat-value { font-size: 26px; font-weight: 900; line-height: 1; font-family: 'Raleway', sans-serif; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-top: 3px; }

/* ============================================================
   TABLAS
   ============================================================ */
.table-cerfin thead th {
    background: var(--primary); color: white;
    font-family: 'Raleway', sans-serif; font-weight: 600;
    font-size: 12px; letter-spacing: .4px;
    padding: 11px 14px; border: none; white-space: nowrap;
}
.table-cerfin tbody tr { transition: background .12s; }
.table-cerfin tbody tr:hover { background: rgba(27,40,102,.03); }
.table-cerfin tbody td { padding: 10px 14px; vertical-align: middle; border-color: var(--border); }

/* ============================================================
   BADGES DE ESTADO
   ============================================================ */
.badge-mora      { background: rgba(231,76,60,.12);  color: var(--danger);  padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-gestion   { background: rgba(243,156,18,.12); color: var(--warning); padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-acuerdo   { background: rgba(41,128,185,.12); color: var(--info);    padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-pagado    { background: rgba(39,174,96,.12);  color: var(--success); padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-castigado { background: rgba(100,100,100,.12);color: #666;           padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-judicial  { background: rgba(142,68,173,.12); color: #8e44ad;        padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-alta      { background: rgba(231,76,60,.12);  color: var(--danger);  padding: 2px 9px;  border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-media     { background: rgba(243,156,18,.12); color: var(--warning); padding: 2px 9px;  border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-baja      { background: rgba(39,174,96,.12);  color: var(--success); padding: 2px 9px;  border-radius: 20px; font-size: 11px; font-weight: 700; }

/* ============================================================
   BOTONES
   ============================================================ */
.btn-cerfin {
    background: var(--primary); color: white; border: none;
    border-radius: 8px; padding: 9px 20px;
    font-weight: 600; font-size: 13px; cursor: pointer;
    display: inline-flex; align-items: center; gap: 7px;
    transition: all .2s;
}
.btn-cerfin:hover { background: var(--primary-light); color: white; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(27,40,102,.28); }

.btn-gold {
    background: var(--gold); color: white; border: none;
    border-radius: 8px; padding: 9px 20px;
    font-weight: 600; font-size: 13px; cursor: pointer;
    display: inline-flex; align-items: center; gap: 7px;
    transition: all .2s;
}
.btn-gold:hover { background: var(--gold-light); color: white; transform: translateY(-1px); }

.btn-sm-icon {
    width: 30px; height: 30px; border-radius: 7px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; border: none; cursor: pointer; transition: all .15s;
}

/* ============================================================
   FORMULARIOS
   ============================================================ */
.form-label { font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 5px; }
.form-control, .form-select {
    border: 1.5px solid var(--border); border-radius: 8px;
    padding: 9px 13px; font-size: 13.5px;
    transition: border .2s, box-shadow .2s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(27,40,102,.10);
    outline: none;
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 55%, var(--primary-light) 100%);
    display: flex; align-items: center; justify-content: center; padding: 20px;
    position: relative; overflow: hidden;
}
.login-page::before {
    content: '';
    position: absolute; inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/svg%3E");
}
.login-card {
    background: white; border-radius: 20px;
    padding: 44px 40px; width: 100%; max-width: 420px;
    box-shadow: 0 24px 64px rgba(0,0,0,.30); position: relative;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-circle {
    width: 72px; height: 72px; background: var(--primary);
    border-radius: 20px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 30px; color: var(--gold); margin-bottom: 12px;
    box-shadow: 0 8px 24px rgba(27,40,102,.30);
}
.login-logo h1 { font-family: 'Raleway', sans-serif; font-weight: 900; font-size: 28px; color: var(--primary); margin: 0; }
.login-logo p  { color: var(--gold); font-size: 12px; font-style: italic; margin: 0; }

/* Dias mora colores */
.dias-0-30   { color: var(--success); font-weight: 700; }
.dias-31-60  { color: var(--warning); font-weight: 700; }
.dias-61-90  { color: #e67e22;        font-weight: 700; }
.dias-90plus { color: var(--danger);  font-weight: 700; }

/* Page header */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 22px; padding-bottom: 14px;
    border-bottom: 2px solid var(--gold);
}
.page-header h3 { margin: 0; font-family: 'Raleway', sans-serif; font-size: 22px; color: var(--primary); }

/* Responsive */
@media (max-width: 768px) {
    #sidebar { transform: translateX(-100%); }
    #sidebar.open { transform: translateX(0); }
    #content { margin-left: 0; width: 100%; }
    .page-content { padding: 16px; }
    .topbar { padding: 10px 16px; }
}
