/* ============================================================
   PAINEL IPTV — Estilos Globais
   ============================================================ */
:root {
  --bg-body:      #0f172a;
  --bg-card:      #1e293b;
  --bg-sidebar:   #1e293b;
  --bg-input:     #0f172a;
  --border:       #334155;
  --primary:      #6366f1;
  --primary-dark: #4f46e5;
  --success:      #22c55e;
  --danger:       #ef4444;
  --warning:      #f59e0b;
  --info:         #3b82f6;
  --text:         #e2e8f0;
  --text-muted:   #94a3b8;
  --sidebar-w:    260px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-body);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
}

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

/* ── Layout ────────────────────────────────────────────────── */
.wrapper { display: flex; min-height: 100vh; }

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

.sidebar-brand {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-brand .logo {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; color: #fff;
}

.sidebar-brand .brand-name {
  font-size: 16px; font-weight: 700; color: #fff;
  line-height: 1.2;
}

.sidebar-brand .brand-sub {
  font-size: 11px; color: var(--text-muted);
}

.sidebar-nav { flex: 1; padding: 16px 0; overflow-y: auto; }

.nav-section {
  padding: 8px 16px 4px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 8px;
  margin: 2px 8px;
  transition: all .2s;
  font-size: 14px;
  cursor: pointer;
}

.nav-item:hover { background: rgba(99,102,241,.1); color: var(--text); }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item i { width: 18px; text-align: center; font-size: 16px; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,.04);
  border-radius: 10px;
  cursor: pointer;
}

.user-avatar {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff;
}

.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 11px; color: var(--text-muted); }

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

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  height: 60px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
}

.topbar-title { font-size: 16px; font-weight: 600; }

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.btn-icon {
  width: 36px; height: 36px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .2s;
}
.btn-icon:hover { background: rgba(255,255,255,.1); color: var(--text); }

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

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}

.card-title { font-size: 15px; font-weight: 600; }

/* ── Stat Cards ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}

.stat-icon.indigo { background: rgba(99,102,241,.15); color: var(--primary); }
.stat-icon.green  { background: rgba(34,197,94,.15);  color: var(--success); }
.stat-icon.red    { background: rgba(239,68,68,.15);   color: var(--danger); }
.stat-icon.amber  { background: rgba(245,158,11,.15);  color: var(--warning); }
.stat-icon.blue   { background: rgba(59,130,246,.15);  color: var(--info); }

.stat-value { font-size: 24px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Botões ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  border: none; cursor: pointer;
  transition: all .2s;
  text-decoration: none;
}
.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-primary  { background: var(--primary);  color: #fff; }
.btn-primary:hover  { background: var(--primary-dark); }
.btn-success  { background: var(--success);  color: #fff; }
.btn-danger   { background: var(--danger);   color: #fff; }
.btn-warning  { background: var(--warning);  color: #fff; }
.btn-secondary {
  background: rgba(255,255,255,.08);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-secondary:hover { background: rgba(255,255,255,.12); }
.btn-outline  {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: rgba(255,255,255,.05); }

/* ── Tabela ───────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: 8px; }

table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: rgba(255,255,255,.04);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid rgba(51,65,85,.5);
  transition: background .15s;
}
tbody tr:hover { background: rgba(255,255,255,.025); }
tbody td { padding: 12px 14px; vertical-align: middle; }

/* ── Badges ───────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-success { background: rgba(34,197,94,.15);  color: #4ade80; }
.badge-danger  { background: rgba(239,68,68,.15);   color: #f87171; }
.badge-warning { background: rgba(245,158,11,.15);  color: #fbbf24; }
.badge-info    { background: rgba(59,130,246,.15);  color: #60a5fa; }
.badge-muted   { background: rgba(148,163,184,.1);  color: var(--text-muted); }

/* ── Inputs / Forms ─────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-size: 14px;
  transition: border .2s;
}
.form-control:focus { outline: none; border-color: var(--primary); }
.form-control::placeholder { color: #475569; }

select.form-control option { background: #1e293b; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  width: 100%; max-width: 480px;
  transform: scale(.95);
  transition: transform .2s;
}
.modal-overlay.open .modal { transform: scale(1); }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { cursor: pointer; color: var(--text-muted); font-size: 20px; }
.modal-close:hover { color: var(--text); }

.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ── Paginação ───────────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; align-items: center; margin-top: 16px; }
.page-btn {
  min-width: 32px; height: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 12px; font-weight: 600;
  color: var(--text-muted);
  transition: all .2s;
}
.page-btn:hover, .page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: default; }

/* ── Search Bar ─────────────────────────────────────────────── */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
}
.search-bar input { background: none; border: none; outline: none; color: var(--text); font-size: 13px; flex: 1; }
.search-bar i { color: var(--text-muted); }

/* ── Toast ───────────────────────────────────────────────────── */
#toast-container {
  position: fixed; top: 16px; right: 16px;
  z-index: 999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
  min-width: 280px; max-width: 400px;
  animation: slideIn .3s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--info); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Spinner ─────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Loading overlay ─────────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}

/* ── Ticket chat ─────────────────────────────────────────────── */
.ticket-chat { display: flex; flex-direction: column; gap: 12px; max-height: 500px; overflow-y: auto; padding: 4px; }
.msg-bubble { display: flex; gap: 10px; }
.msg-bubble.admin { flex-direction: row-reverse; }
.msg-avatar { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.msg-content { max-width: 70%; }
.msg-text { background: rgba(255,255,255,.06); border-radius: 10px; padding: 10px 14px; font-size: 13px; line-height: 1.5; }
.msg-bubble.admin .msg-text { background: rgba(99,102,241,.2); }
.msg-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

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

/* ── Login Page ──────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-body);
  padding: 20px;
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px;
  width: 100%; max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.login-logo {
  width: 56px; height: 56px;
  background: var(--primary);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 900; color: #fff;
  margin: 0 auto 20px;
}
.login-title { text-align: center; font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-sub   { text-align: center; font-size: 13px; color: var(--text-muted); margin-bottom: 28px; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: 240px; min-height: 100vh; background: #0f172a;
  display: flex; flex-direction: column; position: fixed;
  left: 0; top: 0; z-index: 100; transition: transform .3s ease;
  border-right: 1px solid #1e293b;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 16px; border-bottom: 1px solid #1e293b;
}
.brand-name { font-size: 16px; font-weight: 700; color: #f1f5f9; }
.sidebar-user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 16px; border-bottom: 1px solid #1e293b;
}
.sidebar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: #6366f1; display: flex; align-items: center;
  justify-content: center; font-weight: 700; color: #fff; font-size: 16px;
  flex-shrink: 0;
}
.sidebar-user-name { font-size: 13px; font-weight: 600; color: #f1f5f9; }
.sidebar-user-role { font-size: 11px; color: #64748b; margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; color: #94a3b8;
  text-decoration: none; font-size: 14px; transition: all .15s ease;
}
.nav-item:hover { background: #1e293b; color: #f1f5f9; }
.nav-item.active { background: #6366f1; color: #fff; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-footer-btn { padding: 12px 8px; border-top: 1px solid #1e293b; }
.btn-logout {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; background: none; border: none; cursor: pointer;
  color: #ef4444; font-size: 14px; border-radius: 8px; transition: background .15s;
}
.btn-logout:hover { background: #1e293b; }
.main-content { margin-left: 240px; min-height: 100vh; }
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
}
