/* ============================================================
   GW PROVEEDORES - Estilos principales
   Bootstrap 5.3 + Tema claro/oscuro + Custom
   ============================================================ */

/* ---------- Variables CSS ---------- */
:root {
    --bg-body:        #f0f2f5;
    --bg-sidebar:     #1e293b;
    --bg-sidebar-alt: #0f172a;
    --bg-card:        #ffffff;
    --bg-topbar:      #ffffff;
    --text-primary:   #1e293b;
    --text-secondary: #64748b;
    --text-sidebar:   #94a3b8;
    --text-sidebar-active: #ffffff;
    --border-color:   #e2e8f0;
    --shadow-sm:      0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:      0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
    --shadow-card:    0 0 0 1px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.06);
    --accent:         #1a56db;
    --accent-hover:   #1e40af;
    --accent-light:   #dbeafe;
    --success-light:  #d1fae5;
    --warn-light:     #fef3c7;
    --danger-light:   #fee2e2;
    --sidebar-width:  260px;
    --topbar-height:  60px;
    --radius:         10px;
    --radius-sm:      6px;
    --transition:     .2s ease;
}

[data-bs-theme="dark"] {
    --bg-body:        #0f172a;
    --bg-sidebar:     #020617;
    --bg-sidebar-alt: #020617;
    --bg-card:        #1e293b;
    --bg-topbar:      #1e293b;
    --text-primary:   #e2e8f0;
    --text-secondary: #94a3b8;
    --text-sidebar:   #64748b;
    --border-color:   #334155;
    --shadow-sm:      0 1px 3px rgba(0,0,0,.3);
    --shadow-md:      0 4px 6px rgba(0,0,0,.4);
    --shadow-card:    0 0 0 1px rgba(255,255,255,.04), 0 2px 8px rgba(0,0,0,.3);
    --accent-light:   #1e3a5f;
    --success-light:  #064e3b;
    --warn-light:     #451a03;
    --danger-light:   #450a0a;
}

/* ---------- Reset base ---------- */
*, *::before, *::after { box-sizing: border-box; }

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

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

/* ---------- SIDEBAR ---------- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 1000;
    transition: transform var(--transition);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}

.sidebar-brand {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,.06);
    display: flex;
    align-items: center;
    gap: .75rem;
    text-decoration: none;
}

.sidebar-brand .brand-icon {
    width: 36px; height: 36px;
    background: var(--accent);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-brand .brand-name {
    color: #fff;
    font-weight: 700;
    font-size: .97rem;
    letter-spacing: -.01em;
    line-height: 1.2;
}

.sidebar-brand .brand-sub {
    color: var(--text-sidebar);
    font-size: .72rem;
    margin-top: 1px;
}

/* Nav grupos */
.sidebar-group {
    padding: .75rem 0 .25rem;
}

.sidebar-group-label {
    padding: .5rem 1.25rem .35rem;
    font-size: .67rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-sidebar);
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1.25rem;
    color: #94a3b8;
    text-decoration: none;
    border-radius: var(--radius-sm);
    margin: 1px .5rem;
    transition: background var(--transition), color var(--transition);
    font-size: .95rem;
    font-weight: 500;
}

.sidebar-nav a .nav-icon {
    width: 22px;
    flex-shrink: 0;
    text-align: center;
    font-size: 1.15rem;
    opacity: .7;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255,255,255,.06);
    color: #fff;
}

.sidebar-nav a.active {
    background: rgba(26, 86, 219, .25);
    color: #93c5fd;
}

.sidebar-nav a.active .nav-icon {
    opacity: 1;
}

.sidebar-footer {
    margin-top: auto;
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,.06);
}

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

.topbar {
    height: var(--topbar-height);
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 900;
    transition: background var(--transition);
    box-shadow: var(--shadow-sm);
}

.topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.topbar .btn-icon {
    width: 40px; height: 40px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition);
    font-size: 1.15rem;
}

.topbar .btn-icon:hover {
    background: var(--bg-body);
    color: var(--text-primary);
    border-color: var(--accent);
}

.topbar .user-pill {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .3rem .75rem .3rem .4rem;
    border-radius: 100px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all var(--transition);
    background: transparent;
    color: var(--text-primary);
}

.topbar .user-pill:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.user-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: .78rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

/* ---------- CONTENIDO ---------- */
.page-content {
    padding: 1.5rem;
    flex: 1;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.breadcrumb-wrapper {
    font-size: .8rem;
    color: var(--text-secondary);
    margin-top: .2rem;
}

/* ============================================================
   CARDS
   ============================================================ */
.card-gw {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    transition: background var(--transition);
}

.card-gw .card-header-gw {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}

.card-gw .card-header-gw h5,
.card-gw .card-header-gw h6 {
    margin: 0;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body-gw {
    padding: 1.25rem;
}

/* KPI Cards */
.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-card);
    transition: transform var(--transition), box-shadow var(--transition);
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.kpi-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.kpi-value {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text-primary);
}

