/* ============================================================
   PANEL DE GESTIÓN — gestion.leizaranwebs.com
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --blue:       #4A90D9;
    --blue-light: #EBF4FF;
    --blue-dark:  #1a5fa8;

    --danger:       #dc3545;
    --danger-light: #fff0f0;
    --warning:      #e67e22;
    --warning-light:#fff8ee;
    --success:      #27ae60;
    --success-light:#f0fff5;
    --muted:        #6c757d;

    --bg:        #f5f6f8;
    --surface:   #ffffff;
    --surface-2: #f8f9fa;
    --border:    #e2e6ea;

    --text:      #1a1a2e;
    --text-2:    #555570;
    --text-3:    #9090a8;

    --sidebar-w: 210px;
    --header-h:  52px;
    --radius:    8px;
    --radius-lg: 12px;
    --shadow:    0 1px 3px rgba(0,0,0,.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 16px; padding: 0 20px;
}

.header-logo {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; font-weight: 600; color: var(--text);
    min-width: var(--sidebar-w);
}

.logo-dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--blue);
    flex-shrink: 0;
}

.header-nav {
    display: flex; gap: 2px; flex: 1;
}

.header-nav a {
    font-size: 12px; padding: 5px 11px; border-radius: var(--radius);
    color: var(--text-2);
    transition: background .15s, color .15s;
}

.header-nav a:hover  { background: var(--surface-2); color: var(--text); }
.header-nav a.active { background: var(--surface-2); color: var(--text); font-weight: 500; border: 1px solid var(--border); }

.header-user {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; color: var(--text-2);
}

.avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--blue-light); color: var(--blue);
    font-size: 11px; font-weight: 600;
    display: flex; align-items: center; justify-content: center;
}

.logout-link { color: var(--text-3); font-size: 16px; display: flex; align-items: center; }
.logout-link:hover { color: var(--danger); }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-layout {
    display: flex;
    margin-top: var(--header-h);
    min-height: calc(100vh - var(--header-h));
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 14px 0;
    position: fixed;
    top: var(--header-h);
    bottom: 0;
    overflow-y: auto;
}

.sidebar-section {
    font-size: 10px; font-weight: 600;
    color: var(--text-3);
    letter-spacing: .06em; text-transform: uppercase;
    padding: 14px 16px 5px;
}

.sidebar-item {
    display: flex; align-items: center; gap: 9px;
    padding: 7px 16px;
    font-size: 13px; color: var(--text-2);
    border-left: 2px solid transparent;
    transition: background .12s, color .12s;
    cursor: pointer;
}

.sidebar-item i { font-size: 16px; width: 18px; flex-shrink: 0; }
.sidebar-item:hover { background: var(--bg); color: var(--text); }
.sidebar-item.active { color: var(--text); font-weight: 500; border-left-color: var(--blue); background: var(--bg); }

/* ============================================================
   CONTENIDO PRINCIPAL
   ============================================================ */
.app-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 24px;
    min-width: 0;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge-danger, .badge-warn {
    margin-left: auto;
    font-size: 10px; font-weight: 600;
    border-radius: 10px; padding: 1px 6px;
}
.badge-danger { background: var(--danger-light);  color: var(--danger); }
.badge-warn   { background: var(--warning-light); color: var(--warning); }

/* ============================================================
   FLASH MESSAGES
   ============================================================ */
.flash {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; border-radius: var(--radius);
    margin-bottom: 20px; font-size: 13px;
}
.flash i { font-size: 18px; }
.flash-ok    { background: var(--success-light); color: var(--success); border: 1px solid #b7e4c7; }
.flash-error { background: var(--danger-light);  color: var(--danger);  border: 1px solid #f5c6cb; }
.flash-warn  { background: var(--warning-light); color: var(--warning); border: 1px solid #ffdda0; }

/* ============================================================
   PÁGINA: CABECERA
   ============================================================ */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.page-title { font-size: 18px; font-weight: 600; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text-3); margin-top: 2px; }

/* ============================================================
   MÉTRICAS (DASHBOARD)
   ============================================================ */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
}
.metric-label { font-size: 11px; color: var(--text-3); margin-bottom: 6px; }
.metric-value { font-size: 26px; font-weight: 600; color: var(--text); line-height: 1; }
.metric-value.danger  { color: var(--danger); }
.metric-value.warning { color: var(--warning); }
.metric-value.success { color: var(--success); }
.metric-sub { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
}

.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px;
}

