/* ============================================================
   IRIS COBRANÇA — Global Design System
   ============================================================ */

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

/* ── Tokens ─────────────────────────────────────────────────── */
:root {
  --bg:          #0B0F1A;
  --surface:     #111827;
  --surface-2:   #1a2235;
  --surface-3:   #212d42;
  --border:      rgba(255,255,255,.07);
  --brand:       #534AB7;
  --brand-light: #6c63d4;
  --brand-dim:   rgba(83,74,183,.18);
  --success:     #5DCAA5;
  --success-dim: rgba(93,202,165,.15);
  --warn:        #EF9F27;
  --warn-dim:    rgba(239,159,39,.15);
  --danger:      #F09595;
  --danger-dim:  rgba(240,149,149,.15);
  --text:        #ffffff;
  --text-2:      #a0aec0;
  --text-3:      #637083;
  --radius:      12px;
  --radius-sm:   8px;
  --sidebar-w:   240px;
  --topbar-h:    64px;
  --transition:  .18s ease;
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }
ul { list-style: none; }

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; }

/* ═══════════════════════════════════════════════════════════════
   LAYOUT — sidebar + main
   ═══════════════════════════════════════════════════════════════ */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
}

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

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

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

.sidebar-logo .logo-text span {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-3);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 10px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  position: relative;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.active {
  background: var(--brand-dim);
  color: var(--brand-light);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  height: 60%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--brand);
}

.nav-item .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke-width: 1.7;
}

.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  background: var(--brand-dim);
  color: var(--brand-light);
  border-radius: 99px;
  padding: 1px 7px;
}

.sidebar-footer {
  padding: 12px 10px 16px;
  border-top: 1px solid var(--border);
}

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
  grid-area: topbar;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 99px;
  background: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Main content ────────────────────────────────────────────── */
.main {
  grid-area: main;
  padding: 28px 28px 48px;
  overflow-y: auto;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
}

.page-header .sub {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 2px;
}

.page-header .actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

/* ═══════════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Metric cards ────────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.metric-card .m-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.metric-card .m-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.metric-card .m-sub {
  font-size: 12px;
  color: var(--text-3);
}

.metric-card .m-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.m-icon.brand  { background: var(--brand-dim); color: var(--brand-light); }
.m-icon.success { background: var(--success-dim); color: var(--success); }
.m-icon.warn   { background: var(--warn-dim); color: var(--warn); }
.m-icon.danger { background: var(--danger-dim); color: var(--danger); }

/* ═══════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  transition: opacity var(--transition), background var(--transition), box-shadow var(--transition);
  cursor: pointer;
  white-space: nowrap;
}

.btn:disabled { opacity: .45; pointer-events: none; }

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

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

.btn-success {
  background: var(--success);
  color: #0B0F1A;
}
.btn-success:hover { opacity: .88; }

.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(240,149,149,.25);
}
.btn-danger:hover { background: var(--danger); color: #0B0F1A; }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 7px; border-radius: var(--radius-sm); }

.btn .icon { width: 16px; height: 16px; stroke-width: 2; }

/* ═══════════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════════ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

.form-input,
.form-select,
.form-textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 12px;
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
  outline: none;
}

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

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-dim);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23637083' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.form-select option { background: var(--surface-2); }

.form-textarea { resize: vertical; min-height: 80px; }

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

.form-error {
  font-size: 12px;
  color: var(--danger);
}

.form-row {
  display: grid;
  gap: 14px;
}
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* Toggle switch */
.toggle-group {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--surface-3);
  border-radius: 99px;
  cursor: pointer;
  transition: background var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: transform var(--transition);
}

.toggle input:checked + .toggle-slider { background: var(--brand); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

.toggle-label {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
}

/* Range input */
.form-range {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 99px;
  background: var(--surface-3);
  outline: none;
}
.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--brand);
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════════
   TABLE
   ═══════════════════════════════════════════════════════════════ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  padding: 11px 14px;
  background: var(--surface-2);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-3);
  text-align: left;
  white-space: nowrap;
}

tbody tr {
  border-top: 1px solid var(--border);
  transition: background var(--transition);
}

tbody tr:hover { background: var(--surface-2); }

tbody td {
  padding: 12px 14px;
  font-size: 13.5px;
  color: var(--text);
  vertical-align: middle;
}

.td-muted { color: var(--text-2); }