.kpi-label {
    font-size: .78rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: .2rem;
}

/* ============================================================
   TABLAS
   ============================================================ */
.table-gw {
    margin: 0;
    font-size: .95rem;
}

.table-gw thead th {
    border-bottom: 2px solid var(--border-color);
    background: var(--bg-body);
    color: var(--text-secondary);
    font-size: .85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: .85rem 1rem;
    white-space: nowrap;
}

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

.table-gw tbody tr:last-child td { border-bottom: none; }

.table-gw tbody tr:hover td {
    background: var(--bg-body);
}

/* ============================================================
   FORMULARIOS
   ============================================================ */
.form-label {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: .3rem;
}

.form-control, .form-select {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: .5rem .75rem;
    font-size: .9rem;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(26,86,219,.12);
    background: var(--bg-card);
    color: var(--text-primary);
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background: #0f172a;
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background: #0f172a;
}

.form-section-title {
    font-size: .78rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: .08em;
    padding-bottom: .5rem;
    border-bottom: 2px solid var(--accent-light);
    margin-bottom: 1rem;
}

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: .95rem;
    padding: .5rem 1rem;
    transition: all var(--transition);
}

.btn-accent {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-accent:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
}

.btn-gw-outline {
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-primary);
}

.btn-gw-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ============================================================
   BADGES ESTADO
   ============================================================ */
.badge {
    font-size: .82rem;
    font-weight: 600;
    border-radius: 100px;
    padding: .4em .85em;
}

/* ============================================================
   ALERTAS FLASH
   ============================================================ */
.flash-container {
    position: fixed;
    top: calc(var(--topbar-height) + 1rem);
    right: 1rem;
    z-index: 2000;
    min-width: 300px;
    max-width: 450px;
}

.flash-item {
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    animation: slideIn .3s ease;
}

@keyframes slideIn {
    from { transform: translateX(20px); opacity: 0; }
    to   { transform: translateX(0);   opacity: 1; }
}

/* ============================================================
   TABS
   ============================================================ */
.nav-tabs-gw {
    border-bottom: 2px solid var(--border-color);
    gap: .25rem;
}

.nav-tabs-gw .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    padding: .6rem 1rem;
    font-size: .85rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: 0;
    margin-bottom: -2px;
    transition: all var(--transition);
}

.nav-tabs-gw .nav-link:hover { color: var(--text-primary); }
.nav-tabs-gw .nav-link.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: transparent;
}

/* ============================================================
   LOG TIMELINE
   ============================================================ */
.timeline {
    position: relative;
    padding-left: 1.5rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: .5rem;
    top: 4px; bottom: 4px;
    width: 2px;
    background: var(--border-color);
    border-radius: 2px;
}

.timeline-item {
    position: relative;
    padding-bottom: 1.25rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -1.06rem;
    top: .35rem;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-card);
}

.timeline-date {
    font-size: .72rem;
    color: var(--text-secondary);
    margin-bottom: .15rem;
}

.timeline-text {
    font-size: .85rem;
    color: var(--text-primary);
}

/* ============================================================
   ESTADO VIGENCIA
   ============================================================ */
.vigencia-bar {
    height: 6px;
    border-radius: 100px;
    background: var(--border-color);
    overflow: hidden;
}

.vigencia-bar-fill {
    height: 100%;
    border-radius: 100px;
    transition: width .5s ease;
}

/* ============================================================
   BÚSQUEDA Y FILTROS
   ============================================================ */
.filtros-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

/* ============================================================
   UPLOAD ZONA
   ============================================================ */
.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-body);
}

.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-light);
}

.upload-zone-icon { font-size: 2.5rem; opacity: .4; }

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.sidebar-open {
        transform: translateX(0);
        box-shadow: 0 0 40px rgba(0,0,0,.3);
    }
    .app-main {
        margin-left: 0;
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.5);
        z-index: 999;
    }
    .sidebar-overlay.active { display: block; }
}

@media (max-width: 575.98px) {
    .page-content { padding: 1rem; }
    .kpi-value { font-size: 1.4rem; }
}

/* ============================================================
   AUTH PÁGINAS (login, recuperar)
   ============================================================ */
.auth-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 60%, #1a56db 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px rgba(0,0,0,.25);
}

.auth-logo {
    width: 52px; height: 52px;
    background: var(--accent);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
    color: #fff;
    margin: 0 auto 1.25rem;
}

/* ============================================================
   FORMULARIO PÚBLICO (Proveedor externo)
   ============================================================ */
.public-page {
    min-height: 100vh;
    background: var(--bg-body);
}

.public-header {
    background: var(--bg-sidebar);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* ============================================================
   MISC
   ============================================================ */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cursor-pointer { cursor: pointer; }

.separator {
    height: 1px;
    background: var(--border-color);
    margin: 1.25rem 0;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state-icon { font-size: 3rem; opacity: .25; margin-bottom: .75rem; }
.empty-state h6   { font-weight: 600; color: var(--text-primary); }
.empty-state p    { font-size: .875rem; margin: 0; }
