/* ============================================================
   KYRINO — CSS Principal
   Design: sidebar escura, conteúdo claro, paleta musical
   ============================================================ */

/* ── Variáveis ─────────────────────────────────────────────── */
:root {
  --sidebar-width:      240px;
  --sidebar-bg:         #1a1f2e;
  --sidebar-hover:      #252b3b;
  --sidebar-active:     #2e3650;
  --sidebar-text:       #a0aab8;
  --sidebar-text-light: #e2e8f0;
  --sidebar-accent:     #6c63ff;
  --sidebar-border:     rgba(255,255,255,0.07);

  --topbar-h:           60px;
  --topbar-bg:          #ffffff;
  --topbar-border:      #e8ecf0;

  --bg-page:            #f4f6fb;
  --bg-card:            #ffffff;
  --border-color:       #e2e8f0;

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

  --primary:            #6c63ff;
  --primary-dark:       #5a52d5;
  --primary-light:      #ede9ff;

  --success:            #10b981;
  --success-light:      #d1fae5;
  --danger:             #ef4444;
  --danger-light:       #fee2e2;
  --warning:            #f59e0b;
  --warning-light:      #fef3c7;
  --info:               #3b82f6;
  --info-light:         #dbeafe;

  --radius:             10px;
  --radius-sm:          6px;
  --radius-lg:          16px;
  --shadow:             0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:          0 4px 12px rgba(0,0,0,0.08);
  --transition:         all 0.2s ease;
}

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

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-page);
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ═══════════════════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════════════════ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.3s ease;
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--sidebar-border);
}

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

.brand-text {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.sidebar-toggle-btn {
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
}

/* Usuário */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
}

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

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--sidebar-text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 155px;
}

.user-role {
  font-size: 11px;
  color: var(--sidebar-text);
  text-transform: capitalize;
}

/* Divisor */
.sidebar-divider {
  height: 1px;
  background: var(--sidebar-border);
  margin: 4px 16px 8px;
}

/* Navegação */
.sidebar-nav {
  list-style: none;
  padding: 0 8px;
  margin: 0;
  flex: 1;
}

.nav-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--sidebar-text);
  padding: 12px 8px 4px;
  opacity: 0.6;
}

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

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  transition: var(--transition);
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-light);
}

.nav-link.active {
  background: var(--sidebar-active);
  color: #fff;
}

.nav-link.active i { color: var(--primary); }

