/* ============================================================
   GestLog — Sistema de Gestión de Contratos
   Stylesheet principal
   ============================================================ */

:root {
  --sidebar-width: 260px;
  --sidebar-collapsed: 70px;
  --topbar-height: 64px;

  --brand-primary: #1e40af;
  --brand-secondary: #3b82f6;
  --brand-accent: #0ea5e9;

  --color-bg: #f1f5f9;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #1e293b;
  --color-muted: #64748b;

  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-info: #3b82f6;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .08);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, .12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  --font-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --transition: 0.2s ease;
}

/* ── Reset & Base ── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--brand-secondary);
}

a:hover {
  color: var(--brand-primary);
}

.fw-500 {
  font-weight: 500;
}

.fw-600 {
  font-weight: 600;
}

.fw-700 {
  font-weight: 700;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: #0f172a;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: width var(--transition);
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--brand-secondary), var(--brand-accent));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.3px;
}

.brand-sub {
  font-size: 10px;
  color: rgba(255, 255, 255, .4);
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* Sidebar user */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role.badge {
  background: rgba(99, 102, 241, .25) !important;
  color: #a5b4fc !important;
  font-size: 10px;
  padding: 2px 6px;
  width: fit-content;
}

/* Sidebar nav */
.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
  overflow-y: auto;
}

.nav-section-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, .3);
  letter-spacing: 1px;
  padding: 4px 8px 8px;
  text-transform: uppercase;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, .6);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
  margin-bottom: 2px;
}

.sidebar-nav .nav-link i {
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-nav .nav-link:hover {
  background: rgba(255, 255, 255, .08);
  color: #fff;
}

.sidebar-nav .nav-link.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, .3), rgba(14, 165, 233, .2));
  color: #93c5fd;
  border-left: 3px solid var(--brand-secondary);
  padding-left: 9px;
}

.sidebar-nav .nav-link-danger:hover {
  background: rgba(239, 68, 68, .15);
  color: #fca5a5;
}

.sidebar-footer {
  padding: 12px 20px;
  font-size: 11px;
  color: rgba(255, 255, 255, .2);
  border-top: 1px solid rgba(255, 255, 255, .06);
}

/* ── Main Wrapper ── */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}

/* ── Topbar ── */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar-title {
  flex: 1;
}

.page-heading {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

.sidebar-toggle {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-muted);
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  font-size: 18px;
  display: none;
}

/* ── Main Content ── */
.main-content {
  padding: 24px;
  max-width: 1400px;
  flex: 1 0 auto;
}

.footer {
  margin-top: auto;
}

/* ── Stat Cards ── */
.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.stat-card-blue::before {
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
}

.stat-card-green::before {
  background: linear-gradient(90deg, #22c55e, #4ade80);
}

.stat-card-purple::before {
  background: linear-gradient(90deg, #8b5cf6, #a78bfa);
}

.stat-card-orange::before {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-card-alert {
  border-color: #fde68a;
  background: #fffbeb;
}

.stat-icon {
  font-size: 22px;
  opacity: .7;
}

.stat-card-blue .stat-icon {
  color: #3b82f6;
}

.stat-card-green .stat-icon {
  color: #22c55e;
}

.stat-card-purple .stat-icon {
  color: #8b5cf6;
}

.stat-card-orange .stat-icon {
  color: #f59e0b;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  color: var(--color-text);
}

.stat-label {
  font-size: 13px;
  color: var(--color-muted);
  font-weight: 500;
}

.stat-link {
  font-size: 12px;
  color: var(--color-muted);
  text-decoration: none;
  font-weight: 500;
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.stat-link:hover {
  color: var(--brand-secondary);
}

/* ── Metric Mini ── */
.metric-mini {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.metric-mini-val {
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}

.metric-mini-label {
  font-size: 12px;
  color: var(--color-muted);
  margin-top: 4px;
}

.metric-green .metric-mini-val {
  color: #22c55e;
}

.metric-slate .metric-mini-val {
  color: #64748b;
}

.metric-yellow .metric-mini-val {
  color: #f59e0b;
}

.metric-teal .metric-mini-val {
  color: #14b8a6;
}

/* ── Card Panel ── */
.card-panel {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  background: #f8fafc;
}

.card-panel-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}

.card-panel-body {
  padding: 20px;
}

/* ── Tables ── */
.table {
  font-size: 13.5px;
}

.table thead th {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--color-muted);
  border-bottom: 1px solid var(--color-border);
  background: #f8fafc;
  padding: 10px 16px;
}

.table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.table-hover tbody tr:hover {
  background: #f8fafc;
}

.row-warning {
  background: #fffbeb !important;
}

/* ── Page Toolbar ── */
.page-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-search {
  flex: 1;
  min-width: 280px;
}

/* ── Avatars ── */
.avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: var(--font-mono);
}

.avatar-md {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
}

.avatar-xl {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
}

/* ── Empty States ── */
.empty-state {
  padding: 60px 24px;
  text-align: center;
}

.empty-state i {
  font-size: 48px;
  color: #cbd5e1;
  display: block;
  margin-bottom: 16px;
}

.empty-state h4 {
  color: var(--color-text);
  font-weight: 600;
}

.empty-state p {
  color: var(--color-muted);
  margin-bottom: 20px;
}

.empty-state-sm {
  padding: 32px 24px;
  text-align: center;
}

.empty-state-sm i {
  font-size: 32px;
  color: #cbd5e1;
  display: block;
  margin-bottom: 8px;
}

.empty-state-sm p {
  color: var(--color-muted);
  margin: 0;
  font-size: 13px;
}

/* ── Info Block ── */
.info-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-block-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--color-muted);
}

