/* =====================================================================
   Central de Atendimento OS — estilos
   ===================================================================== */
:root {
  --primary: #4f46e5;
  --primary-2: #6d28d9;
  --primary-soft: #eef2ff;
  --dark: #0f172a;
  --dark-2: #1e293b;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14.5px;
}

/* =====================================================================
   TELA DE LOGIN
   ===================================================================== */
.login-body { margin: 0; overflow: hidden; }
.login-bg { position: fixed; inset: 0; z-index: 0; background: linear-gradient(135deg, #0f172a 0%, #312e81 55%, #4f46e5 100%); }
.login-bg-layer {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  opacity: .32;
}
.login-bg-layer.has-image { opacity: .38; }
.login-bg::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 0%, rgba(0,0,0,.45) 100%);
  pointer-events: none;
}
.login-wrap {
  position: relative; z-index: 1; height: 100vh;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.login-card {
  width: 100%; max-width: 400px;
  background: rgba(255,255,255,.94);
  border-radius: 20px; padding: 2.2rem 2rem 1.6rem;
  box-shadow: 0 30px 80px rgba(0,0,0,.45);
}
.login-brand { text-align: center; margin-bottom: 1.6rem; }
.login-logo {
  width: 140px; height: 140px; margin: 0 auto 18px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 28px; overflow: hidden;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; font-size: 3.2rem;
  box-shadow: 0 16px 32px rgba(79,70,229,.45);
}
.login-logo img { width: 100%; height: 100%; object-fit: contain; background:#fff; padding: 8px; }
.login-title { font-size: 1.35rem; font-weight: 700; margin: 0; }
.login-subtitle { color: var(--muted); font-size: .86rem; margin: 4px 0 0; }
.btn-login {
  background: linear-gradient(135deg, var(--primary), var(--primary-2)) !important;
  border: none !important; font-weight: 600; padding: .72rem; border-radius: 10px;
}
.login-error { border-radius: 8px; }
.login-footer {
  margin-top: 1.4rem; padding-top: 1rem; border-top: 1px solid var(--border);
  text-align: center; color: var(--muted); font-size: .78rem;
  display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap;
}
.dot { width: 5px; height: 5px; border-radius: 50%; background: var(--primary); display: inline-block; }
.login-body .form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 .2rem rgba(79,70,229,.15); }

/* =====================================================================
   SHELL DA APLICACAO
   ===================================================================== */
.app-body { margin: 0; }
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px; flex-shrink: 0;
  background: linear-gradient(180deg, var(--dark) 0%, #111c37 100%);
  color: #cbd5e1;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px; color: #fff;
}
.sidebar-logo {
  width: 42px; height: 42px; border-radius: 12px; overflow: hidden;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.2rem; flex-shrink: 0;
}
.sidebar-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; padding: 4px; }
.sidebar-brand strong { display: block; font-size: .98rem; line-height: 1.15; }
.sidebar-brand small { color: #94a3b8; font-size: .72rem; }
.sidebar-nav { flex: 1; padding: 8px 10px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; margin-bottom: 2px; border-radius: 10px;
  color: #cbd5e1; text-decoration: none; font-weight: 500; font-size: .9rem;
  transition: background .15s, color .15s;
}
.nav-item i { font-size: 1.05rem; width: 20px; text-align: center; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 6px 16px rgba(79,70,229,.35); }
.nav-sep { border-color: rgba(255,255,255,.08); margin: 10px 6px; }
.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.user-mini { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; font-weight: 700; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
}
.avatar-lg { width: 74px; height: 74px; font-size: 1.8rem; border-radius: 22px; }
.user-mini-info { flex: 1; min-width: 0; line-height: 1.25; }
.user-mini-info strong { display: block; color: #fff; font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-mini-info small { color: #94a3b8; font-size: .74rem; }
.icon-btn {
  border: none; background: transparent; color: inherit;
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.user-mini .icon-btn { color: #94a3b8; }
.user-mini .icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }

/* principal */
.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 26px;
  background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 1.15rem; font-weight: 700; margin: 0; }
.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.topbar .icon-btn { color: var(--muted); }
.topbar .icon-btn:hover { background: var(--primary-soft); color: var(--primary); }
.topbar .icon-btn.off { color: #b91c1c; }
.main-content { padding: 24px 26px 60px; flex: 1; }

.toast-wrap { position: fixed; top: 70px; right: 20px; z-index: 1200; display: flex; flex-direction: column; gap: 8px; }

.notif-badge { position: absolute; top: 2px; right: 2px; font-size: .62rem; padding: 2px 5px; }
.notif-menu { width: 360px; max-height: 480px; overflow: hidden; padding: 0; display: none; }
.notif-menu.show { display: flex; flex-direction: column; }
.notif-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 600;
}
.notif-list { overflow-y: auto; max-height: 420px; }
.notif-item { white-space: normal; border-bottom: 1px solid var(--border); padding: 10px 14px; }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--primary-soft); }
.notif-title { font-weight: 600; font-size: .84rem; }
.notif-msg { font-size: .78rem; color: var(--muted); margin: 2px 0; }

