/* ============================================================
   BI SWSistema — app.css
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:       #6c3fc5;
  --brand-dark:  #4e2d99;
  --brand-light: #ede8fa;
  --success:     #22c55e;
  --warning:     #f59e0b;
  --danger:      #ef4444;
  --info:        #3b82f6;
  --gray-50:     #f9fafb;
  --gray-100:    #f3f4f6;
  --gray-200:    #e5e7eb;
  --gray-300:    #d1d5db;
  --gray-400:    #9ca3af;
  --gray-600:    #4b5563;
  --gray-700:    #374151;
  --gray-900:    #111827;
  --sidebar-w:   240px;
  --radius:      8px;
  --shadow:      0 1px 3px rgba(0,0,0,.1), 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,.06);
  --shadow-lg:   0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  color: var(--gray-700);
  background: var(--gray-50);
  display: flex;
  min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--gray-900);
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  border-bottom: 1px solid #374151;
}
.sidebar-brand svg { width: 22px; height: 22px; color: var(--brand); }

.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }

.nav-section {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--gray-400);
  padding: 16px 8px 6px;
}

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: #9ca3af;
  text-decoration: none;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link:hover  { background: #1f2937; color: #fff; }
.nav-link.active { background: var(--brand); color: #fff; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid #374151;
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--gray-400); text-transform: capitalize; }
.btn-logout {
  color: var(--gray-400); text-decoration: none;
  display: flex; align-items: center; padding: 4px;
  border-radius: 6px; transition: color .15s;
}
.btn-logout svg { width: 18px; height: 18px; }
.btn-logout:hover { color: var(--danger); }

/* ---- MAIN ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  height: 56px;
  display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow);
}
.btn-toggle-sidebar {
  display: none;
  background: none; border: none; cursor: pointer; padding: 4px;
  color: var(--gray-600);
}
.btn-toggle-sidebar svg { width: 22px; height: 22px; }
.page-title { font-size: 17px; font-weight: 600; color: var(--gray-900); }

.page-body { padding: 24px; flex: 1; }

/* ---- CARDS ---- */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.card-title { font-weight: 600; font-size: 15px; color: var(--gray-900); }
.card-body { padding: 20px; }

/* ---- FILTROS ---- */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  padding: 16px 20px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  border-radius: var(--radius) var(--radius) 0 0;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 11px; font-weight: 600; color: var(--gray-600); text-transform: uppercase; letter-spacing: .05em; }

input[type="text"], input[type="date"], input[type="email"], input[type="password"],
select, textarea {
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--gray-900);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(108,63,197,.12);
}
.input-search { min-width: 240px; }

/* ---- BOTÕES ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 13px; font-weight: 500; font-family: inherit;
  border: 1px solid transparent;
  cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.btn-primary   { background: var(--brand);   color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border-color: var(--gray-300); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-success   { background: var(--success); color: #fff; }
.btn-danger    { background: var(--danger);  color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px; }

/* ---- TABELA ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--gray-600);
  white-space: nowrap;
}
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--brand-light); }

/* ---- BADGES ---- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef9c3; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-gray    { background: var(--gray-100); color: var(--gray-600); }

/* ---- PAGINAÇÃO ---- */
.pagination {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 14px 20px;
  border-top: 1px solid var(--gray-200);
  font-size: 13px;
}
.pagination-info { color: var(--gray-600); margin-right: auto; }
.page-btn {
  min-width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; border: 1px solid var(--gray-300);
  background: #fff; color: var(--gray-700);
  cursor: pointer; font-size: 13px; font-weight: 500;
  text-decoration: none; transition: background .15s;
}
.page-btn:hover    { background: var(--brand-light); border-color: var(--brand); color: var(--brand); }
.page-btn.current  { background: var(--brand); color: #fff; border-color: var(--brand); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---- MODAL ---- */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
}
.modal {
  display: none;
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 201;
  background: #fff;
  border-radius: 12px;
  width: min(900px, 95vw);
  max-height: 88vh;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
}
.modal.open, .modal-overlay.open { display: flex; }
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h2 { font-size: 17px; font-weight: 600; }
.modal-close {
  background: none; border: none; font-size: 18px; cursor: pointer;
  color: var(--gray-400); padding: 4px 8px; border-radius: 6px;
  transition: background .15s; line-height: 1;
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-700); }
.modal-body { padding: 24px; overflow-y: auto; }

/* ---- DETALHE (seções dentro do modal) ---- */
.detail-sections { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 640px) { .detail-sections { grid-template-columns: 1fr; } }

.detail-section {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
}
.detail-section h3 {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--brand);
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 6px;
}
.detail-row { display: flex; flex-direction: column; margin-bottom: 8px; }
.detail-label { font-size: 10px; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: .05em; }
.detail-value { font-size: 13px; color: var(--gray-900); font-weight: 500; }
.detail-value.empty { color: var(--gray-400); font-style: italic; font-weight: 400; }

/* ---- FORMULÁRIOS ---- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 580px) { .form-grid { grid-template-columns: 1fr; } }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--gray-700); }
.form-group input, .form-group select { width: 100%; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* ---- ALERTAS ---- */
.alert {
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px;
  font-size: 13px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
}
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }

/* ---- LOGIN ---- */
.login-page {
  min-height: 100vh; width: 100%;
  display: flex; align-items: center; justify-content: center;
  background: var(--gray-900);
}
.login-box {
  background: #fff; border-radius: 12px;
  padding: 40px; width: 380px; max-width: 95vw;
  box-shadow: var(--shadow-lg);
}
.login-brand {
  display: flex; align-items: center; gap: 10px;
  justify-content: center; margin-bottom: 28px;
}
.login-brand svg { width: 28px; height: 28px; color: var(--brand); }
.login-brand span { font-size: 20px; font-weight: 700; color: var(--gray-900); }
.login-box h2 { font-size: 22px; font-weight: 700; margin-bottom: 6px; color: var(--gray-900); }
.login-box p  { color: var(--gray-400); font-size: 13px; margin-bottom: 24px; }
.login-box .form-group { margin-bottom: 16px; }
.login-box input { width: 100%; padding: 10px 12px; }
.btn-login { width: 100%; justify-content: center; padding: 11px; font-size: 14px; }

/* ---- LOADING ---- */
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 40px; color: var(--gray-400); font-size: 14px;
}

/* ---- EMPTY STATE ---- */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 60px 20px; color: var(--gray-400); text-align: center;
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: 14px; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .btn-toggle-sidebar { display: flex; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .input-search { min-width: auto; }
}