.info-block-value {
  font-size: 15px;
  font-weight: 500;
  color: var(--color-text);
}

/* ── Detail List ── */
.detail-list dt {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--color-muted);
  margin-top: 12px;
  margin-bottom: 2px;
}

.detail-list dd {
  font-size: 14px;
  color: var(--color-text);
  margin: 0;
}

.detail-list dt:first-child {
  margin-top: 0;
}

/* ── Form ── */
.form-label {
  font-weight: 600;
  font-size: 13px;
  color: var(--color-text);
  margin-bottom: 6px;
}

.form-label.required::after {
  content: ' *';
  color: var(--color-danger);
}

.form-control,
.form-select {
  border-color: var(--color-border);
  border-radius: var(--radius-xs);
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--brand-secondary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .12);
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

/* ── Buttons ── */
.btn {
  font-weight: 600;
  font-size: 13px;
  border-radius: var(--radius-xs);
  transition: all var(--transition);
}

.btn-primary {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
}

.btn-primary:hover {
  background: #1d3a8e;
  border-color: #1d3a8e;
}

.btn-xs {
  font-size: 12px;
  padding: 3px 8px;
}

/* ── Badges ── */
.badge {
  font-weight: 600;
  font-size: 11px;
  border-radius: 6px;
}

.bg-primary-soft {
  background: rgba(59, 130, 246, .1) !important;
}

.bg-success-soft {
  background: rgba(34, 197, 94, .1) !important;
}

.bg-purple-soft {
  background: rgba(139, 92, 246, .1) !important;
}

.text-purple {
  color: #7c3aed !important;
}

/* ── Alert Flash ── */
.alert-flash {
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.alert-sm {
  font-size: 13px;
  padding: 10px 14px;
}

.smaller {
  font-size: 11.5px;
}

/* ── UI Components ── */
.contract-icon {
  width: 36px;
  height: 36px;
  background: #f1f5f9;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.bg-info-soft {
  background: rgba(14, 165, 233, .1) !important;
}

.bg-danger-soft {
  background: rgba(239, 68, 68, .1) !important;
}

.bg-warning-soft {
  background: rgba(245, 158, 11, .1) !important;
}

/* ── Flash message auto-dismiss ── */
.alert-dismissible {
  position: relative;
}

/* ── Login Page ── */
body.login-body {
  background: #0f172a;
  display: block;
}

.login-wrapper {
  display: flex;
  min-height: 100vh;
}

.login-left {
  flex: 1;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #1e40af 100%);
  padding: 60px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-left::before {
  content: '';
  position: absolute;
  top: -100px;
  right: -100px;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59, 130, 246, .15) 0%, transparent 70%);
}

.login-logo {
  width: 64px;
  height: 64px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #3b82f6, #0ea5e9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  margin-bottom: 24px;
  box-shadow: 0 8px 24px rgba(59, 130, 246, .4);
}

.login-app-name {
  font-size: 42px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 8px;
  letter-spacing: -1px;
}

