/* ============================================================
   POLIZAS SEGUROS — Estilos Personalizados
   ============================================================ */

/* ── Variables de color ────────────────────────────────────── */
:root {
  --primary:      #0d47a1;
  --primary-dark: #0a3882;
  --primary-light:#1565c0;
  --accent:       #ff6f00;
  --accent-hover: #e65100;
  --sidebar-bg:   #0d2b5e;
  --sidebar-text: rgba(255,255,255,.75);
  --sidebar-w:    260px;
  --topbar-h:     60px;
  --surface:      #f4f6fb;
  --border:       #dee2e6;
  --shadow-sm:    0 2px 8px rgba(0,0,0,.08);
  --shadow-md:    0 4px 16px rgba(0,0,0,.12);
  --radius:       .5rem;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--surface);
  color: #212529;
  min-height: 100vh;
}

/* ── LOGIN PAGE ─────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0d2b5e 0%, #1565c0 50%, #0d47a1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 80%, rgba(255,111,0,.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(21,101,192,.3) 0%, transparent 50%);
}

.login-card {
  background: #fff;
  border-radius: 1.25rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  width: 100%;
  max-width: 440px;
  padding: 2.5rem 2rem;
  position: relative;
  z-index: 1;
}

.login-logo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}

.login-logo i { font-size: 1.75rem; color: #fff; }

.login-logo-img {
  text-align: center;
  margin: 0 auto 0.5rem;
}

.sia-logo {
  max-height: 100px;
  max-width: 220px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

.login-title { font-size: 1.5rem; font-weight: 700; color: var(--primary); text-align: center; }
.login-subtitle { font-size: .85rem; color: #6c757d; text-align: center; margin-bottom: 1.75rem; }

.form-label { font-size: .85rem; font-weight: 600; color: #495057; }

.input-group-text {
  background: var(--surface);
  border-right: none;
  color: var(--primary);
}

.form-control {
  border-left: none;
  transition: border-color .2s, box-shadow .2s;
}

.form-control:focus {
  box-shadow: 0 0 0 3px rgba(13,71,161,.15);
  border-color: var(--primary-light);
}

.input-group:focus-within .input-group-text {
  border-color: var(--primary-light);
}

.btn-login {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border: none;
  color: #fff;
  font-weight: 600;
  padding: .75rem 1rem;
  border-radius: var(--radius);
  letter-spacing: .3px;
  transition: opacity .2s, transform .1s;
}

.btn-login:hover   { opacity: .9; transform: translateY(-1px); color: #fff; }
.btn-login:active  { transform: translateY(0); }
.btn-login:disabled{ opacity: .65; transform: none; }

.login-footer { font-size: .78rem; color: #adb5bd; text-align: center; margin-top: 1.5rem; }

/* ── SIDEBAR ─────────────────────────────────────────────────── */
#sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1050;
  transition: transform .3s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }

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

.sidebar-brand-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, #ff8f00 100%);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand-icon i { color: #fff; font-size: 1.1rem; }

.sidebar-brand-text { color: #fff; }
.sidebar-brand-name { font-size: .95rem; font-weight: 700; line-height: 1.2; display: block; }
.sidebar-brand-sub  { font-size: .68rem; color: rgba(255,255,255,.5); }

.sidebar-nav { padding: 1rem 0; flex: 1; }

.nav-section-title {
  font-size: .65rem;
  font-weight: 700;
  color: rgba(255,255,255,.35);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: .75rem 1.5rem .35rem;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem 1.5rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .875rem;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
  cursor: pointer;
}

.sidebar-item:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
  text-decoration: none;
}

.sidebar-item.active {
  background: rgba(255,255,255,.1);
  color: #fff;
  border-left-color: var(--accent);
}

.sidebar-item i { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-item .badge {
  margin-left: auto;
  font-size: .65rem;
}

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

.sidebar-user {
  display: flex;
  align-items: center;
  gap: .65rem;
  color: var(--sidebar-text);
}

.sidebar-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: .85rem;
  flex-shrink: 0;
}

