/* ============================================================
   GameTech OS — Stylesheet Principal
   assets/css/app.css
   ============================================================ */

:root {
  --sidebar-w:   240px;
  --topbar-h:    56px;
  --c-primary:   #1a3a5c;
  --c-primary-l: #2563a8;
  --c-accent:    #3b82f6;
  --c-success:   #16a34a;
  --c-warning:   #d97706;
  --c-danger:    #dc2626;
  --c-purple:    #7c3aed;
  --c-orange:    #ea580c;
  --radius:      .5rem;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:   0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
}

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

body {
  font-family: 'Inter', sans-serif;
  font-size: .875rem;
  background: #f1f5f9;
  color: #1e293b;
  margin: 0;
}

/* ---- SIDEBAR ---- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--c-primary);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1000;
  transition: width .25s ease, transform .25s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}
.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .user-info,
.sidebar.collapsed .nav-section,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-badge { display: none !important; }
.sidebar.collapsed .nav-item { justify-content: center; padding: .6rem; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.brand-icon {
  width: 36px; height: 36px;
  background: var(--c-primary-l);
  border-radius: .5rem;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.brand-name  { display: block; color: #fff; font-weight: 600; font-size: .9rem; }
.brand-sub   { display: block; color: rgba(255,255,255,.5); font-size: .7rem; }

.sidebar-user {
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.user-avatar {
  width: 32px; height: 32px;
  background: var(--c-accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .75rem; font-weight: 600;
  flex-shrink: 0;
}
.user-name  { display: block; color: #fff; font-size: .8rem; font-weight: 500; }
.user-role  { display: block; color: rgba(255,255,255,.45); font-size: .7rem; }

.sidebar-nav { padding: .5rem 0; flex: 1; }
.nav-section {
  padding: .5rem 1.25rem .25rem;
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.35);
  font-weight: 500;
}
.nav-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem 1.25rem;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: .8rem;
  transition: all .15s;
  border-left: 3px solid transparent;
  position: relative;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav-item.active { color: #fff; background: rgba(255,255,255,.12); border-left-color: var(--c-accent); }
.nav-item i { font-size: 1rem; width: 1.1rem; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--c-danger);
  color: #fff;
  border-radius: 10px;
  padding: .1rem .45rem;
  font-size: .65rem;
  font-weight: 600;
}
.nav-badge-warn { background: var(--c-warning); }

/* ---- TOPBAR ---- */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: .75rem;
  z-index: 999;
  transition: left .25s ease;
  box-shadow: var(--shadow);
}
.topbar.expanded { left: 64px; }
.page-title { font-size: 1rem; font-weight: 600; margin: 0; white-space: nowrap; }

/* ---- MAIN CONTENT ---- */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
  transition: margin-left .25s ease;
}
.main-content.expanded { margin-left: 64px; }

/* ---- CARDS ---- */
.card {
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 600;
  padding: .875rem 1.25rem;
}

