/* ============================================================
   shared.css — Design System CRM Construcción
   Importar en todas las páginas del proyecto.
   ============================================================ */

/* ── Fuentes ─────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

/* ── Tokens de color (modo claro) ───────────────────────── */
:root {
  /* Fondo */
  --bg-primary:   #FFFFFF;
  --bg-secondary: #F7F7F6;
  --bg-tertiary:  #EFEFED;
  --bg-info:      #EEF4FD;

  /* Texto */
  --text-primary:   #1A1A18;
  --text-secondary: #5C5C58;
  --text-tertiary:  #9B9B95;
  --text-danger:    #791F1F;

  /* Bordes */
  --border-primary:   #C8C8C0;
  --border-secondary: #DCDCD4;
  --border-tertiary:  #EAEAE2;
  --border-danger:    #E8B4B4;

  /* Marca */
  --brand:        #534AB7;
  --brand-dark:   #3C3489;
  --brand-light:  #EEEDFE;
  --brand-text:   #3C3489;

  /* Semánticos */
  --green:        #1D9E75;
  --green-light:  #E1F5EE;
  --green-text:   #085041;
  --amber:        #EF9F27;
  --amber-light:  #FAEEDA;
  --amber-text:   #633806;
  --red:          #C0392B;
  --red-light:    #FCEBEB;
  --red-text:     #791F1F;
  --blue-light:   #E6F1FB;
  --blue-text:    #0C447C;
  --gray-light:   #F1EFE8;
  --gray-text:    #444441;

  /* Radio */
  --r-sm:   4px;
  --r-md:   6px;
  --r-lg:   10px;
  --r-full: 999px;

  /* Sombra */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);

  /* Tipografía */
  --font: 'Inter', system-ui, sans-serif;
}

/* ── Reset base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-secondary);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: var(--font); cursor: pointer; }
input, select, textarea { font-family: var(--font); }

/* ── Layout principal ────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-right: 0.5px solid var(--border-tertiary);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 0.5px solid var(--border-tertiary);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-logo span {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 400;
  display: block;
  margin-top: 1px;
}

.sidebar-section {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 12px 16px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  border-left: 2px solid transparent;
  white-space: nowrap;
  transition: background .1s, color .1s;
}
.nav-item svg { width: 14px; height: 14px; flex-shrink: 0; }
.nav-item:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-left-color: var(--brand);
  font-weight: 500;
}

.sidebar-footer {
  margin-top: auto;
  border-top: 0.5px solid var(--border-tertiary);
  padding: 10px 16px;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}
.sidebar-user strong { display: block; color: var(--text-primary); font-size: 12px; font-weight: 500; }
.sidebar-user span { font-size: 10px; }

/* ── Área principal ─────────────────────────────────────── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  padding: 11px 18px;
  border-bottom: 0.5px solid var(--border-tertiary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
  background: var(--bg-primary);
}
.topbar-left { display: flex; flex-direction: column; gap: 1px; }
.topbar-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.topbar-sub   { font-size: 11px; color: var(--text-tertiary); }
.topbar-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ── Contenido scrollable ───────────────────────────────── */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
}

/* ── Botones ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  font-size: 12px;
  border: 0.5px solid var(--border-secondary);
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  transition: background .1s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-secondary); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

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

.btn-danger {
  background: var(--red-light);
  color: var(--red-text);
  border-color: var(--border-danger);
}
.btn-danger:hover { background: #f9dada; }

.btn-sm { padding: 4px 9px; font-size: 11px; }
.btn-lg { padding: 8px 18px; font-size: 13px; }

.btn-icon {
  padding: 5px;
  border-radius: var(--r-md);
  border: 0.5px solid var(--border-secondary);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: var(--bg-secondary); }
.btn-icon svg { width: 14px; height: 14px; }

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-purple { background: var(--brand-light);  color: var(--brand-text); }
.badge-green  { background: var(--green-light);  color: var(--green-text); }
.badge-amber  { background: var(--amber-light);  color: var(--amber-text); }
.badge-red    { background: var(--red-light);    color: var(--red-text);   }
.badge-blue   { background: var(--blue-light);   color: var(--blue-text);  }
.badge-gray   { background: var(--gray-light);   color: var(--gray-text);  }

/* ── Tablas ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

.tbl {
  width: 100%;
  font-size: 12px;
  border-collapse: collapse;
}
.tbl th {
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 6px 10px;
  border-bottom: 0.5px solid var(--border-tertiary);
  white-space: nowrap;
}
.tbl td {
  padding: 8px 10px;
  border-bottom: 0.5px solid var(--border-tertiary);
  color: var(--text-primary);
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: var(--bg-secondary); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .actions { text-align: right; white-space: nowrap; }
.tbl .muted { color: var(--text-tertiary); }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--bg-primary);
  border: 0.5px solid var(--border-tertiary);
  border-radius: var(--r-lg);
  padding: 14px 16px;
}
.card + .card { margin-top: 10px; }
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

/* ── Métricas ───────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.metric {
  background: var(--bg-secondary);
  border-radius: var(--r-md);
  padding: 10px 12px;
}
.metric-label { font-size: 11px; color: var(--text-secondary); margin-bottom: 3px; }
.metric-value { font-size: 20px; font-weight: 600; color: var(--text-primary); }
.metric-value.brand  { color: var(--brand); }
.metric-value.green  { color: var(--green); }
.metric-value.red    { color: var(--red);   }
.metric-value.amber  { color: var(--amber); }

/* ── Grids ──────────────────────────────────────────────── */
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.g3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.g4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
@media (max-width: 700px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
}

