/* ============================================================
   orqXtor — Main Stylesheet
   ============================================================ */

:root {
  color-scheme: dark;
  --bg-base:     #111115;
  --bg-surface:  #18181d;
  --bg-elevated: #1e1e24;
  --bg-hover:    #25252c;
  --border:      rgba(255,255,255,.07);
  --accent:      #9163F2;
  --accent-soft: #9980F2;
  --accent-glow: rgba(145,99,242,.2);
  --text-primary: #E8E8EC;
  --text-muted:   #8A8FA8;
  --text-faint:   #4A4F60;
  --red:    #EF4444;
  --green:  #34BF8C;
  --sidebar-w: 240px;
  --topbar-h:  60px;
  --radius:    10px;
  --shadow:    0 4px 24px rgba(0,0,0,.4);
}

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

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: 'Inter', 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 3px; }

/* ── Date picker — ocultar indicador nativo (se reemplaza por botón custom via initDatePickers) ── */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  display: none !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-logo {
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.logo-mark {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--accent-soft);
  line-height: 1;
}
.logo-x {
  color: var(--accent);
  font-size: 28px;
  vertical-align: middle;
  line-height: 0;
}
.logo-agency {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-top: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 13.5px;
  transition: all .15s;
}
.nav-item svg {
  width: 18px; height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent-soft);
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-chip { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff;
  flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }

.btn-logout {
  color: var(--text-faint);
  display: flex; align-items: center;
  transition: color .15s;
  flex-shrink: 0;
}
.btn-logout:hover { color: var(--red); }
.btn-logout svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

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

