/* ============================================================
   HELPDESK PRO - DESIGN SYSTEM
   Fuente: IBM Plex Sans (elegante, técnica, legible)
   Tema: Azul oscuro profesional
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ---- VARIABLES ---- */
:root {
  --font: 'IBM Plex Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', monospace;

  /* Colores primarios */
  --blue-50:  #eff6ff;
  --blue-100: #dbeafe;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-900: #1e3a8a;

  /* Grises */
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Semánticos */
  --red-100: #fee2e2; --red-500: #ef4444; --red-600: #dc2626; --red-700: #b91c1c;
  --amber-100: #fef3c7; --amber-500: #f59e0b; --amber-600: #d97706;
  --green-100: #dcfce7; --green-500: #22c55e; --green-600: #16a34a; --green-700: #15803d;
  --purple-100: #f3e8ff; --purple-500: #a855f7; --purple-600: #9333ea;

  /* UI vars */
  --bg:          #f8fafc;
  --bg-card:     #ffffff;
  --bg-sidebar:  #0f172a;
  --text:        #1e293b;
  --text-muted:  #64748b;
  --text-light:  #94a3b8;
  --border:      #e2e8f0;
  --border-dark: #cbd5e1;
  --shadow-sm:   0 1px 2px rgba(0,0,0,.06);
  --shadow:      0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg:   0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.06);
  --radius:      8px;
  --radius-lg:   12px;
  --sidebar-w:   260px;
  --header-h:    60px;
  --transition:  150ms cubic-bezier(.4,0,.2,1);
}

