/* ============================================================
   CRM — Stylesheet principal
   Fuentes: DM Sans (UI) + Space Grotesk (headings/numbers)
   Paleta: Slate oscuro + Indigo + Lima accent
   ============================================================ */

:root {
  --bg-base:        rgba(10,13,25,.80);
  --bg-surface:     rgba(18,22,40,.88);
  --bg-raised:      rgba(26,30,50,.85);
  --bg-hover:       #252a3a;
  --border:         #2c3149;
  --border-light:   #384060;

  --text-primary:   #ffffff;
  --text-secondary: #e0e4f0;
  --text-muted:     #b8bdd4;

  --accent:         #6366f1;   /* indigo */
  --accent-light:   #818cf8;
  --accent-bg:      rgba(99,102,241,.12);

  --green:          #22c55e;
  --green-bg:       rgba(34,197,94,.12);
  --amber:          #f59e0b;
  --amber-bg:       rgba(245,158,11,.12);
  --red:            #ef4444;
  --red-bg:         rgba(239,68,68,.12);
  --blue:           #3b82f6;
  --blue-bg:        rgba(59,130,246,.12);
  --purple:         #a855f7;
  --purple-bg:      rgba(168,85,247,.12);
  --lime:           #a3e635;

  --radius:         10px;
  --radius-lg:      16px;
  --sidebar-w:      220px;
  --topbar-h:       64px;
  --shadow:         0 1px 3px rgba(0,0,0,.4);
  --shadow-md:      0 4px 16px rgba(0,0,0,.5);
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: linear-gradient(rgba(10,13,25,.55), rgba(10,13,25,.45)), url('https://www.salmef.cl/wp-content/uploads/2026/04/fondo-paisaje1-scaled.jpg') center center / cover fixed no-repeat;
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ---- Layout ------------------------------------------------ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.logo-icon {
  font-size: 22px;
  color: var(--accent-light);
  line-height: 1;
}
.logo-text {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -.3px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-bg);
  color: var(--accent-light);
}
.nav-icon { font-size: 16px; opacity: .8; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.sidebar-version { font-size: 11px; color: var(--text-muted); }

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

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 40;
}
.page-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -.3px;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }

.content-body { padding: 28px; flex: 1; }

/* ---- Cards ------------------------------------------------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.card-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ---- KPI Grid ---------------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.kpi-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color .2s;
}
.kpi-card:hover { border-color: var(--border-light); }
.kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 8px;
}
.kpi-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1;
}
.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}
.kpi-accent-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* ---- Tables ----------------------------------------------- */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child { border-bottom: none; }
tbody td {
  padding: 12px 14px;
  color: var(--text-primary);
  vertical-align: middle;
}

/* ---- Badges ----------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: .3px;
}
.badge-gray   { background: rgba(139,144,168,.15); color: var(--text-secondary); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue);   }
.badge-green  { background: var(--green-bg);  color: var(--green);  }
.badge-amber  { background: var(--amber-bg);  color: var(--amber);  }
.badge-red    { background: var(--red-bg);    color: var(--red);    }
.badge-purple { background: var(--purple-bg); color: var(--purple); }

/* ---- Buttons ---------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s, background .15s;
}
.btn:hover { opacity: .88; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary {
  background: var(--bg-raised);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }

/* ---- Forms ------------------------------------------------- */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  padding: 10px 13px;
  transition: border-color .15s;
  outline: none;
}
.form-control:focus { border-color: var(--accent); }
.form-control option { background: var(--bg-raised); }
textarea.form-control { resize: vertical; min-height: 90px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ---- Modals ----------------------------------------------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 100;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.modal-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 17px;
  font-weight: 600;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ---- Alerts ----------------------------------------------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 18px;
}
.alert-success { background: var(--green-bg); color: var(--green); }
.alert-error   { background: var(--red-bg);   color: var(--red);   }
.alert-warn    { background: var(--amber-bg);  color: var(--amber); }

/* ---- Filters ---------------------------------------------- */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.filter-bar .form-control { width: auto; }
.search-input { min-width: 240px; }

/* ---- Dashboard charts grid -------------------------------- */
.dash-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-top: 20px;
}

/* ---- Calendar --------------------------------------------- */
#calendar-container {
  background: var(--bg-raised);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border);
}
.fc { font-family: 'DM Sans', sans-serif !important; }
.fc-theme-standard td, .fc-theme-standard th { border-color: var(--border) !important; }
.fc-daygrid-day { background: transparent !important; }
.fc-daygrid-day:hover { background: var(--bg-hover) !important; }
.fc-toolbar-title { font-family: 'Space Grotesk', sans-serif !important; font-size: 18px !important; color: var(--text-primary) !important; }
.fc-button { background: var(--bg-raised) !important; border-color: var(--border) !important; color: var(--text-secondary) !important; font-family: 'DM Sans', sans-serif !important; }
.fc-button:hover { background: var(--bg-hover) !important; }
.fc-button-active { background: var(--accent-bg) !important; color: var(--accent-light) !important; }
.fc-col-header-cell-cushion { color: var(--text-muted) !important; font-size: 12px !important; font-weight: 600 !important; text-transform: uppercase !important; }
.fc-daygrid-day-number { color: var(--text-secondary) !important; }
.fc-day-today { background: var(--accent-bg) !important; }
.fc-event { border-radius: 5px !important; font-size: 12px !important; font-weight: 500 !important; border: none !important; padding: 2px 6px !important; }

/* ---- Detail view ------------------------------------------ */
.detail-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}
.detail-field { margin-bottom: 14px; }
.detail-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 3px; }
.detail-value { font-size: 14px; color: var(--text-primary); }

/* ---- Progress bar ----------------------------------------- */
.progress-bar { background: var(--bg-raised); border-radius: 999px; height: 6px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width .4s; }

/* ---- Empty states ----------------------------------------- */
.empty-state { text-align: center; padding: 48px 0; color: var(--text-muted); }
.empty-state-icon { font-size: 40px; margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: 14px; }

/* ---- Utilities -------------------------------------------- */
.text-muted   { color: var(--text-muted) !important; }
.text-success { color: var(--green) !important; }
.text-danger  { color: var(--red) !important; }
.text-warn    { color: var(--amber) !important; }
.text-accent  { color: var(--accent-light) !important; }
.text-right   { text-align: right; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.font-mono {
  font-family: 'Space Grotesk', monospace;
}