.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-title { font-size: 16px; font-weight: 700; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.btn-sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}
.btn-sidebar-toggle svg { stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

.page-body { padding: 24px; flex: 1; min-width: 0; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #5b54e8; }
.btn-secondary { background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-danger { background: rgba(239,68,68,.15); color: var(--red); border: 1px solid rgba(239,68,68,.2); }
.btn-danger:hover { background: rgba(239,68,68,.25); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* ── Cards ── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 16px;
}

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 32px; font-weight: 800; color: var(--text-primary); line-height: 1; }
.stat-sub { font-size: 12px; color: var(--text-muted); }
.stat-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
}
.stat-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px; }
.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: var(--text-faint); }
select.form-control option { background: var(--bg-surface); }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-hover); }
.td-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}
/* ── Estado — solo estos usan color ── */
.badge-todo              { background: rgba(255,255,255,.05);  color: rgba(255,255,255,.3); }
.badge-in_progress       { background: rgba(145,99,242,.18);  color: #9163F2; }
.badge-review            { background: rgba(153,128,242,.15); color: #9980F2; }
.badge-pending_approval  { background: rgba(52,191,140,.16);  color: #34BF8C; }
.badge-done              { background: rgba(52,191,140,.1);   color: rgba(52,191,140,.6); }
.badge-standby           { background: rgba(248,113,113,.1);  color: rgba(248,113,113,.7); }

/* ── Estado de proyecto ── */
.badge-active     { background: rgba(145,99,242,.18);  color: #9163F2; }
.badge-paused     { background: rgba(255,255,255,.04); color: rgba(255,255,255,.22); }
.badge-completed  { background: rgba(52,191,140,.14);  color: #34BF8C; }
.badge-cancelled  { background: rgba(239,68,68,.12);   color: #f87171; }

/* ── Prioridad — dot + texto, sin badge de color ── */
.task-priority {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  color: rgba(255,255,255,.3);
}
.task-priority .priority-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgba(255,255,255,.2);
}
.task-priority.medium { color: #9980F2; }
.task-priority.medium .priority-dot { background: #9980F2; }
.task-priority.high   { color: #9163F2; }
.task-priority.high   .priority-dot { background: #9163F2; }
.task-priority.urgent { color: #f87171; }
.task-priority.urgent .priority-dot { background: #f87171; }

/* ── Avatar group ── */
.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; border: 2px solid var(--bg-surface); }

/* ── Kanban ── */
.kanban-board { display: flex; gap: 12px; padding-bottom: 16px; align-items: flex-start; }
.kanban-col {
  flex: 1 1 0;
  min-width: 200px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.kanban-col-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.kanban-count { background: var(--bg-hover); color: var(--text-muted); border-radius: 20px; padding: 2px 8px; font-size: 11px; font-weight: 600; }

.task-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  transition: all .15s;
}
.task-card:hover { border-color: var(--accent); background: rgba(145,99,242,.16); transform: translateY(-3px); box-shadow: 0 0 0 2px rgba(145,99,242,.5), 0 10px 30px rgba(145,99,242,.3); }
.task-card.is-revision { border-left: 3px solid rgba(153,128,242,.5); padding-left: 10px; }
.task-card.is-revision:hover { border-left-color: #9980F2; }
.task-card.has-link {
  border-color: rgba(153,128,242,.35);
  border-left: 3px solid rgba(153,128,242,.6);
  background: rgba(153,128,242,.05);
  padding-left: 10px;
}
.task-card.has-link:hover { border-color: var(--accent); border-left-color: #9980F2; background: rgba(145,99,242,.1); }
.task-card.chain-highlight { border-color: rgba(145,99,242,.7) !important; background: rgba(145,99,242,.14) !important; box-shadow: 0 0 0 2px rgba(145,99,242,.35) !important; transform: translateY(-2px); }

/* Tareas completadas — apagadas, ya no necesitan atención */
.task-card[data-status="done"] { opacity: 0.5; transition: opacity .15s; }
.task-card[data-status="done"]:hover { opacity: 0.85; }

/* Agrupación de cadenas — borde punteado alrededor del grupo */
.chain-group {
  border: 1px dashed rgba(153,128,242,.45);
  border-radius: var(--radius);
  padding: 6px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: rgba(153,128,242,.04);
  position: relative;
}
.chain-group::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: rgba(153,128,242,.45);
  border-radius: var(--radius) 0 0 var(--radius);
}
.chain-group .task-card { margin-bottom: 0; }
/* Tarjetas hijas dentro del grupo (revisiones y enlazadas) */
.chain-group .task-card:not(:first-child) {
  border-left: 2px solid rgba(153,128,242,.35);
  padding-left: 11px;
}

/* Columna Hecho: ocultar tareas > 3 hasta que se expanda */
.done-extra { display: none !important; }

.task-card-title { font-size: 13.5px; font-weight: 600; margin-bottom: 8px; }
.task-link-chip { display:flex;align-items:center;gap:5px;text-decoration:none;color:var(--accent-soft);font-size:11.5px;font-weight:500;padding:2px 5px;border-radius:5px;overflow:hidden;transition:background .12s,color .12s; }
.task-link-chip:hover { background:rgba(153,128,242,.2);color:#c4b5fd; }
.task-card:hover .task-link-chip { background:rgba(153,128,242,.12);color:#c4b5fd; }
.task-card:hover .task-link-chip:hover { background:rgba(153,128,242,.25);color:#e9d5ff; }
.task-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.task-card-project { font-size: 11.5px; color: var(--text-muted); }
.task-card-due { font-size: 11.5px; color: var(--text-muted); }
.task-card-due.overdue { color: var(--red); }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.modal-close {
  position: absolute;
  top: 20px; right: 20px;
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: color .15s;
}
.modal-close:hover { color: var(--text-primary); }
.modal-close svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

/* ── Gantt / Calendar ── */
.gantt-wrap { overflow-x: auto; }
.gantt-header { display: flex; align-items: center; gap: 0; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg-surface); z-index: 10; }
.gantt-label-col { min-width: 200px; width: 200px; padding: 10px 14px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); border-right: 1px solid var(--border); flex-shrink: 0; }
.gantt-days { display: flex; flex: 1; }
.gantt-day {
  min-width: 36px;
  text-align: center;
  padding: 10px 0;
  font-size: 10px;
  color: var(--text-faint);
  border-right: 1px solid var(--border);
}
.gantt-day.today { color: var(--accent-soft); background: var(--accent-glow); }
.gantt-row { display: flex; align-items: center; border-bottom: 1px solid var(--border); min-height: 44px; }
.gantt-row:hover { background: var(--bg-hover); }
.gantt-row-label { min-width: 200px; width: 200px; padding: 8px 14px; font-size: 13px; font-weight: 500; border-right: 1px solid var(--border); flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantt-row-label small { display: block; font-size: 11px; color: var(--text-muted); }
.gantt-row-track { flex: 1; position: relative; height: 44px; display: flex; align-items: center; }
.gantt-bar {
  position: absolute;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: opacity .15s;
}
.gantt-bar:hover { opacity: .85; }

/* ── Toast ── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 13.5px;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  animation: slideIn .25s ease;
  min-width: 260px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--accent); }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 60px 24px; color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; stroke: var(--text-faint); fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 16px; }
.empty-state p { font-size: 15px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.empty-state span { font-size: 13px; color: var(--text-faint); }

/* ── Progress bar ── */
.progress { height: 6px; background: var(--bg-hover); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-soft)); border-radius: 3px; transition: width .4s ease; }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; background: var(--bg-elevated); border-radius: var(--radius); padding: 4px; width: fit-content; margin-bottom: 20px; }
.tab { padding: 7px 16px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--text-muted); cursor: pointer; border: none; background: none; transition: all .15s; }
.tab.active { background: var(--bg-surface); color: var(--text-primary); box-shadow: 0 1px 4px rgba(0,0,0,.3); }

/* ── Color dot ── */
.color-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ── Responsive ── */
@media (max-width: 1024px) {
  /* Project detail: stack sidebar below main */
  .project-detail-grid { grid-template-columns: 1fr !important; }
  /* Task page: stack sidebar below main */
  .task-page-grid { grid-template-columns: 1fr !important; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .btn-sidebar-toggle { display: flex; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  /* Kanban scrolls horizontally on mobile, nothing else does */
  .kanban-board { overflow-x: auto; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-body { padding: 16px; }
}

/* ── Drag & Drop Kanban ──────────────────────────────────── */
.task-card[draggable="true"] { cursor: default; position: relative; }
.task-card.dragging {
  opacity: 0.4;
  transform: scale(0.97);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  cursor: grabbing;
}
.kanban-col.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -3px;
  background: rgba(108,99,255,.05);
  transition: background .15s;
}

/* Drag handle — aparece al hacer hover en la card */
.drag-handle {
  position: absolute;
  top: 8px;
  right: 8px;
  color: var(--text-faint, #444);
  opacity: 0;
  cursor: grab;
  padding: 2px;
  border-radius: 4px;
  transition: opacity .15s, background .15s;
  line-height: 0;
  pointer-events: none;   /* el drag lo maneja la card entera */
}
.task-card:hover .drag-handle {
  opacity: 1;
}
.task-card[draggable="true"]:hover {
  cursor: grab;
}
.task-card[draggable="true"]:active {
  cursor: grabbing;
}

/* Tom Select: siempre encima de modales y overlays */
.ts-dropdown { z-index: 10000 !important; }