/* =====================================================================
   CARDS E PAINEL
   ===================================================================== */
.panel-card {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--card);
  box-shadow: 0 1px 3px rgba(15,23,42,.05);
}
.panel-card .card-header {
  background: #f8fafc; border-bottom: 1px solid var(--border);
  padding: 12px 16px; font-size: .92rem;
}

.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 992px) { .stats-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 540px) { .stats-row { grid-template-columns: 1fr; } }
.stat-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: 0 1px 3px rgba(15,23,42,.05);
}
.stat-icon {
  width: 52px; height: 52px; border-radius: 14px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
  color: var(--primary); background: var(--primary-soft);
}
.stat-card.tone-green .stat-icon { background: #dcfce7; color: #16a34a; }
.stat-card.tone-amber .stat-icon { background: #fef3c7; color: #d97706; }
.stat-card.tone-red .stat-icon { background: #fee2e2; color: #dc2626; }
.stat-value { font-size: 1.7rem; font-weight: 800; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .8rem; font-weight: 600; }
.stat-sub { color: var(--muted); font-size: .72rem; }

/* =====================================================================
   TABELAS E BADGES
   ===================================================================== */
.dashboard-table thead th {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); border-bottom-width: 1px;
}
.dashboard-table tbody tr { cursor: pointer; }
.ticket-title { width: 340px; max-width: 340px; overflow-wrap: break-word; }
.tech-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #f0f9ff; color: #0369a1;
  padding: 4px 10px; border-radius: 20px; font-size: .8rem;
}
.badge { font-weight: 600; border-radius: 8px; }

.bd-new { background: #dbeafe; color: #1d4ed8; }
.bd-assigned { background: #ede9fe; color: #6d28d9; }
.bd-progress { background: #cffafe; color: #0e7490; }
.bd-pending { background: #fef3c7; color: #b45309; }
.bd-solved { background: #dcfce7; color: #15803d; }
.bd-closed { background: #e2e8f0; color: #475569; }
.bd-canceled { background: #fee2e2; color: #b91c1c; }
.bd-pending-approval { background: #fef3c7; color: #b45309; }
.bd-approval-pending { background: #fef3c7; color: #b45309; }
.bd-approval-approved { background: #dcfce7; color: #15803d; }
.bd-approval-rejected { background: #fee2e2; color: #b91c1c; }

.prio-low { background: #f1f5f9; color: #334155; }
.prio-med { background: #fef3c7; color: #b45309; }
.prio-high { background: #ffedd5; color: #c2410c; }
.prio-urgent { background: #fee2e2; color: #b91c1c; }

.empty-state { text-align: center; padding: 56px 16px; color: var(--muted); }
.empty-state i { font-size: 3rem; display: block; margin-bottom: 12px; color: #cbd5e1; }

/* =====================================================================
   TIMELINE
   ===================================================================== */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline-item { display: flex; gap: 12px; padding-bottom: 16px; position: relative; }
.timeline-item::before {
  content: ''; position: absolute; left: 17px; top: 40px; bottom: 0;
  width: 2px; background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.tl-badge {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  background: #e0e7ff; color: var(--primary);
}
.tl-badge.tl-warning { background: #fef3c7; color: #b45309; }
.tl-badge.tl-primary { background: #dcfce7; color: #15803d; }
.tl-badge.tl-info { background: #dbeafe; color: #1d4ed8; }
.tl-body { flex: 1; min-width: 0; }
.tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-content {
  background: #f8fafc; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; margin-top: 6px; font-size: .9rem;
}
.timeline-item.system .tl-badge { background: #f1f5f9; color: var(--muted); }
.timeline-item.system .tl-content { background: transparent; border: none; padding: 4px 0; font-style: italic; }

.ticket-desc { white-space: pre-line; }
.info-table th { font-size: .8rem; color: var(--muted); font-weight: 600; width: 120px; }
.info-table td { font-size: .88rem; }

.blink-dot { animation: blink 1.2s infinite; font-size: .85rem; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

.pending-box { border-left: 5px solid #d97706; }

/* =====================================================================
   UPLOAD / MISC
   ===================================================================== */
.upload-box {
  border: 2px dashed var(--border); border-radius: 12px;
  height: 130px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--muted); cursor: pointer; overflow: hidden; text-align: center;
  background: #f8fafc; font-size: .8rem;
}
.upload-box i { font-size: 1.7rem; margin-bottom: 6px; }
.upload-box img { width: 100%; height: 100%; object-fit: contain; }
.upload-box.bg-box img { object-fit: cover; }
.upload-box:hover { border-color: var(--primary); color: var(--primary); }
.entity-logo {
  max-width: 46px; max-height: 46px; object-fit: contain;
  border-radius: 8px; background: #fff;
  border: 1px solid var(--border); padding: 2px;
}
.profile-entity-logo {
  max-height: 56px; max-width: 180px; object-fit: contain;
  margin: 0 auto 8px; display: block;
}

@media (max-width: 992px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 100; transform: translateX(-100%); transition: transform .2s; }
  .app-body.sidebar-open .sidebar { transform: translateX(0); }
  .main-content { padding: 18px 14px 60px; }
}