.card-title {
    font-size: 13px; font-weight: 600; color: var(--text);
    display: flex; align-items: center; gap: 7px;
}
.card-title i { font-size: 16px; color: var(--text-3); }

.card-link {
    font-size: 11px; color: var(--blue);
    background: none; border: none; cursor: pointer; padding: 0;
}

.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ============================================================
   TABLAS
   ============================================================ */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }

table { width: 100%; border-collapse: collapse; }
th {
    font-size: 11px; font-weight: 600; color: var(--text-3);
    text-align: left; padding: 10px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: 13px;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

.td-title { font-weight: 500; color: var(--text); }
.td-sub   { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ============================================================
   PILLS / BADGES
   ============================================================ */
.pill {
    display: inline-block;
    font-size: 10px; font-weight: 600;
    border-radius: 10px; padding: 2px 9px;
    white-space: nowrap;
}
.pill-urgente { background: var(--danger-light);  color: var(--danger); }
.pill-alta    { background: var(--warning-light); color: var(--warning); }
.pill-media   { background: var(--blue-light);    color: var(--blue); }
.pill-baja    { background: var(--surface-2);     color: var(--text-3); border: 1px solid var(--border); }

.pill-pendiente  { background: var(--surface-2);     color: var(--text-3); border: 1px solid var(--border); }
.pill-en_curso   { background: var(--blue-light);    color: var(--blue); }
.pill-esperando  { background: var(--warning-light); color: var(--warning); }
.pill-completada { background: var(--success-light); color: var(--success); }
.pill-cancelada  { background: #f8f8f8; color: var(--text-3); text-decoration: line-through; }

.pill-tipo { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); font-size: 10px; font-weight: 500; border-radius: 10px; padding: 2px 8px; white-space: nowrap; }

.pill-cobrada   { background: var(--success-light); color: var(--success); }
.pill-parcial   { background: var(--warning-light); color: var(--warning); }
.pill-incobrable{ background: var(--danger-light);  color: var(--danger); }

/* ============================================================
   ACCIONES DE TABLA
   ============================================================ */
.actions { display: flex; gap: 4px; }
.btn-icon {
    background: none; border: none; cursor: pointer;
    color: var(--text-3); font-size: 16px;
    padding: 4px; border-radius: 6px;
    display: flex; align-items: center;
    transition: color .12s, background .12s;
}
.btn-icon:hover         { color: var(--text); background: var(--surface-2); }
.btn-icon.danger:hover  { color: var(--danger); }
.btn-icon.success:hover { color: var(--success); }

/* ============================================================
   FILTROS
   ============================================================ */
.filters {
    display: flex; align-items: center; gap: 8px;
    flex-wrap: wrap; margin-bottom: 16px;
}
.filter-tab {
    font-size: 12px; padding: 5px 12px;
    border-radius: var(--radius); border: 1px solid var(--border);
    background: var(--surface); color: var(--text-2); cursor: pointer;
}
.filter-tab.active { background: var(--surface-2); color: var(--text); font-weight: 500; border-color: #ccc; }
.filter-select {
    font-size: 12px; padding: 5px 10px;
    border-radius: var(--radius); border: 1px solid var(--border);
    background: var(--surface); color: var(--text-2); cursor: pointer;
}
.filter-sep { width: 1px; height: 20px; background: var(--border); margin: 0 2px; }
.search-wrap {
    margin-left: auto;
    display: flex; align-items: center; gap: 6px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 5px 10px;
}
.search-wrap i { font-size: 14px; color: var(--text-3); }
.search-wrap input { border: none; background: none; font-size: 12px; color: var(--text); outline: none; width: 160px; }

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 13px; font-weight: 500;
    padding: 8px 16px; border-radius: var(--radius);
    border: none; cursor: pointer; transition: opacity .15s;
}
.btn:hover { opacity: .88; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-sm { font-size: 12px; padding: 5px 12px; }

/* ============================================================
   FORMULARIOS
   ============================================================ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-full { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 12px; font-weight: 500; color: var(--text-2); }

input[type=text], input[type=email], input[type=password],
input[type=number], input[type=date], input[type=datetime-local],
select, textarea {
    font-size: 13px; color: var(--text);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 8px 10px;
    width: 100%; outline: none;
    transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); }
textarea { resize: vertical; min-height: 80px; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    display: none; position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,.35);
    align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--surface); border-radius: var(--radius-lg);
    padding: 24px; width: 560px; max-width: 95vw;
    max-height: 90vh; overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,.15);
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 20px; color: var(--text-3); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: var(--bg);
}
.login-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 36px 32px; width: 380px;
}
.login-logo {
    display: flex; align-items: center; gap: 10px;
    font-size: 16px; font-weight: 600; margin-bottom: 28px;
}

/* ============================================================
   ITEMS DE LISTA (dashboard cards)
   ============================================================ */
.list-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 0; border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; padding-bottom: 0; }
.list-item-text { flex: 1; min-width: 0; }
.list-item-title { font-size: 12px; color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-sub   { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot-danger  { background: var(--danger); }
.dot-warning { background: var(--warning); }
.dot-blue    { background: var(--blue); }
.dot-muted   { background: var(--text-3); }

.amount { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; }

/* ============================================================
   UTILIDADES
   ============================================================ */
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-success { color: var(--success); }
.text-muted   { color: var(--text-3); }
.text-right   { text-align: right; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.fw-500 { font-weight: 500; }
.fs-11  { font-size: 11px; }
.fs-12  { font-size: 12px; }

/* Columna acciones visible siempre */
td .actions { display: flex; gap: 4px; min-width: 70px; }
td:last-child { min-width: 80px; }

/* Tamaño letra tablas */
td { font-size: 14px !important; }
th { font-size: 12px !important; }
.td-title { font-size: 14px !important; }
.td-sub { font-size: 12px !important; }
a[style*="font-size:12px"] { font-size: 14px !important; }

/* Clientes de baja */
tr.fila-baja td { color: #bbb !important; }
tr.fila-baja td a { color: #bbb !important; }
tr.fila-baja td strong { color: #bbb !important; }
tr.fila-baja { background: #fafafa !important; }

/* Clientes de baja - fuerza gris en todo */
tr.fila-baja td,
tr.fila-baja td *,
tr.fila-baja td a,
tr.fila-baja .td-title,
tr.fila-baja .td-sub,
tr.fila-baja span,
tr.fila-baja strong { 
    color: #ccc !important; 
}
tr.fila-baja { background-color: #fafafa !important; }

/* Kit Digital — expedientes finalizados */
tr.fila-finalizada td,
tr.fila-finalizada td * { color: #bbb !important; }
tr.fila-finalizada { background: #fafafa !important; }

/* Kit Digital — plazo vencido */
tr.fila-vencida td { background: #fff5f5 !important; }
tr.fila-vencida td .td-title { color: var(--danger) !important; font-weight: 600 !important; }
tr.fila-vencida { border-left: 3px solid var(--danger); }

/* Kit Digital — plazo próximo (30 días) */
tr.fila-proxima td { background: #fffbf0 !important; }
tr.fila-proxima td .td-title { color: var(--warning) !important; font-weight: 600 !important; }
tr.fila-proxima { border-left: 3px solid var(--warning); }

/* Modal scroll en pantallas pequeñas */
.modal { max-height: 90vh; overflow-y: auto; }

/* Empresa facturación en clientes */
.emp-leizaran { color: #2563eb; font-weight: 500; }
.emp-optimiza { color: #7c3aed; font-weight: 500; }

/* Empresa facturación */
.emp-leizaran { color: #2563eb; font-weight: 600; border-color: #bfdbfe; background: #eff6ff; }
.emp-optimiza { color: #7c3aed; font-weight: 600; border-color: #ddd6fe; background: #f5f3ff; }

/* Empresa facturación v2 */
.emp-leizaran { color: #1d4ed8 !important; font-weight: 600 !important; border-color: #93c5fd !important; background: #dbeafe !important; }
.emp-optimiza { color: #6d28d9 !important; font-weight: 600 !important; border-color: #c4b5fd !important; background: #ede9fe !important; }

/* Empresa facturación v3 */
.emp-leizaran { color: #0369a1 !important; font-weight: 500 !important; border-color: #7dd3fc !important; background: #e0f2fe !important; }
.emp-optimiza { color: #b45309 !important; font-weight: 500 !important; border-color: #fcd34d !important; background: #fef3c7 !important; }
