/* ============================================================
   XML MultiTenant — app.css
   Design: Industrial Minimal — slate + amber accent
   ============================================================ */

:root {
  --sidebar-w: 260px;
  --topbar-h: 64px;

  --bg:        #0f1117;
  --bg-2:      #181c26;
  --bg-3:      #1f2435;
  --border:    #2a3045;
  --border-2:  #3a4260;

  --text:      #e8eaf0;
  --text-muted:#7a85a0;
  --text-dim:  #4a5570;

  --accent:    #f59e0b;
  --accent-dk: #d97706;
  --accent-lt: #fcd34d;

  --success:   #10b981;
  --danger:    #ef4444;
  --warning:   #f59e0b;
  --info:      #3b82f6;

  --radius:    8px;
  --radius-lg: 14px;
  --shadow:    0 4px 24px rgba(0,0,0,.45);
}

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

html, body {
  height: 100%;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform .25s ease;
  overflow-y: auto;
}

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

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .02em;
}

.logo-icon {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #000;
  font-size: 14px;
}

.logo-text { color: var(--text); }

.sidebar-toggle {
  background: none; border: none;
  color: var(--text-muted);
  font-size: 16px; cursor: pointer;
}

/* User block */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.user-avatar {
  width: 38px; height: 38px;
  background: var(--accent);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
  color: #000;
  flex-shrink: 0;
}

.user-info { min-width: 0; }
.user-name  { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-badge { font-size: 10px; color: var(--accent); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.user-unit  { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Nav */
.sidebar-nav {
  list-style: none;
  padding: 12px 0;
  flex: 1;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .15s;
}

.sidebar-nav li a i { width: 16px; text-align: center; font-size: 13px; }

.sidebar-nav li a:hover {
  color: var(--text);
  background: var(--bg-3);
}

.sidebar-nav li.active a {
  color: var(--accent);
  background: rgba(245,158,11,.08);
  border-left-color: var(--accent);
}

.nav-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-dim);
  padding: 14px 20px 6px;
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.sidebar-cnpj {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  z-index: 900;
}

.topbar-toggle {
  background: none; border: none;
  color: var(--text-muted); font-size: 18px; cursor: pointer;
}

.topbar-title h1 {
  font-size: 18px;
  font-weight: 600;
  flex: 1;
  margin: 0;
}

.topbar-actions { margin-left: auto; }

.topbar-tenant {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-3);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 20px;
}

.page-content {
  padding: 28px;
  flex: 1;
}

/* ============================================================
   CARDS & PANELS
   ============================================================ */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: none;
}

.card-header {
  background: var(--bg-3);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.card-body { padding: 20px; }

/* Stats */
.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  transition: border-color .2s;
}

.stat-card:hover { border-color: var(--accent); }

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

.stat-icon.amber  { background: rgba(245,158,11,.15); color: var(--accent); }
.stat-icon.green  { background: rgba(16,185,129,.15); color: var(--success); }
.stat-icon.blue   { background: rgba(59,130,246,.15); color: var(--info); }
.stat-icon.red    { background: rgba(239,68,68,.15);  color: var(--danger); }

.stat-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  font-family: 'DM Mono', monospace;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ============================================================
   TABLE
   ============================================================ */
.table-dark-custom {
  color: var(--text);
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}

.table-dark-custom thead th {
  background: var(--bg-3);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table-dark-custom tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 13.5px;
}

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

.table-dark-custom tbody tr:hover td { background: var(--bg-3); }

.cnpj-badge {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--text-muted);
}

/* ============================================================
   FORMS
   ============================================================ */
.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}

.form-control, .form-select {
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 9px 14px;
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  transition: border-color .2s, box-shadow .2s;
}

.form-control:focus, .form-select:focus {
  background: var(--bg-3);
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 0 0 3px rgba(245,158,11,.18);
  outline: none;
}

.form-control::placeholder { color: var(--text-dim); }

.form-select option { background: var(--bg-3); }

.form-control.is-invalid, .form-select.is-invalid {
  border-color: var(--danger);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 13px;
  border-radius: var(--radius);
  padding: 8px 18px;
  transition: all .2s;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.btn-primary {
  background: var(--accent);
  color: #000;
}
.btn-primary:hover { background: var(--accent-dk); color: #000; }

.btn-outline-secondary {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--text-muted);
}
.btn-outline-secondary:hover { border-color: var(--text-muted); color: var(--text); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-icon { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; }

/* ============================================================
   BADGES
   ============================================================ */
.badge-status {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .07em;
}
.badge-status.ativo   { background: rgba(16,185,129,.15); color: var(--success); }
.badge-status.inativo { background: rgba(239,68,68,.15);  color: var(--danger); }

.badge-perfil {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.badge-perfil.admin    { background: rgba(245,158,11,.18); color: var(--accent); }
.badge-perfil.gerente  { background: rgba(59,130,246,.15); color: var(--info); }
.badge-perfil.operador { background: rgba(124,58,237,.15); color: #a78bfa; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  border: none;
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert-success { background: rgba(16,185,129,.12); color: #6ee7b7; }
.alert-danger   { background: rgba(239,68,68,.12);  color: #fca5a5; }
.alert-warning  { background: rgba(245,158,11,.12); color: var(--accent-lt); }
.alert-info     { background: rgba(59,130,246,.12); color: #93c5fd; }
.btn-close { filter: invert(1) brightness(.6); }

/* ============================================================
   BREADCRUMB / PAGE HEADER
   ============================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header-left h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

.page-header-left p {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 2px 0 0;
}

/* ============================================================
   AUTH PAGES
   ============================================================ */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 20% 20%, rgba(245,158,11,.07) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(59,130,246,.05) 0%, transparent 50%);
}

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

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.auth-logo-icon {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #000;
  font-size: 18px;
}

.auth-logo-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.auth-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.filter-bar .form-group { flex: 1; min-width: 180px; }
.filter-bar .form-group label { font-size: 11px; font-weight: 600; color: var(--text-muted); display: block; margin-bottom: 5px; text-transform: uppercase; letter-spacing: .06em; }

/* ============================================================
   SIDEBAR OVERLAY (mobile)
   ============================================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 999;
}
.sidebar-overlay.show { display: block; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-content { padding: 16px; }
  .topbar { padding: 0 16px; }
}