/* ---- RESET ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue-600); text-decoration: none; }
a:hover { color: var(--blue-700); }
img { max-width: 100%; }
button { cursor: pointer; font-family: var(--font); }
input, select, textarea { font-family: var(--font); }

/* ---- LAYOUT ---- */
.app-wrapper { display: flex; min-height: 100vh; }

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-logo .logo-icon {
  width: 34px; height: 34px;
  background: var(--blue-600);
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 16px; color: #fff;
}
.sidebar-logo .logo-text {
  font-size: .95rem; font-weight: 600;
  color: #fff; letter-spacing: -.01em;
}
.sidebar-logo .logo-sub {
  font-size: .7rem; color: var(--gray-500);
  font-weight: 400;
}
.sidebar-company {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.company-pill {
  display: flex; align-items: center; gap: 8px;
  background: rgba(59,130,246,.15);
  border: 1px solid rgba(59,130,246,.25);
  border-radius: 6px;
  padding: 6px 10px;
}
.company-pill span { font-size: .8rem; color: var(--blue-100); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.nav-section { padding: 8px 16px 4px; }
.nav-section-label {
  font-size: .68rem; font-weight: 600;
  color: var(--gray-600); text-transform: uppercase;
  letter-spacing: .06em;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px;
  color: var(--gray-400);
  border-radius: 0;
  transition: all var(--transition);
  font-size: .875rem;
  position: relative;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item.active {
  color: #fff;
  background: rgba(59,130,246,.2);
  border-right: 2px solid var(--blue-500);
}
.nav-item .nav-icon { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--red-500);
  color: #fff; font-size: .65rem; font-weight: 600;
  padding: 1px 6px; border-radius: 999px; min-width: 18px; text-align: center;
}
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.user-card {
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 34px; height: 34px;
  background: var(--blue-700);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: .8rem; font-weight: 600; color: #fff;
  flex-shrink: 0;
}
.user-info .user-name { font-size: .83rem; color: #fff; font-weight: 500; }
.user-info .user-role { font-size: .72rem; color: var(--gray-500); }
.user-card a { margin-left: auto; color: var(--gray-500); font-size: .85rem; transition: color var(--transition); }
.user-card a:hover { color: #fff; }

/* ---- MAIN ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ---- TOPBAR ---- */
.topbar {
  height: var(--header-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 1rem; font-weight: 600; color: var(--text); flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  display: grid; place-items: center;
  color: var(--text-muted);
  position: relative;
  transition: all var(--transition);
}
.icon-btn:hover { background: var(--gray-100); color: var(--text); }
.icon-btn .badge-dot {
  position: absolute; top: 5px; right: 5px;
  width: 8px; height: 8px;
  background: var(--red-500); border-radius: 50%;
  border: 1px solid #fff;
}

/* ---- PAGE ---- */
.page { padding: 24px; flex: 1; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-size: 1.35rem; font-weight: 600; color: var(--text); }
.page-subtitle { font-size: .85rem; color: var(--text-muted); margin-top: 2px; }

/* ---- CARDS ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: .95rem; font-weight: 600; }
.card-body { padding: 20px; }

/* ---- STATS GRID ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex; align-items: flex-start; gap: 14px;
  transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); }
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-icon.blue   { background: var(--blue-50);   color: var(--blue-600); }
.stat-icon.amber  { background: var(--amber-100);  color: var(--amber-600); }
.stat-icon.green  { background: var(--green-100);  color: var(--green-600); }
.stat-icon.red    { background: var(--red-100);    color: var(--red-600); }
.stat-icon.purple { background: var(--purple-100); color: var(--purple-600); }
.stat-value { font-size: 1.6rem; font-weight: 600; line-height: 1; color: var(--text); }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }
.stat-trend { font-size: .75rem; margin-top: 4px; }
.stat-trend.up   { color: var(--green-600); }
.stat-trend.down { color: var(--red-600); }

/* ---- TABLE ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { border-bottom: 1px solid var(--border); }
th {
  padding: 10px 14px;
  text-align: left;
  font-size: .75rem; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .04em;
  white-space: nowrap;
}
td {
  padding: 12px 14px;
  font-size: .875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--gray-50); }
.table-actions { display: flex; gap: 4px; }

/* ---- BADGES ---- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .72rem; font-weight: 600;
  white-space: nowrap;
}
.badge-dot { width: 5px; height: 5px; border-radius: 50%; }
.badge-blue   { background: var(--blue-100);   color: var(--blue-700); }
.badge-amber  { background: var(--amber-100);  color: var(--amber-600); }
.badge-green  { background: var(--green-100);  color: var(--green-700); }
.badge-red    { background: var(--red-100);    color: var(--red-700); }
.badge-purple { background: var(--purple-100); color: var(--purple-600); }
.badge-gray   { background: var(--gray-100);   color: var(--gray-600); }

/* ---- BOTONES ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: .875rem; font-weight: 500;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--blue-600); color: #fff; border-color: var(--blue-600); }
.btn-primary:hover { background: var(--blue-700); border-color: var(--blue-700); color: #fff; }
.btn-secondary { background: var(--bg-card); color: var(--text); border-color: var(--border-dark); }
.btn-secondary:hover { background: var(--gray-100); }
.btn-danger { background: var(--red-600); color: #fff; }
.btn-danger:hover { background: var(--red-700); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-xs { padding: 3px 8px; font-size: .75rem; border-radius: 6px; }
.btn-icon { padding: 7px; }

/* ---- FORMULARIOS ---- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .83rem; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.form-label .req { color: var(--red-500); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  font-size: .875rem;
  color: var(--text);
  background: var(--bg-card);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.form-control.error { border-color: var(--red-500); }
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: .78rem; color: var(--red-600); margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; }

/* ---- SEARCH BAR ---- */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  background: var(--bg-card);
}
.search-bar input {
  border: none; outline: none;
  font-size: .875rem; color: var(--text);
  background: transparent; flex: 1;
}
.search-bar .search-icon { color: var(--text-muted); font-size: .9rem; }

/* ---- FILTROS ---- */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 16px;
}

/* ---- PAGINACIÓN ---- */
.pagination {
  display: flex; align-items: center; gap: 4px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.page-btn {
  min-width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .83rem; color: var(--text-muted);
  background: var(--bg-card);
  transition: all var(--transition);
  padding: 0 8px;
}
.page-btn:hover { background: var(--gray-100); color: var(--text); }
.page-btn.active { background: var(--blue-600); color: #fff; border-color: var(--blue-600); }
.page-info { font-size: .8rem; color: var(--text-muted); margin-left: auto; }

/* ---- AVATAR ---- */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--blue-600);
  color: #fff;
  display: grid; place-items: center;
  font-size: .78rem; font-weight: 600;
  flex-shrink: 0;
}
.avatar-sm { width: 26px; height: 26px; font-size: .7rem; }
.avatar-lg { width: 44px; height: 44px; font-size: .95rem; }

/* ---- ALERTS ---- */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 16px;
}
.alert-success { background: var(--green-100); color: var(--green-700); border-left: 3px solid var(--green-500); }
.alert-danger   { background: var(--red-100);   color: var(--red-700);   border-left: 3px solid var(--red-500); }
.alert-warning  { background: var(--amber-100); color: var(--amber-600); border-left: 3px solid var(--amber-500); }
.alert-info     { background: var(--blue-50);   color: var(--blue-700);  border-left: 3px solid var(--blue-500); }

/* ---- PRIORITY DOT ---- */
.priority-dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0;
}
.priority-dot.low      { background: var(--gray-400); }
.priority-dot.medium   { background: var(--blue-500); }
.priority-dot.high     { background: var(--amber-500); }
.priority-dot.critical { background: var(--red-500); box-shadow: 0 0 0 3px rgba(239,68,68,.2); }

/* ---- TICKET THREAD ---- */
.thread { display: flex; flex-direction: column; gap: 16px; }
.thread-item { display: flex; gap: 12px; }
.thread-bubble {
  flex: 1; background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.thread-bubble.own { background: var(--blue-50); border-color: var(--blue-100); }
.thread-bubble.internal { background: #fffbeb; border-color: var(--amber-100); }
.thread-bubble.system { background: var(--gray-100); border-color: var(--border); font-style: italic; }
.thread-header {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
  font-size: .78rem; color: var(--text-muted);
}
.thread-header strong { color: var(--text); font-weight: 500; }
.thread-body { padding: 12px 14px; font-size: .875rem; line-height: 1.7; white-space: pre-wrap; }
.internal-badge {
  margin-left: auto;
  background: var(--amber-100); color: var(--amber-600);
  font-size: .68rem; font-weight: 600; padding: 1px 6px; border-radius: 4px;
}

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center; padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; opacity: .3; margin-bottom: 16px; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-state p  { font-size: .875rem; }

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  transform: translateY(10px);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-body { padding: 20px 22px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
}
.close-btn {
  background: transparent; border: none;
  color: var(--text-muted); font-size: 1.2rem;
  padding: 4px; border-radius: 6px;
  transition: all var(--transition);
}
.close-btn:hover { background: var(--gray-100); color: var(--text); }

/* ---- DROPDOWN ---- */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 180px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
  opacity: 0; transform: translateY(-6px);
  pointer-events: none;
  transition: all var(--transition);
}
.dropdown-menu.open { opacity: 1; transform: translateY(0); pointer-events: all; }
.dropdown-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  font-size: .875rem; color: var(--text);
  transition: background var(--transition);
  border: none; background: none; width: 100%; text-align: left;
}
.dropdown-item:hover { background: var(--gray-50); }
.dropdown-item.danger { color: var(--red-600); }
.dropdown-item.danger:hover { background: var(--red-100); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ---- TABS ---- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 9px 16px;
  font-size: .875rem; font-weight: 500;
  color: var(--text-muted);
  border: none; background: transparent;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--blue-600); border-bottom-color: var(--blue-600); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---- SPEC TABLE ---- */
.spec-table { width: 100%; }
.spec-table tr td:first-child {
  width: 40%; font-size: .8rem; font-weight: 500;
  color: var(--text-muted); padding: 6px 0;
}
.spec-table tr td:last-child { font-size: .875rem; font-family: var(--mono); }

/* ---- TIMELINE ---- */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item { display: flex; gap: 12px; padding-bottom: 16px; position: relative; }
.timeline-item::before {
  content: ''; position: absolute;
  left: 14px; top: 28px; bottom: 0;
  width: 1px; background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--gray-100); border: 2px solid var(--border);
  display: grid; place-items: center; font-size: .75rem; flex-shrink: 0;
  margin-top: 2px;
}
.timeline-content { flex: 1; }
.timeline-meta { font-size: .78rem; color: var(--text-muted); }
.timeline-text { font-size: .875rem; margin-top: 2px; }

/* ---- LOGIN PAGE ---- */
.login-page {
  min-height: 100vh;
  display: flex;
}
.login-left {
  flex: 1;
  background: var(--bg-sidebar);
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
  position: relative; overflow: hidden;
}
.login-left::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 30% 50%, rgba(59,130,246,.15) 0%, transparent 60%);
}
.login-right {
  width: 420px;
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
  background: var(--bg-card);
}
.login-box { width: 100%; }
.login-heading { font-size: 1.5rem; font-weight: 600; margin-bottom: 6px; }
.login-sub { font-size: .875rem; color: var(--text-muted); margin-bottom: 28px; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .login-left { display: none; }
  .login-right { width: 100%; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---- UTILITIES ---- */
.flex   { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.mt-4   { margin-top: 16px; }
.mb-4   { margin-bottom: 16px; }
.mr-2   { margin-right: 8px; }
.ml-auto { margin-left: auto; }
.text-sm    { font-size: .85rem; }
.text-xs    { font-size: .75rem; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.font-mono  { font-family: var(--mono); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 99px; }