.login-app-desc {
  font-size: 16px;
  color: rgba(255, 255, 255, .5);
  line-height: 1.6;
  margin-bottom: 48px;
}

.login-features {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-feature-item {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255, 255, 255, .7);
  font-size: 14px;
  font-weight: 500;
}

.login-feature-item i {
  font-size: 18px;
  color: #60a5fa;
  flex-shrink: 0;
}

.login-right {
  width: 480px;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 36px;
}

.login-card-header {
  text-align: center;
  margin-bottom: 28px;
}

.login-card-header h2 {
  font-size: 24px;
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: 4px;
}

.login-card-header p {
  color: var(--color-muted);
  font-size: 14px;
  margin: 0;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-wrapper {
    margin-left: 0;
  }

  .sidebar-toggle {
    display: flex;
  }
}

@media (max-width: 768px) {
  .main-content {
    padding: 16px;
  }

  .topbar {
    padding: 0 16px;
  }

  .login-left {
    display: none;
  }

  .login-right {
    width: 100%;
  }

  .stat-value {
    font-size: 26px;
  }

  .page-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-search {
    min-width: auto;
  }
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ── Utilities ── */
.text-truncate {
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* ── Media Print Styles: 1 Page Compact Official Layout ── */
@media print {
  @page {
    size: A4 portrait;
    margin: 10mm 12mm 10mm 12mm;
  }

  *, *::before, *::after {
    box-shadow: none !important;
    text-shadow: none !important;
  }

  html, body {
    background: #fff !important;
    color: #000 !important;
    font-size: 10pt !important;
    line-height: 1.3 !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .sidebar,
  .topbar,
  .footer,
  .no-print,
  .btn,
  .btn-group,
  .alert-flash,
  .modal,
  .pagination,
  #sidebarToggle,
  .dataTables_filter,
  .dataTables_length,
  .dataTables_paginate,
  .dataTables_info {
    display: none !important;
  }

  .main-wrapper {
    margin-left: 0 !important;
    padding: 0 !important;
    min-height: auto !important;
    width: 100% !important;
  }

  .main-content {
    padding: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  .print-header {
    display: block !important;
    border-bottom: 2px solid #222;
    padding-bottom: 8px;
    margin-bottom: 12px;
  }

  .print-signatures {
    display: flex !important;
    justify-content: space-between;
    margin-top: 30px;
    padding-top: 10px;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .card, .card-panel {
    border: 1px solid #bbb !important;
    margin-bottom: 10px !important;
    page-break-inside: avoid;
    break-inside: avoid;
    background: #fff !important;
  }

  .card-header, .card-panel-header {
    background: #f1f3f5 !important;
    color: #000 !important;
    padding: 6px 10px !important;
    font-size: 10.5pt !important;
    border-bottom: 1px solid #bbb !important;
  }

  .card-body, .card-panel-body {
    padding: 10px !important;
  }

  h1, h2, h3, h4, h5, h6, .h2, .h3, .display-6 {
    font-size: 12pt !important;
    margin-top: 0 !important;
    margin-bottom: 4px !important;
    font-weight: 700 !important;
    color: #000 !important;
  }

  .display-6 {
    font-size: 14pt !important;
  }

  .badge {
    border: 1px solid #444 !important;
    color: #000 !important;
    background: transparent !important;
    padding: 1px 6px !important;
    font-size: 8.5pt !important;
  }

  .info-block {
    margin-bottom: 4px !important;
  }

  .info-block-label {
    font-size: 8pt !important;
    color: #555 !important;
  }

  .info-block-value {
    font-size: 9.5pt !important;
    color: #000 !important;
  }

  .table {
    font-size: 9pt !important;
    width: 100% !important;
    border-collapse: collapse !important;
  }

  .table th, .table td {
    padding: 4px 6px !important;
    border: 1px solid #ccc !important;
  }

  .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .col-lg-8 {
    width: 65% !important;
    float: left !important;
  }

  .col-lg-4 {
    width: 35% !important;
    float: left !important;
    padding-left: 10px !important;
  }

  .col-md-6 {
    width: 50% !important;
    float: left !important;
  }

  .col-md-4 {
    width: 33.333% !important;
    float: left !important;
  }

  a {
    text-decoration: none !important;
    color: #000 !important;
  }

  tr, img, .card, .card-panel, .info-block {
    page-break-inside: avoid;
    break-inside: avoid;
  }
}