.sidebar-user-name  { font-size: .82rem; font-weight: 600; color: #fff; line-height: 1.2; display: block; }
.sidebar-user-role  { font-size: .7rem; color: rgba(255,255,255,.45); }

/* ── TOPBAR ──────────────────────────────────────────────────── */
#topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  z-index: 1040;
  box-shadow: var(--shadow-sm);
}

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

.topbar-actions { display: flex; align-items: center; gap: .5rem; }

.topbar-btn {
  width: 38px; height: 38px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  color: #6c757d;
  transition: all .2s;
  cursor: pointer;
  text-decoration: none;
}

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

/* ── MAIN CONTENT ────────────────────────────────────────────── */
#main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 1.5rem;
  min-height: calc(100vh - var(--topbar-h));
}

/* ── STAT CARDS ──────────────────────────────────────────────── */
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: box-shadow .2s;
}

.stat-card:hover { box-shadow: var(--shadow-md); }

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

.stat-icon.blue     { background: rgba(13,71,161,.1);   color: var(--primary); }
.stat-icon.green    { background: rgba(25,135,84,.1);   color: #198754; }
.stat-icon.orange   { background: rgba(253,126,20,.1);  color: #fd7e14; }
.stat-icon.red      { background: rgba(220,53,69,.1);   color: #dc3545; }
.stat-icon.red-dark { background: rgba(176,0,32,.16);   color: #b71c1c; }

.stat-label { font-size: .78rem; color: #6c757d; font-weight: 500; text-transform: uppercase; letter-spacing: .4px; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: #212529; line-height: 1.1; }

/* ── CARDS ───────────────────────────────────────────────────── */
.card {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
  border-radius: var(--radius) var(--radius) 0 0 !important;
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}

.card-title { font-size: 1rem; font-weight: 700; color: var(--primary); margin: 0; }

/* ── STATUS BADGES ───────────────────────────────────────────── */
.badge-status {
  font-size: .72rem;
  font-weight: 600;
  padding: .3em .65em;
  border-radius: 20px;
  white-space: nowrap;
}

.badge-activo    { background: rgba(25,135,84,.15);  color: #198754; }
.badge-pendiente { background: rgba(253,126,20,.15); color: #e05d00; }
.badge-vencido   { background: rgba(220,53,69,.15);  color: #dc3545; }
.badge-cancelado { background: rgba(220,53,69,.12);  color: #c0392b; }

/* ── BOTONES ─────────────────────────────────────────────────── */
.btn-add {
  background: linear-gradient(135deg, var(--accent) 0%, #ff8f00 100%);
  border: none;
  color: #fff;
  font-weight: 600;
  font-size: .875rem;
  padding: .5rem 1.25rem;
  border-radius: var(--radius);
  transition: opacity .2s, transform .1s;
  white-space: nowrap;
}

.btn-add:hover  { opacity: .9; color: #fff; transform: translateY(-1px); }
.btn-add:active { transform: translateY(0); }

.btn-action {
  font-size: .78rem;
  padding: .3rem .65rem;
  border-radius: .35rem;
}

/* ── TABLE ACTION BUTTONS ────────────────────────────────── */
.btn-tbl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: .4rem;
  border: none;
  font-size: .73rem;
  transition: background .15s, color .15s, transform .1s;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-tbl:active { transform: scale(.9); }

.btn-tbl-edit             { background: #e8f0fe; color: #1565c0; }
.btn-tbl-edit:hover       { background: #1565c0; color: #fff; }

.btn-tbl-deactivate       { background: #fff3e0; color: #e65100; }
.btn-tbl-deactivate:hover { background: #e65100; color: #fff; }

.btn-tbl-activate         { background: #e8f5e9; color: #2e7d32; }
.btn-tbl-activate:hover   { background: #2e7d32; color: #fff; }

.btn-tbl-delete           { background: #ffebee; color: #c62828; }
.btn-tbl-delete:hover     { background: #c62828; color: #fff; }

.btn-tbl-view             { background: #e3f2fd; color: #0277bd; }
.btn-tbl-view:hover       { background: #0277bd; color: #fff; }

.tbl-actions {
  display: flex;
  align-items: center;
  gap: .3rem;
  justify-content: center;
  flex-wrap: nowrap;
}

.dt-nowrap { white-space: nowrap; }

/* ── DATATABLE ───────────────────────────────────────────────── */
.dataTables_wrapper .dataTables_filter input {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .35rem .75rem;
  font-size: .875rem;
  outline: none;
  transition: border-color .2s;
}

.dataTables_wrapper .dataTables_filter input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(13,71,161,.1);
}

.dataTables_wrapper .dataTables_length select {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .3rem 1.75rem .3rem .6rem;
  font-size: .875rem;
  min-width: 62px;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23495057' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right .5rem center;
  background-size: 10px 8px;
}

.dataTables_wrapper .dataTables_info { font-size: .8rem; color: #6c757d; }

.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: .35rem !important;
  font-size: .82rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--primary) !important;
}

table.dataTable thead th {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: #495057;
  background: var(--surface);
  white-space: nowrap;
}

table.dataTable tbody td { font-size: .85rem; vertical-align: middle; }

table.dataTable tbody tr:hover { background: rgba(13,71,161,.04); }

/* ── MODALES ─────────────────────────────────────────────────── */
.modal-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  border-bottom: none;
}

.modal-header .btn-close { filter: invert(1) grayscale(1); }
.modal-title { font-weight: 700; font-size: 1rem; }

/* Timeline de historial */
.timeline { position: relative; padding-left: 1.5rem; }
.timeline::before {
  content: '';
  position: absolute;
  left: .5rem;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--border);
}

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

.timeline-dot {
  position: absolute;
  left: -1.25rem;
  top: .25rem;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--primary);
}

.timeline-dot.pago      { background: #198754; box-shadow: 0 0 0 2px #198754; }
.timeline-dot.creacion  { background: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.timeline-dot.actualiz  { background: #0dcaf0; box-shadow: 0 0 0 2px #0dcaf0; }

.timeline-date    { font-size: .72rem; color: #6c757d; margin-bottom: .2rem; }
.timeline-action  { font-size: .8rem;  font-weight: 700; color: #333; }
.timeline-desc    { font-size: .8rem;  color: #555; }
.timeline-user    { font-size: .72rem; color: #6c757d; font-style: italic; }

/* ── LOADING SPINNER ─────────────────────────────────────────── */
.page-loader {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

/* ── Offices list cell — truncar en tabla ────────────────────── */
.offices-list-cell {
  display: block;
  font-size: .78rem;
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.show { transform: translateX(0); }
  #topbar { left: 0; }
  #main-content { margin-left: 0; padding: 1rem .75rem; }

  /* Stat cards en móvil */
  .stat-card { padding: .9rem 1rem; gap: .6rem; }
  .stat-icon { width: 40px; height: 40px; font-size: 1rem; }
  .stat-value { font-size: 1.35rem; }
  .stat-label { font-size: .7rem; }

  /* Card header con botón Nuevo */
  .card-header { gap: .5rem; }
  .btn-add { font-size: .8rem; padding: .4rem .9rem; }

  /* DataTable controles */
  .dataTables_wrapper .dataTables_filter,
  .dataTables_wrapper .dataTables_length { text-align: left; }
  .dataTables_wrapper .dataTables_filter input { width: 100%; }

  /* Topbar title más pequeño */
  .topbar-title { font-size: .9rem; }
}

/* ── Responsive ≤576px ───────────────────────────────────────── */
@media (max-width: 576px) {
  /* Stat cards — 1 por fila en pantallas muy pequeñas */
  .stat-value { font-size: 1.2rem; }

  /* DataTable — búsqueda y selector de registros apilados */
  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter { width: 100%; }
  .dataTables_wrapper .dataTables_length label { display: flex; align-items: center; gap: .4rem; }

  /* Botones de acción en tabla: mínimo tamaño */
  .btn-tbl { width: 26px; height: 26px; font-size: .68rem; }
  .tbl-actions { gap: .2rem; }

  /* Breadcrumb compacto */
  .breadcrumb { font-size: .75rem; }
}
