/* ============================================================
   fgcandlestick — CSS Principal
   Paleta: dark navy + blue accent + verde/âmbar para dados
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Variáveis ──────────────────────────────────────────────── */
:root {
  --bg-base:       #0d0f1a;
  --bg-surface:    #131629;
  --bg-card:       #1a1e35;
  --bg-card-hover: #1f2440;
  --border:        rgba(255,255,255,.07);
  --border-accent: rgba(79,110,247,.4);

  --text-primary:  #e2e8f0;
  --text-secondary:#94a3b8;
  --text-muted:    #64748b;

  --accent:        #4f6ef7;
  --accent-dark:   #3b55d4;
  --accent-glow:   rgba(79,110,247,.25);

  --green:  #22c55e;
  --amber:  #f59e0b;
  --red:    #ef4444;

  --sidebar-w: 240px;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow:    0 4px 24px rgba(0,0,0,.4);

  --transition: .18s ease;
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: #7a99ff; }

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  padding: 0 0 24px;
}

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

.brand-icon { font-size: 1.6rem; }

.brand-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.02em;
}

.sidebar-nav {
  list-style: none;
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-section {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 16px 8px 6px;
}

.nav-item { margin: 2px 0; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: .9rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}

.nav-link:hover { background: var(--bg-card); color: var(--text-primary); }

.nav-link.active {
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid var(--border-accent);
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 0;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.user-info {
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

.btn-logout {
  font-size: .8rem;
  color: var(--text-muted);
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: all var(--transition);
}

.btn-logout:hover { color: var(--red); border-color: var(--red); }

/* ── Main Content ───────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 32px;
  max-width: 1200px;
}

.main-content.no-sidebar { margin-left: 0; max-width: 100%; }

/* ── Flash Messages ─────────────────────────────────────────── */
.flash-container { margin-bottom: 20px; }

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: .9rem;
  border: 1px solid transparent;
}

.alert-success { background: rgba(34,197,94,.12);  border-color: rgba(34,197,94,.3);  color: #86efac; }
.alert-danger  { background: rgba(239,68,68,.12);  border-color: rgba(239,68,68,.3);  color: #fca5a5; }
.alert-warning { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.3); color: #fcd34d; }
.alert-info    { background: rgba(79,110,247,.12); border-color: rgba(79,110,247,.3); color: #a5b4fc; }

/* ── Auth Pages ─────────────────────────────────────────────── */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg-base);
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.auth-header { text-align: center; margin-bottom: 32px; }
.auth-icon   { font-size: 2.8rem; }
.auth-title  { font-size: 1.5rem; font-weight: 700; margin: 8px 0 4px; }
.auth-subtitle { color: var(--text-secondary); font-size: .9rem; }
.auth-footer-link { text-align: center; margin-top: 20px; font-size: .88rem; color: var(--text-secondary); }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input,
.form-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: inherit;
  font-size: .9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder { color: var(--text-muted); }

.form-error { display: block; font-size: .8rem; color: var(--red); margin-top: 4px; }

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .88rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.link-muted { font-size: .85rem; color: var(--text-muted); }
.link-muted:hover { color: var(--accent); }

/* ── Botões ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-dark);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--border-accent); }

.btn-danger {
  background: rgba(239,68,68,.15);
  color: var(--red);
  border-color: rgba(239,68,68,.3);
}
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-full { width: 100%; justify-content: center; }

.btn-sm { padding: 5px 12px; font-size: .8rem; }

/* Legend toggle buttons */
.btn-legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: .82rem;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-legend.active { color: var(--text-primary); border-color: var(--border-accent); }
.btn-legend:hover  { border-color: var(--accent); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ── Page Header ────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.page-header h1 { font-size: 1.6rem; font-weight: 700; }

.page-subtitle { color: var(--text-secondary); font-size: .9rem; }

/* ── Cards Grid ─────────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all var(--transition);
}

.card-link {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text-primary);
  cursor: pointer;
}
.card-link:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  color: var(--text-primary);
}

.card-placeholder { opacity: .45; }

.card-icon { font-size: 2rem; flex-shrink: 0; }
.card-body { flex: 1; }
.card-title { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.card-desc  { font-size: .82rem; color: var(--text-secondary); }
.card-arrow { font-size: 1.2rem; color: var(--text-muted); }

/* Stat cards */
.stat-card { text-align: center; }
.stat-icon  { font-size: 1.8rem; margin-bottom: 8px; }
.stat-value { font-size: 2.2rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: .85rem; color: var(--text-secondary); margin-top: 4px; }

/* ── Chart Controls ─────────────────────────────────────────── */
.chart-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-group label {
  font-size: .85rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.legend-toggles { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Chart Wrapper ──────────────────────────────────────────── */
.chart-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  height: 420px;
  position: relative;
  margin-bottom: 32px;
}

.chart-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: .9rem;
}

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-msg { color: var(--red); }

/* ── Tables ─────────────────────────────────────────────────── */
.data-table-section { margin-top: 8px; }
.section-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 16px; }

.table-wrapper { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}

.data-table thead tr {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: .8rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr:hover { background: var(--bg-card); }

.table-loading, .table-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 24px !important;
}

/* Valor colorido */
.val-high  { color: var(--green);  font-weight: 600; }
.val-mid   { color: var(--amber);  font-weight: 600; }
.val-low   { color: var(--red);    font-weight: 600; }

/* Action cell */
.action-cell { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-admin    { background: rgba(79,110,247,.2);  color: #818cf8; border: 1px solid rgba(79,110,247,.3); }
.badge-user     { background: rgba(148,163,184,.1); color: var(--text-muted); }
.badge-active   { background: rgba(34,197,94,.15);  color: var(--green); }
.badge-inactive { background: rgba(239,68,68,.12);  color: var(--red); }

/* ── Admin Links ─────────────────────────────────────────────── */
.admin-links { display: flex; gap: 12px; flex-wrap: wrap; }

/* ── Elementos Mobile (Ocultos no Desktop por padrão) ──────── */
.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 99;
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.menu-toggle {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: background var(--transition);
}
.menu-toggle:hover { background: var(--bg-card); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 101;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .mobile-header { display: flex; }
  .sidebar-overlay { display: block; }

  /* Transformar sidebar em gaveta (drawer) */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    height: 100vh;
    z-index: 102;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
  }
  
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.5);
  }

  /* Ajuste no layout principal do conteúdo */
  .main-content {
    margin-left: 0;
    padding: 20px;
    padding-top: 80px; /* Dá espaço para a barra fixa no topo */
  }

  /* Sem espaçamento extra de topo no login/cadastro */
  .main-content.no-sidebar {
    padding-top: 20px;
  }

  /* Bloqueia scroll do fundo com menu aberto */
  body.menu-open {
    overflow: hidden;
  }

  /* Redimensionamento e controles do gráfico */
  .chart-wrapper {
    height: 300px;
    padding: 12px;
  }

  .chart-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .control-group {
    width: 100%;
    justify-content: space-between;
  }

  .control-group select {
    width: auto;
  }

  .legend-toggles {
    justify-content: flex-start;
  }

  /* Cards da Home em coluna única */
  .cards-grid {
    grid-template-columns: 1fr;
  }

  /* Otimização de formulário de login no mobile */
  .auth-card {
    padding: 30px 20px;
  }
}

