/* ============================================================
   COMUNIK2 — Estilos principales
   ============================================================ */

:root {
  --primary:      #f97316;
  --primary-dark: #ea580c;
  --sidebar-bg:   #DDD7CC;
  --sidebar-w:    260px;
  --topnav-h:     64px;
  --text-muted:   #78716c;
  --border:       #e8d5bc;
  --bg-body:      #fef7ee;
  --card-shadow:  0 1px 4px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04);
  --transition:   .2s ease;
  --purple:       #7c3aed;
}

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-body);
  color: #1e293b;
  font-size: 14px;
  overflow-x: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform var(--transition);
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid rgba(0,0,0,.08);
}
.sidebar-brand-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #f97316, #fb923c);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px; flex-shrink: 0;
}
.sidebar-brand-text span {
  display: block; color: #1c1917; font-weight: 700; font-size: 15px; line-height: 1.2;
}
.sidebar-brand-text small {
  color: #a8a29e; font-size: 11px;
}
.sidebar-divider { height: 1px; background: rgba(0,0,0,.07); margin: 4px 16px; }

.sidebar-nav { list-style: none; padding: 8px 10px; margin: 0; flex: 1; overflow-y: auto; }
.sidebar-item { margin: 2px 0; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  color: #57534e; text-decoration: none;
  border-radius: 8px;
  transition: background var(--transition), color var(--transition);
  position: relative;
  font-size: 13.5px; font-weight: 500;
}
.sidebar-link:hover { background: rgba(249,115,22,.08); color: #1c1917; }
.sidebar-link.active {
  background: linear-gradient(90deg, rgba(249,115,22,.18), rgba(249,115,22,.07));
  color: #ea580c;
  border-left: 3px solid var(--primary);
}
.sidebar-link i { font-size: 16px; flex-shrink: 0; }
.sidebar-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}

.sidebar-footer { padding: 12px 10px; border-top: 1px solid rgba(0,0,0,.08); }
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 8px;
  text-decoration: none;
  transition: background var(--transition);
}
.sidebar-user:hover { background: rgba(0,0,0,.05); }
.sidebar-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #f97316, #fb923c);
  color: #fff; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-user-name { color: #1c1917; font-size: 13px; font-weight: 600; }