/* ---- METRIC CARDS ---- */
.metric-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.metric-label { font-size: .75rem; color: #64748b; margin-bottom: .25rem; }
.metric-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.metric-sub   { font-size: .72rem; color: #94a3b8; margin-top: .2rem; }
.metric-icon  { font-size: 1.5rem; margin-bottom: .5rem; }

/* ---- TABLES ---- */
.table { font-size: .82rem; }
.table th {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
  color: #64748b;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}
.table td { vertical-align: middle; }
.table-hover tbody tr:hover { background: #f8fafc; }

/* ---- BADGES ---- */
.bg-purple  { background-color: var(--c-purple) !important; }
.bg-orange  { background-color: var(--c-orange) !important; }
.badge { font-size: .72rem; font-weight: 500; }

/* ---- TIMELINE ---- */
.timeline { position: relative; padding-left: 1.5rem; }
.timeline::before {
  content: '';
  position: absolute;
  left: .65rem; top: 0; bottom: 0;
  width: 2px;
  background: #e2e8f0;
}
.tl-item { position: relative; padding-bottom: 1.25rem; }
.tl-dot {
  position: absolute;
  left: -1.5rem;
  top: .1rem;
  width: 1.1rem; height: 1.1rem;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .6rem;
  color: #fff;
  border: 2px solid #fff;
}
.tl-title   { font-weight: 500; font-size: .82rem; }
.tl-meta    { font-size: .72rem; color: #94a3b8; }
.tl-body    { font-size: .8rem; color: #475569; margin-top: .2rem; }

/* ---- KANBAN ---- */
.kanban-board { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: .5rem; }
.kanban-col {
  min-width: 200px;
  background: #f1f5f9;
  border-radius: var(--radius);
  padding: .75rem;
  flex-shrink: 0;
}
.kanban-col-header {
  font-size: .75rem;
  font-weight: 600;
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: .75rem;
}
.kanban-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  padding: .75rem;
  margin-bottom: .5rem;
  cursor: pointer;
  transition: box-shadow .15s, transform .15s;
  text-decoration: none;
  color: inherit;
  display: block;
}
.kanban-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kanban-card-num   { font-size: .72rem; color: var(--c-accent); font-weight: 600; }
.kanban-card-title { font-size: .8rem; font-weight: 500; margin: .2rem 0; }
.kanban-card-sub   { font-size: .72rem; color: #94a3b8; }

/* ---- FORMS ---- */
.form-label    { font-size: .8rem; font-weight: 500; color: #475569; }
.form-control, .form-select {
  font-size: .875rem;
  border-color: #cbd5e1;
}
.form-control:focus, .form-select:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}
.required::after { content: ' *'; color: var(--c-danger); }

/* ---- BUTTONS ---- */
.btn-icon {
  width: 36px; height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e2e8f0;
  background: transparent;
  border-radius: var(--radius);
  color: #64748b;
  transition: all .15s;
}
.btn-icon:hover { background: #f1f5f9; color: #1e293b; }

/* ---- AVATAR ---- */
.avatar-xs {
  width: 28px; height: 28px;
  background: var(--c-accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .7rem; font-weight: 600;
}

/* ---- NOTIF MENU ---- */
.notif-menu  { min-width: 300px; max-height: 380px; overflow-y: auto; }
.notif-item  { display: flex; gap: .75rem; align-items: flex-start; padding: .25rem 0; }
.notif-icon  { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-text  { font-size: .8rem; line-height: 1.3; }
.notif-time  { font-size: .7rem; margin-top: .15rem; }
.notif-dot   { position: absolute; top: 4px; right: 2px; font-size: .6rem; min-width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; }

/* ---- CHARTS ---- */
.chart-bar-row   { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.chart-bar-label { min-width: 130px; font-size: .75rem; color: #64748b; text-align: right; white-space: nowrap; }
.chart-bar-track { flex: 1; height: 1.25rem; background: #f1f5f9; border-radius: 3px; overflow: hidden; }
.chart-bar-fill  { height: 100%; border-radius: 3px; display: flex; align-items: center; padding-left: .5rem; font-size: .7rem; color: #fff; font-weight: 500; transition: width .6s ease; }

/* ---- TREND (comparacao com periodo anterior, secao 7 do prompt mestre HMABI) ---- */
.metric-trend { font-size: .72rem; margin-top: .2rem; display: flex; align-items: center; gap: .3rem; }
.metric-trend.up   { color: var(--c-success); }
.metric-trend.down { color: var(--c-danger); }
.metric-trend.flat { color: #94a3b8; }
.metric-skeleton { color: #cbd5e1; }

/* ---- PRINT STYLES ---- */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-content { margin: 0 !important; }
  .card { border: 1px solid #ccc; box-shadow: none; }
}

/* ============================================================
   MOBILE / PWA
   ============================================================ */

/* Overlay do sidebar no mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 999;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* Banner de instalação PWA */
.pwa-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(135deg, #1a3a5c, #2563a8);
  color: #fff;
  z-index: 2000;
  box-shadow: 0 -4px 20px rgba(0,0,0,.25);
  padding: .75rem 1rem;
  animation: slideUp .3s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.pwa-banner-inner {
  display: flex;
  align-items: center;
  gap: .75rem;
  max-width: 600px;
  margin: 0 auto;
}
.pwa-banner-icon {
  font-size: 1.75rem;
  flex-shrink: 0;
  width: 44px; height: 44px;
  background: rgba(255,255,255,.15);
  border-radius: .5rem;
  display: flex; align-items: center; justify-content: center;
}
.pwa-banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  font-size: .82rem;
  line-height: 1.3;
}
.pwa-banner-text strong { font-size: .9rem; }
.pwa-banner-text span   { opacity: .8; font-size: .75rem; }

/* Botão instalar PWA (topbar) */
#btnInstallPwa {
  background: var(--c-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: .35rem .85rem;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: .4rem;
}
#btnInstallPwa:hover { background: #2563eb; }

/* ---- TABLET / MOBILE (< 768px) ---- */
@media (max-width: 767.98px) {
  /* Sidebar vira drawer */
  .sidebar {
    transform: translateX(-100%);
    z-index: 1000;
    box-shadow: 4px 0 24px rgba(0,0,0,.25);
  }
  .sidebar.show { transform: translateX(0); }

  /* Topbar ocupa full width */
  .topbar { left: 0 !important; }

  /* Conteúdo sem margem lateral */
  .main-content { margin-left: 0 !important; }

  /* Título menor */
  .page-title { font-size: .875rem; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }

  /* Oculta busca no topbar em telas pequenas */
  .topbar-search { display: none !important; }

  /* Aumenta área de toque em botões de ação */
  .btn-icon { width: 40px; height: 40px; }

  /* Inputs maiores para toque */
  .form-control, .form-select { font-size: 1rem; min-height: 44px; }
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }

  /* Cards sem padding lateral excessivo */
  .container-fluid { padding-left: .75rem; padding-right: .75rem; }

  /* Tabelas: scroll horizontal */
  .table-responsive { border: 0; }
  .table { font-size: .78rem; }
  .table th, .table td { padding: .4rem .5rem; }

  /* Oculta colunas secundárias em tabelas grandes */
  .table .col-hide-mobile { display: none; }

  /* Métrics em 2 colunas */
  .row-metrics > [class*='col-'] { flex: 0 0 50%; max-width: 50%; }

  /* Kanban scroll */
  .kanban-board { flex-wrap: nowrap; }
  .kanban-col   { min-width: 75vw; }

  /* Notif menu menor */
  .notif-menu { min-width: 280px; max-width: calc(100vw - 2rem); }

  /* Modal full-screen no mobile */
  .modal-dialog { margin: .5rem; }
  .modal-dialog-scrollable .modal-content { max-height: calc(100vh - 1rem); }
}

/* ---- PEQUENOS (< 480px) ---- */
@media (max-width: 479.98px) {
  .topbar-actions .btn { padding: .35rem .6rem; font-size: .78rem; }
  .row-metrics > [class*='col-'] { flex: 0 0 100%; max-width: 100%; }
}

/* ---- SAFE AREA (notch / home bar iOS) ---- */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .main-content { padding-bottom: env(safe-area-inset-bottom); }
  .sidebar { padding-bottom: env(safe-area-inset-bottom); }
}

/* ---- DARK MODE do sistema (opcional) ---- */
@media (prefers-color-scheme: dark) {
  /* Não aplicar dark mode automaticamente — manter tema da marca */
}