/* ── Formularios ────────────────────────────────────────── */
.form-row { margin-bottom: 10px; }
.form-label {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 3px;
  font-weight: 500;
}
.form-input,
input[type=text],
input[type=email],
input[type=password],
input[type=date],
input[type=number],
select,
textarea {
  width: 100%;
  padding: 6px 9px;
  font-size: 12px;
  border: 0.5px solid var(--border-secondary);
  border-radius: var(--r-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: border-color .15s;
  outline: none;
}
.form-input:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(83,74,183,.1);
}
textarea { resize: vertical; min-height: 52px; }
.form-hint { font-size: 11px; color: var(--text-tertiary); margin-top: 3px; }
.form-error { font-size: 11px; color: var(--red); margin-top: 3px; }

/* ── Avatar ─────────────────────────────────────────────── */
.av {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  flex-shrink: 0;
}
.av-lg { width: 40px; height: 40px; font-size: 14px; }
.av-xl { width: 52px; height: 52px; font-size: 17px; }

.av-purple { background: var(--brand-light); color: var(--brand-text); }
.av-green  { background: var(--green-light); color: var(--green-text); }
.av-amber  { background: var(--amber-light); color: var(--amber-text); }
.av-blue   { background: var(--blue-light);  color: var(--blue-text);  }
.av-gray   { background: var(--gray-light);  color: var(--gray-text);  }
.av-red    { background: var(--red-light);   color: var(--red-text);   }

/* ── Tabs ───────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 0.5px solid var(--border-tertiary);
  margin-bottom: 14px;
  gap: 0;
  overflow-x: auto;
}
.tab {
  padding: 7px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color .1s;
}
.tab:hover { color: var(--text-primary); }
.tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--brand);
  font-weight: 500;
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Toggle (switch) ────────────────────────────────────── */
.toggle {
  width: 34px;
  height: 19px;
  border-radius: var(--r-full);
  border: 0.5px solid var(--border-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  padding: 2px;
  background: var(--bg-tertiary);
  transition: background .15s, border-color .15s;
  flex-shrink: 0;
}
.toggle.on { background: var(--brand); border-color: var(--brand); }
.toggle-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
  transition: transform .15s;
}
.toggle.on .toggle-dot { transform: translateX(15px); }

/* ── Checkbox ───────────────────────────────────────────── */
.chk {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 0.5px solid var(--border-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 9px;
  flex-shrink: 0;
  transition: background .1s, border-color .1s;
}
.chk.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ── Barra de progreso ──────────────────────────────────── */
.prog-bar {
  height: 5px;
  background: var(--bg-tertiary);
  border-radius: var(--r-full);
  overflow: hidden;
}
.prog-fill {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--brand);
  transition: width .3s;
}
.prog-fill.green  { background: var(--green);  }
.prog-fill.amber  { background: var(--amber);  }
.prog-fill.red    { background: var(--red);    }

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal {
  background: var(--bg-primary);
  border-radius: var(--r-lg);
  border: 0.5px solid var(--border-tertiary);
  width: 100%;
  max-width: 480px;
  padding: 20px;
  box-shadow: var(--shadow-md);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text-primary);
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 0.5px solid var(--border-tertiary);
}
.modal-wide { max-width: 700px; }