/* ═══════════════════════════════════════════════════════════════
   BADGES / STATUS PILLS
   ═══════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-brand   { background: var(--brand-dim);   color: var(--brand-light); }
.badge-success { background: var(--success-dim);  color: var(--success); }
.badge-warn    { background: var(--warn-dim);     color: var(--warn); }
.badge-danger  { background: var(--danger-dim);   color: var(--danger); }
.badge-neutral { background: var(--surface-3);    color: var(--text-2); }

.badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* Dot pulse animation */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .5; transform: scale(.7); }
}
.badge .dot.pulse { animation: pulse-dot 1.6s ease-in-out infinite; }

/* ═══════════════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(16px) scale(.98);
  transition: transform var(--transition);
}

.modal-overlay.open .modal { transform: none; }

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

.modal-header h2 { font-size: 17px; font-weight: 700; flex: 1; }

.modal-body { padding: 24px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════════════
   TOAST / ALERT
   ═══════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  font-size: 13.5px;
  font-weight: 500;
  min-width: 260px;
  max-width: 380px;
  animation: toast-in .25s ease;
}

@keyframes toast-in {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.warn    { border-left: 3px solid var(--warn); }
.toast.info    { border-left: 3px solid var(--brand); }

.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 16px;
}

.alert-success { background: var(--success-dim); border: 1px solid rgba(93,202,165,.25); color: var(--success); }
.alert-error   { background: var(--danger-dim);  border: 1px solid rgba(240,149,149,.25); color: var(--danger); }
.alert-warn    { background: var(--warn-dim);    border: 1px solid rgba(239,159,39,.25); color: var(--warn); }
.alert-info    { background: var(--brand-dim);   border: 1px solid rgba(83,74,183,.3); color: var(--brand-light); }

/* ═══════════════════════════════════════════════════════════════
   SEARCH BAR
   ═══════════════════════════════════════════════════════════════ */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  transition: border-color var(--transition);
}

.search-bar:focus-within { border-color: var(--brand); }

.search-bar input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 13.5px;
  width: 220px;
}

.search-bar input::placeholder { color: var(--text-3); }

/* ═══════════════════════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}

.empty-state .empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  opacity: .35;
}

.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.empty-state p  { font-size: 13.5px; }

/* ═══════════════════════════════════════════════════════════════
   LOADER / SPINNER
   ═══════════════════════════════════════════════════════════════ */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,.15);
  border-top-color: var(--brand-light);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

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

.page-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 14px;
  color: var(--text-2);
  font-size: 14px;
}

.page-loader .spinner { width: 34px; height: 34px; }

/* ═══════════════════════════════════════════════════════════════
   LOGIN PAGE (standalone, no sidebar)
   ═══════════════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-bg-glow {
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(83,74,183,.18) 0%, transparent 70%);
  pointer-events: none;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  box-shadow: 0 24px 80px rgba(0,0,0,.45);
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 32px;
  gap: 10px;
}

.login-logo .logo-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: #fff;
  box-shadow: 0 8px 24px rgba(83,74,183,.4);
}

.login-logo h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.3px;
}

.login-logo p {
  font-size: 13px;
  color: var(--text-2);
  text-align: center;
}

.login-submit {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  margin-top: 8px;
}

.login-footer {
  margin-top: 22px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-3);
}

/* ═══════════════════════════════════════════════════════════════
   DIVIDER
   ═══════════════════════════════════════════════════════════════ */
.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* ═══════════════════════════════════════════════════════════════
   SECTION GRID (2-col content layout)
   ═══════════════════════════════════════════════════════════════ */
.content-grid {
  display: grid;
  gap: 20px;
}
.content-grid-2 { grid-template-columns: 1fr 1fr; }
.content-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.content-grid-aside { grid-template-columns: 1fr 360px; }

/* ═══════════════════════════════════════════════════════════════
   AVATAR STACK
   ═══════════════════════════════════════════════════════════════ */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   UTILITY
   ═══════════════════════════════════════════════════════════════ */
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warn    { color: var(--warn); }
.text-brand   { color: var(--brand-light); }
.text-muted   { color: var(--text-2); }
.text-dim     { color: var(--text-3); }

.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.mt-0  { margin-top: 0; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

.mb-0  { margin-bottom: 0; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }

.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas: "topbar" "main";
  }
  .content-grid-2, .content-grid-aside { grid-template-columns: 1fr; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
}