.nav-link i {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

/* Footer da sidebar */
.sidebar-footer {
  padding: 8px 8px 16px;
  border-top: 1px solid var(--sidebar-border);
  margin-top: auto;
}

.nav-link-logout:hover {
  background: rgba(239, 68, 68, 0.15) !important;
  color: #fc8181 !important;
}

/* ═══════════════════════════════════════════════════════════
   WRAPPER + TOPBAR
═══════════════════════════════════════════════════════════ */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s ease;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 900;
  height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: 0 1px 0 var(--topbar-border);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-menu-btn {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  display: none;
}

.topbar-date {
  font-size: 13px;
  color: var(--text-muted);
}

/* Breadcrumb */
.breadcrumb {
  font-size: 13px;
  margin: 0;
}
.breadcrumb-item a { color: var(--text-secondary); }
.breadcrumb-item.active { color: var(--text-primary); font-weight: 500; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════
   PAGE CONTENT + FOOTER
═══════════════════════════════════════════════════════════ */
.page-content {
  flex: 1;
  padding: 28px 28px 0;
}

.page-footer {
  padding: 16px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  margin-top: 32px;
}

/* ═══════════════════════════════════════════════════════════
   COMPONENTES DE PÁGINA
═══════════════════════════════════════════════════════════ */

/* Cabeçalho de página */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.3;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 4px 0 0;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.card-body { padding: 20px; }

/* Stat cards */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.purple  { background: var(--primary-light);  color: var(--primary); }
.stat-icon.green   { background: var(--success-light);  color: var(--success); }
.stat-icon.red     { background: var(--danger-light);   color: var(--danger); }
.stat-icon.yellow  { background: var(--warning-light);  color: var(--warning); }
.stat-icon.blue    { background: var(--info-light);     color: var(--info); }

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════════
   TABELAS
═══════════════════════════════════════════════════════════ */
.table {
  font-size: 13.5px;
  color: var(--text-primary);
}

.table th {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border-color) !important;
  padding: 10px 14px;
  white-space: nowrap;
}

.table td {
  padding: 12px 14px;
  vertical-align: middle;
  border-color: var(--border-color);
}

.table tbody tr:hover { background: #f8fafc; }
.table-responsive { border-radius: var(--radius); overflow: hidden; }

/* ═══════════════════════════════════════════════════════════
   BADGES / STATUS
═══════════════════════════════════════════════════════════ */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 50px;
  font-size: 12px;
  font-weight: 600;
}

.badge-status::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-ativo    { background: var(--success-light); color: #059669; }
.badge-inativo  { background: #f1f5f9; color: #64748b; }
.badge-trancado { background: var(--warning-light); color: #d97706; }
.badge-pago     { background: var(--success-light); color: #059669; }
.badge-pendente { background: var(--warning-light); color: #d97706; }
.badge-atrasado { background: var(--danger-light);  color: #dc2626; }
.badge-cancelado{ background: #f1f5f9; color: #94a3b8; }
.badge-concluido{ background: var(--info-light);    color: #2563eb; }
.badge-emitido  { background: var(--success-light); color: #059669; }

/* ═══════════════════════════════════════════════════════════
   FORMULÁRIOS
═══════════════════════════════════════════════════════════ */
.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 5px;
}

.form-control, .form-select {
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  padding: 8px 12px;
  transition: var(--transition);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.12);
  outline: none;
}

.form-control.is-invalid { border-color: var(--danger); }
.invalid-feedback { font-size: 12px; }

.form-text { font-size: 12px; color: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════
   BOTÕES
═══════════════════════════════════════════════════════════ */
.btn {
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
}

.btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline-primary:hover {
  background: var(--primary);
  color: #fff;
}

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

.btn-icon {
  width: 32px; height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

/* ═══════════════════════════════════════════════════════════
   PAGINAÇÃO
═══════════════════════════════════════════════════════════ */
.pagination { gap: 3px; }

.page-link {
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 13px;
  padding: 6px 11px;
}

.page-link:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

/* ═══════════════════════════════════════════════════════════
   BUSCA / FILTROS
═══════════════════════════════════════════════════════════ */
.search-bar {
  position: relative;
}

.search-bar .bi-search {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 15px;
}

.search-bar input {
  padding-left: 38px;
}

/* ═══════════════════════════════════════════════════════════
   FREQUÊNCIA / BARRA DE PROGRESSO
═══════════════════════════════════════════════════════════ */
.freq-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--border-color);
  overflow: hidden;
  min-width: 80px;
}

.freq-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--success);
  transition: width 0.4s ease;
}

.freq-bar-fill.low    { background: var(--danger); }
.freq-bar-fill.medium { background: var(--warning); }

/* ═══════════════════════════════════════════════════════════
   ALERTS
═══════════════════════════════════════════════════════════ */
.alert {
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  padding: 12px 16px;
}

/* ═══════════════════════════════════════════════════════════
   PÁGINA DE LOGIN
═══════════════════════════════════════════════════════════ */
.login-body {
  background: linear-gradient(135deg, #1a1f2e 0%, #252b3b 60%, #2e3650 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 40px 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 28px;
}

.login-brand-icon {
  width: 60px; height: 60px;
  background: var(--primary);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  margin-bottom: 12px;
}

.login-brand-name {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.login-brand-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ═══════════════════════════════════════════════════════════
   VAZIO / EMPTY STATE
═══════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}

.empty-state i {
  font-size: 48px;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: block;
}

.empty-state h5 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.empty-state p { font-size: 13.5px; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVO — MOBILE
═══════════════════════════════════════════════════════════ */
@media (max-width: 991px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
  }
  .main-wrapper {
    margin-left: 0;
  }
  .topbar-menu-btn {
    display: flex;
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
  }
  .sidebar-overlay.show { display: block; }
  .page-content { padding: 20px 16px 0; }
}

@media (max-width: 576px) {
  .login-card { padding: 28px 20px 24px; }
  .page-title { font-size: 18px; }
}

/* ═══════════════════════════════════════════════════════════
   UTILITÁRIOS EXTRAS
═══════════════════════════════════════════════════════════ */
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fw-600 { font-weight: 600; }
.fs-13  { font-size: 13px; }
.fs-12  { font-size: 12px; }
.gap-2  { gap: 8px; }

.cursor-pointer { cursor: pointer; }

/* Ajuste cor padrão Bootstrap para a nossa paleta */
.text-primary { color: var(--primary) !important; }
.bg-primary   { background: var(--primary) !important; }
.btn-primary  { background: var(--primary); border-color: var(--primary); }