.sidebar-user-role { color: #a8a29e; font-size: 11px; }

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

/* ── Top Navbar ───────────────────────────────────────────── */
.topnav {
  position: sticky; top: 0; z-index: 1030;
  height: var(--topnav-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.sidebar-toggle { color: #64748b; padding: 4px 8px; }
.sidebar-toggle:hover { color: var(--primary); }
.topnav-title { flex: 1; }
.topnav-actions { display: flex; align-items: center; gap: 6px; }

.notif-btn { color: #64748b; padding: 6px 10px; border-radius: 8px; }
.notif-btn:hover { background: #f1f5f9; color: var(--primary); }
.notif-badge {
  position: absolute; top: 2px; right: 2px;
  background: #ef4444; color: #fff;
  font-size: 9px; font-weight: 700; min-width: 16px; height: 16px;
  border-radius: 8px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
}

.notif-dropdown { width: 340px; padding: 0; border: 1px solid var(--border); }
.notif-header { border-bottom: 1px solid var(--border); background: #f8fafc; }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; text-decoration: none; color: inherit;
  border-bottom: 1px solid #f1f5f9;
  transition: background var(--transition);
}
.notif-item:hover { background: #f8fafc; }
.notif-icon {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 15px;
}
.notif-info    .notif-icon { background: #ffedd5; color: #f97316; }
.notif-warning .notif-icon { background: #fef3c7; color: #d97706; }
.notif-danger  .notif-icon { background: #fee2e2; color: #dc2626; }
.notif-success .notif-icon { background: #d1fae5; color: #059669; }
.notif-title { font-size: 13px; font-weight: 500; color: #1e293b; line-height: 1.3; }
.notif-time  { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.notif-empty { text-align: center; padding: 32px 16px; color: #94a3b8; }
.notif-empty i { font-size: 28px; display: block; margin-bottom: 8px; }

.user-btn { display: flex; align-items: center; color: #374151; padding: 6px 10px; border-radius: 8px; }
.user-btn:hover { background: #f1f5f9; }
.topnav-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #f97316, #fb923c);
  color: #fff; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}

/* ── Page Content ────────────────────────────────────────── */
.page-content { padding: 24px; flex: 1; }
.page-header { margin-bottom: 24px; }
.page-title { font-size: 20px; font-weight: 700; color: #1c1917; margin: 0; }
.page-subtitle { color: var(--text-muted); font-size: 13px; margin: 4px 0 0; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.card-header {
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 16px 20px; border-radius: 12px 12px 0 0;
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 15px; font-weight: 600; margin: 0; color: #1c1917; }
.card-body { padding: 20px; }

/* ── Stat Cards ──────────────────────────────────────────── */
.stat-card {
  border-radius: 12px; padding: 20px;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: var(--card-shadow);
  display: flex; align-items: center; gap: 16px;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.stat-icon {
  width: 52px; height: 52px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-value { font-size: 26px; font-weight: 700; line-height: 1; color: #1c1917; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-blue   .stat-icon { background: #ffedd5; color: #f97316; }
.stat-green  .stat-icon { background: #d1fae5; color: #059669; }
.stat-orange .stat-icon { background: #ffedd5; color: #ea580c; }
.stat-red    .stat-icon { background: #fee2e2; color: #dc2626; }
.stat-purple .stat-icon { background: #ede9fe; color: #7c3aed; }
.stat-yellow .stat-icon { background: #fef9c3; color: #ca8a04; }

/* ── Status & Priority Badges ────────────────────────────── */
.status-badge { font-size: 11.5px; padding: 4px 10px; border-radius: 20px; font-weight: 500; }
.badge-purple { background: #ede9fe !important; color: #7c3aed !important; }
.bg-purple    { background: #7c3aed !important; }

/* ── Tables ──────────────────────────────────────────────── */
.table-card { border-radius: 12px; overflow: hidden; border: 1px solid var(--border); box-shadow: var(--card-shadow); }
.table { margin: 0; }
.table thead th {
  background: #f8fafc; color: #64748b; font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
  padding: 12px 16px; border-bottom: 2px solid var(--border);
}
.table tbody td { padding: 13px 16px; vertical-align: middle; border-bottom: 1px solid #f1f5f9; }
.table tbody tr:hover { background: #fafafa; }
.table tbody tr:last-child td { border-bottom: none; }

/* ── Forms ───────────────────────────────────────────────── */
.form-control, .form-select {
  border: 1.5px solid #e2e8f0; border-radius: 8px;
  padding: 9px 13px; font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(249,115,22,.15);
  outline: none;
}
.form-label { font-weight: 500; font-size: 13px; color: #374151; margin-bottom: 6px; }
.form-text { font-size: 12px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn { border-radius: 8px; font-weight: 500; font-size: 13.5px; transition: all var(--transition); }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; }

/* ── Priority indicator ──────────────────────────────────── */
.priority-dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px;
}
.priority-alta   .priority-dot { background: #ef4444; }
.priority-media  .priority-dot { background: #f59e0b; }
.priority-baja   .priority-dot { background: #22c55e; }

/* ── Timeline ────────────────────────────────────────────── */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: ''; position: absolute; left: 11px; top: 0; bottom: 0;
  width: 2px; background: #e2e8f0;
}
.timeline-item { position: relative; margin-bottom: 24px; }
.timeline-dot {
  position: absolute; left: -22px; top: 4px;
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
  z-index: 1;
}
.timeline-dot.bg-primary   { background: var(--primary); }
.timeline-dot.bg-success   { background: #059669; }
.timeline-dot.bg-warning   { background: #d97706; }
.timeline-dot.bg-danger    { background: #dc2626; }
.timeline-dot.bg-secondary { background: #64748b; }
.timeline-dot.bg-info      { background: #0891b2; }
.timeline-dot.bg-purple    { background: var(--purple); }
.timeline-content { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.timeline-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 6px; }
.timeline-title  { font-weight: 600; font-size: 13.5px; color: #1e293b; }
.timeline-time   { font-size: 11px; color: #94a3b8; flex-shrink: 0; }
.timeline-body   { font-size: 13px; color: #475569; }

/* ── Ticket detail ───────────────────────────────────────── */
.ticket-meta td { padding: 8px 12px; font-size: 13px; }
.ticket-meta td:first-child { color: #64748b; font-weight: 500; white-space: nowrap; }

/* ── Login page ──────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  background: linear-gradient(135deg, #fde8cc 0%, #fdd5a8 50%, #fce0bb 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  width: 420px; background: #fff; border-radius: 16px;
  padding: 40px; box-shadow: 0 25px 60px rgba(180,90,0,.18);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 28px; font-weight: 800; color: #1c1917; letter-spacing: 1px; margin: 0; }
.login-logo p  { color: #78716c; font-size: 13px; margin: 6px 0 0; }
.login-logo .icon-wrap {
  width: 60px; height: 60px; background: linear-gradient(135deg, #f97316, #fb923c);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px; font-size: 26px; color: #fff;
}

/* ── Dashboard ───────────────────────────────────────────── */
.chart-container { position: relative; height: 260px; }

/* ── Filters bar ─────────────────────────────────────────── */
.filters-bar {
  background: #fff; border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 20px;
  margin-bottom: 20px; box-shadow: var(--card-shadow);
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 8px 0 24px rgba(0,0,0,.25); }
  .main-wrapper { margin-left: 0; }
  .page-content { padding: 16px; }
}

/* ── Utilities ───────────────────────────────────────────── */
.fw-600 { font-weight: 600; }
.text-xs { font-size: 11.5px; }
.text-sm { font-size: 13px; }
.rounded-lg { border-radius: 12px !important; }
.gap-2  { gap: .5rem; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.cursor-pointer { cursor: pointer; }

/* ── DataTables overrides ────────────────────────────────── */
.dataTables_wrapper .dataTables_filter input { border: 1.5px solid #e2e8f0; border-radius: 8px; padding: 6px 12px; font-size: 13px; }
.dataTables_wrapper .dataTables_length select { border: 1.5px solid #e2e8f0; border-radius: 8px; padding: 5px 10px; }
.dataTables_wrapper .dataTables_paginate .paginate_button { border-radius: 6px !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current { background: var(--primary) !important; border-color: var(--primary) !important; color: #fff !important; }

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in-up { animation: fadeInUp .3s ease forwards; }

/* ── Sidebar collapsed ───────────────────────────────────── */
.sidebar-collapsed .sidebar { width: 64px; }
.sidebar-collapsed .sidebar-brand-text,
.sidebar-collapsed .sidebar-link span,
.sidebar-collapsed .sidebar-badge,
.sidebar-collapsed .sidebar-user-name,
.sidebar-collapsed .sidebar-user-role { display: none; }
.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 16px; }
.sidebar-collapsed .sidebar-link { justify-content: center; padding: 10px; }
.sidebar-collapsed .sidebar-user { justify-content: center; }
.sidebar-collapsed .main-wrapper { margin-left: 64px; }

/* ── Inline alerts in forms ──────────────────────────────── */
.field-error { color: #dc2626; font-size: 12px; margin-top: 4px; }
.form-control.is-invalid { border-color: #dc2626; }
