/* =====================================================
   TICKET SYSTEM — CSS responsivo mobile-first
   Breakpoints: <480px (phone), 480-768 (phablet),
                768-1024 (tablet), 1024+ (desktop)
   ===================================================== */

/* --- Reset & variáveis --- */
:root {
  --bg0:    #050b16;
  --bg1:    #07152b;
  --card:   rgba(8,18,40,0.62);
  --border: rgba(120,170,255,.18);
  --text:   rgba(245,248,255,.92);
  --muted:  rgba(245,248,255,.55);
  --good:   #2ee59d;
  --bad:    #ff4d6d;
  --warn:   #ffce47;
  --shadow: 0 8px 32px rgba(0,0,0,.40);
  --r:      18px;
  --font:   ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse 80vw 60vh at 15% 10%, rgba(77,178,255,.15), transparent 60%),
    radial-gradient(ellipse 70vw 50vh at 85% 25%, rgba(43,115,255,.12), transparent 55%),
    linear-gradient(180deg, var(--bg0) 0%, var(--bg1) 100%);
  background-attachment: fixed;
}

a { color: inherit; text-decoration: none; }

/* --- Layout wrapper --- */
.appWrap { display: flex; flex-direction: column; min-height: 100dvh; }

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px;
  flex: 1;
}
@media (min-width: 600px)  { .container { padding: 16px; } }
@media (min-width: 1024px) { .container { padding: 20px; } }

/* --- Card --- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* --- Topbar / Header --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(5,11,22,.40);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;   /* quebra em telas muito pequenas */
}

/* Marca (logo + título) */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;      /* remove o min-width fixo problemático */
  flex: 1 1 auto;
}
.brand .logo {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,.08);
  background: #fff;
  display: grid; place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}
.brand .logo img { width: 100%; height: 100%; object-fit: contain; padding: 5px; }
.brand .title { line-height: 1.1; min-width: 0; }
.brand .title .h1 {
  font-weight: 800; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand .title .sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

@media (min-width: 480px) {
  .brand .logo { width: 44px; height: 44px; }
  .brand .title .h1 { font-size: 15px; }
}

/* Relógio / pill */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(120,170,255,.18);
  background: rgba(10,22,50,.35);
  color: var(--muted); font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}
.pill b { color: var(--text); }

/* Área do usuário logado no header */
.userArea {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
  min-width: 0;
}
.userArea .userName {
  line-height: 1.2;
  max-width: 120px;
  overflow: hidden;
}
@media (min-width: 600px) { .userArea .userName { max-width: 180px; } }
@media (max-width: 479px) {
  /* Em telas muito pequenas, esconde nome e mostra só avatar + botão */
  .userArea .userName { display: none; }
}

/* --- Nav menu --- */
.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  align-items: center;
  padding: 10px 12px;
  background: rgba(5,11,22,.20);
  border-bottom: 1px solid var(--border);
}
.nav a {
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(120,170,255,.16);
  background: rgba(10,22,50,.45);
  color: var(--text);
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
  transition: border-color .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.nav a:hover, .nav a:focus { border-color: rgba(120,170,255,.35); transform: translateY(-1px); }
.nav a:active { transform: translateY(0); }

@media (min-width: 480px) { .nav a { font-size: 13px; padding: 9px 14px; } }

/* --- Tipografia --- */
.h1 { font-size: 15px; font-weight: 800; }
.h2 { font-size: 15px; font-weight: 800; line-height: 1.2; }
.sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

@media (min-width: 600px) { .h2 { font-size: 17px; } }

/* --- Grid utilitário --- */
.grid { display: grid; gap: 12px; }

/* Grid de 2 colunas: uma coluna em mobile, duas em 500px+ */
.grid-2 {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}
@media (min-width: 500px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* Grid de KPIs: auto-fit responsivo */
.grid-kpi {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}
@media (min-width: 480px) { .grid-kpi { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); } }

/* --- Inputs --- */
.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(120,170,255,.18);
  background: rgba(5,11,22,.40);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}
.input::placeholder { color: var(--muted); }
.input:focus {
  border-color: rgba(120,170,255,.42);
  box-shadow: 0 0 0 3px rgba(77,178,255,.12);
}
.input[readonly], .input[disabled] { opacity: .55; cursor: not-allowed; }