/* ── Turnos – Calendario ────────────────────────────────── */
.cal {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.cal th {
  padding: 5px 3px;
  text-align: center;
  font-weight: 500;
  font-size: 10px;
  color: var(--text-secondary);
  border-bottom: 0.5px solid var(--border-tertiary);
}
.cal td {
  padding: 3px;
  border: 0.5px solid var(--border-tertiary);
  vertical-align: top;
  min-width: 0;
}
.cal td.today  { background: var(--bg-info); }
.cal td.weekend { background: var(--bg-secondary); opacity: .8; }
.cal td.festivo { background: #FFF3CD; }

.shift {
  border-radius: 3px;
  padding: 2px 4px;
  font-size: 10px;
  margin-bottom: 2px;
  line-height: 1.3;
  cursor: pointer;
}
.sh-m  { background: var(--brand-light);  color: var(--brand-text);  } /* Mañana  */
.sh-t  { background: var(--green-light);  color: var(--green-text);  } /* Tarde   */
.sh-n  { background: var(--blue-light);   color: var(--blue-text);   } /* Noche   */
.sh-v  { background: var(--red-light);    color: var(--red-text);    } /* Vacación */
.sh-f  { background: #FFF3CD;             color: #856404;             } /* Festivo  */
.sh-p  { background: var(--amber-light);  color: var(--amber-text);  } /* Permiso  */

/* ── Vacaciones – barra ─────────────────────────────────── */
.vac-bar-wrap {
  flex: 1;
  background: var(--bg-secondary);
  border-radius: var(--r-sm);
  height: 16px;
  position: relative;
  overflow: hidden;
}
.vac-seg {
  position: absolute;
  height: 100%;
  border-radius: 2px;
  display: flex;
  align-items: center;
  padding: 0 3px;
  font-size: 9px;
  white-space: nowrap;
  overflow: hidden;
}

/* ── Carpetas de documentos ─────────────────────────────── */
.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.folder-item {
  border: 0.5px solid var(--border-tertiary);
  border-radius: var(--r-md);
  padding: 12px 10px;
  cursor: pointer;
  text-align: center;
  transition: background .1s;
}
.folder-item:hover { background: var(--bg-secondary); }
.folder-icon {
  width: 34px;
  height: 28px;
  margin: 0 auto 7px;
  position: relative;
}
.folder-icon-body {
  width: 34px;
  height: 24px;
  background: var(--amber-light);
  border-radius: 3px;
  border: 0.5px solid var(--amber);
  position: absolute;
  bottom: 0;
}
.folder-icon-tab {
  width: 14px;
  height: 7px;
  background: var(--amber-light);
  border: 0.5px solid var(--amber);
  border-bottom: none;
  border-radius: 2px 2px 0 0;
  position: absolute;
  top: 0;
  left: 2px;
}
.folder-name  { font-size: 12px; color: var(--text-primary); font-weight: 500; }
.folder-count { font-size: 10px; color: var(--text-tertiary); margin-top: 2px; }

/* ── Nómina ─────────────────────────────────────────────── */
.nom-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 0.5px solid var(--border-tertiary);
  font-size: 12px;
}
.nom-row.total {
  font-weight: 600;
  font-size: 13px;
  border-top: 1px solid var(--border-primary);
  border-bottom: none;
  padding-top: 8px;
}
.nom-row.neg    { color: var(--red); }
.nom-row.result { font-size: 14px; font-weight: 600; color: var(--brand); padding-top: 6px; }

/* ── Proyectos – item ───────────────────────────────────── */
.proj-item {
  border: 0.5px solid var(--border-tertiary);
  border-radius: var(--r-md);
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background .1s, border-color .1s;
}
.proj-item:hover    { background: var(--bg-secondary); }
.proj-item.selected { border-color: var(--brand); }

/* ── Permisos – matriz ──────────────────────────────────── */
.perm-matrix {
  display: grid;
  font-size: 12px;
}
.perm-matrix .ph {
  padding: 7px 4px 4px;
  font-weight: 500;
  font-size: 10px;
  color: var(--text-secondary);
  text-align: center;
}
.perm-matrix .pl {
  padding: 8px 0;
  border-top: 0.5px solid var(--border-tertiary);
  color: var(--text-primary);
  font-size: 12px;
}
.perm-matrix .pc {
  padding: 8px 0;
  border-top: 0.5px solid var(--border-tertiary);
  text-align: center;
}

/* ── View switcher (día/semana/mes) ─────────────────────── */
.view-btns {
  display: flex;
  border: 0.5px solid var(--border-secondary);
  border-radius: var(--r-md);
  overflow: hidden;
}
.vb {
  padding: 5px 12px;
  font-size: 11px;
  cursor: pointer;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  transition: background .1s, color .1s;
}
.vb:hover { background: var(--bg-secondary); }
.vb.active { background: var(--brand); color: #fff; }

/* ── Utilidades ─────────────────────────────────────────── */
.flex        { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between{ display: flex; align-items: center; justify-content: space-between; }
.gap-4  { gap: 4px; }
.gap-6  { gap: 6px; }
.gap-8  { gap: 8px; }
.gap-10 { gap: 10px; }
.gap-12 { gap: 12px; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.text-sm      { font-size: 11px; }
.text-muted   { color: var(--text-tertiary); }
.text-secondary { color: var(--text-secondary); }
.text-right   { text-align: right; }
.font-medium  { font-weight: 500; }
.font-semibold{ font-weight: 600; }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden       { display: none !important; }
.divider      { border: none; border-top: 0.5px solid var(--border-tertiary); margin: 12px 0; }

/* ── Empty state ────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  color: var(--text-tertiary);
  text-align: center;
  gap: 8px;
}
.empty-state svg { width: 36px; height: 36px; opacity: .35; }
.empty-state p   { font-size: 12px; }

/* ── Toast / notificación ───────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.toast {
  background: var(--text-primary);
  color: #fff;
  padding: 8px 14px;
  border-radius: var(--r-md);
  font-size: 12px;
  box-shadow: var(--shadow-md);
  animation: toast-in .2s ease;
}
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Spinner ────────────────────────────────────────────── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-secondary);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Loading overlay ────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

/* ── Responsive sidebar (móvil) ─────────────────────────── */
@media (max-width: 640px) {
  .sidebar { position: fixed; left: -200px; top: 0; height: 100%; z-index: 100; transition: left .2s; }
  .sidebar.open { left: 0; }
  .main-area { overflow: auto; }
}