textarea.input { resize: vertical; min-height: 130px; line-height: 1.6; }
select.input { cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='rgba(120,170,255,.6)' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; }
input[type="file"].input { padding: 10px; cursor: pointer; }

@media (min-width: 600px) { .input { font-size: 15px; } }

/* --- Botão --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 11px 18px;
  border-radius: 12px;
  border: 1px solid rgba(120,170,255,.22);
  background: rgba(10,22,50,.55);
  color: var(--text);
  font-family: var(--font);
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, background .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:hover  { border-color: rgba(120,170,255,.4); background: rgba(20,40,90,.55); }
.btn:active { transform: scale(.97); }
.btn.danger { border-color: rgba(255,77,109,.35); color: var(--bad); }

/* Botão de largura total em mobile */
@media (max-width: 479px) {
  .btn-full-mobile { width: 100%; }
}

/* --- Tabela responsiva --- */
.tableWrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-top: 1px solid var(--border);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 480px; /* garante scroll horizontal em mobile */
}
thead th {
  text-align: left;
  padding: 10px 12px;
  color: var(--muted);
  background: rgba(5,11,22,.50);
  font-weight: 700;
  white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
tbody td {
  padding: 10px 12px;
  border-top: 1px solid rgba(120,170,255,.08);
  vertical-align: top;
}
tbody tr:hover { background: rgba(120,170,255,.04); }

/* --- Badge / dot --- */
.badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(120,170,255,.18);
  background: rgba(10,22,50,.35);
  font-size: 12px;
  white-space: nowrap;
}
.dot {
  width: 7px; height: 7px; border-radius: 999px;
  background: rgba(200,220,255,.40);
  flex-shrink: 0;
}
.dot.ok   { background: var(--good); }
.dot.bad  { background: var(--bad);  }
.dot.warn { background: var(--warn); }

/* --- Notice / aviso --- */
.notice {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,206,71,.25);
  background: rgba(255,206,71,.07);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

/* --- Footer --- */
.footer {
  padding: 14px 16px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  border-top: 1px solid var(--border);
  background: rgba(5,11,22,.25);
}

/* --- Login / tela centralizada --- */
.loginWrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.loginCard {
  width: 100%;
  max-width: 460px;
}

/* --- Modal (admin) --- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.60);
  display: none;
  align-items: center; justify-content: center;
  padding: 16px;
  overflow-y: auto;
}
.modal-backdrop.show { display: flex; }
.modal {
  width: min(980px, 100%);
  border-radius: 20px;
  background: rgba(8,18,40,0.85);
  border: 1px solid rgba(120,170,255,.20);
  box-shadow: 0 22px 70px rgba(0,0,0,.55);
  overflow: hidden;
  backdrop-filter: blur(12px);
  margin: auto;
}
.modalHeader {
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-bottom: 1px solid rgba(120,170,255,.14);
  flex-wrap: wrap;
}
.modalTitle { font-size: 16px; font-weight: 800; }
.modalClose {
  width: 36px; height: 36px; border-radius: 12px;
  border: 1px solid rgba(120,170,255,.18);
  background: rgba(10,22,50,.35);
  color: var(--text);
  display: grid; place-items: center;
  cursor: pointer; flex-shrink: 0;
  font-size: 16px;
}
.modalBody { padding: 14px 16px; }
.modalGrid { display: grid; gap: 14px; }
@media (min-width: 700px) { .modalGrid { grid-template-columns: 1.1fr .9fr; } }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 5px 10px; font-size: 13px; }
.kv div:nth-child(odd) { color: var(--muted); }
@media (max-width: 479px) { .kv { grid-template-columns: 1fr; } .kv div:nth-child(odd) { margin-top: 8px; } }

.descBox {
  border: 1px solid rgba(120,170,255,.14);
  background: rgba(8,18,40,0.42);
  border-radius: 14px;
  padding: 12px;
  color: rgba(245,248,255,.78);
  white-space: pre-wrap;
  max-height: 220px;
  overflow: auto;
  font-size: 13px;
  line-height: 1.6;
}

body.modalOpen .appWrap { filter: blur(5px); transform: scale(.997); }

/* --- Utilitários extras --- */
.flex-row   { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.text-right { text-align: right; }
.mt-1       { margin-top: 6px; }
.mt-2       { margin-top: 12px; }

/* Scrollbar fina (Webkit) */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(120,170,255,.22); border-radius: 999px; }
