/* SindConnect — design system próprio (sem framework externo, respeita CSP). */

:root {
  --color-bg: #f6f7f6;
  --color-surface: #ffffff;
  --color-surface-raised: #ffffff;
  --color-border: #e2e4e1;
  --color-border-strong: #c9ccc8;
  --color-text: #16201c;
  --color-text-muted: #5b6560;
  --color-text-faint: #8b948e;

  --color-accent: #0d7d6f;
  --color-accent-hover: #0a6459;
  --color-accent-soft: #e2f3f0;
  --color-accent-contrast: #ffffff;

  --color-danger: #b3261e;
  --color-danger-soft: #fbe9e7;
  --color-warning: #8a5a00;
  --color-warning-soft: #fdf0da;
  --color-success: #276b38;
  --color-success-soft: #e6f4e8;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(20, 30, 25, 0.06);
  --shadow-md: 0 6px 20px -8px rgba(20, 30, 25, 0.18);

  --sidebar-width: 248px;
  --topbar-height: 60px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #121512;
    --color-surface: #191d19;
    --color-surface-raised: #1f231f;
    --color-border: #2c322c;
    --color-border-strong: #3c443c;
    --color-text: #eaf0ec;
    --color-text-muted: #a9b3ad;
    --color-text-faint: #767f79;

    --color-accent: #35b3a0;
    --color-accent-hover: #4bc5b2;
    --color-accent-soft: #163530;
    --color-accent-contrast: #05221d;

    --color-danger: #ff6b60;
    --color-danger-soft: #3a1917;
    --color-warning: #e0ab4c;
    --color-warning-soft: #362a10;
    --color-success: #6ad684;
    --color-success-soft: #17321d;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  --color-bg: #121512;
  --color-surface: #191d19;
  --color-surface-raised: #1f231f;
  --color-border: #2c322c;
  --color-border-strong: #3c443c;
  --color-text: #eaf0ec;
  --color-text-muted: #a9b3ad;
  --color-text-faint: #767f79;

  --color-accent: #35b3a0;
  --color-accent-hover: #4bc5b2;
  --color-accent-soft: #163530;
  --color-accent-contrast: #05221d;

  --color-danger: #ff6b60;
  --color-danger-soft: #3a1917;
  --color-warning: #e0ab4c;
  --color-warning-soft: #362a10;
  --color-success: #6ad684;
  --color-success-soft: #17321d;
}

* { box-sizing: border-box; }
html { color-scheme: light dark; }
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }
a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* --- Layout autenticado: topbar + sidebar --- */
.app-shell { min-height: 100vh; display: flex; }

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: 20px 14px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  transition: transform 0.2s ease;
  z-index: 40;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 20px;
  font-weight: 700; font-size: 1.05rem;
}
.sidebar-brand img { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; }
.sidebar-brand .brand-mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--color-accent); color: var(--color-accent-contrast);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .85rem;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--color-text-muted); font-weight: 500; font-size: .92rem;
}
.sidebar-nav a:hover { background: var(--color-accent-soft); color: var(--color-text); text-decoration: none; }
.sidebar-nav a.active { background: var(--color-accent-soft); color: var(--color-accent); }
.sidebar-section-title {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--color-text-faint); margin: 18px 12px 6px; font-weight: 700;
}

.content-area { flex: 1; margin-left: var(--sidebar-width); min-width: 0; }
.topbar {
  height: var(--topbar-height);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; border-bottom: 1px solid var(--color-border);
  background: var(--color-surface); position: sticky; top: 0; z-index: 30;
}
.topbar-menu-btn { display: none; }
.topbar-user { display: flex; align-items: center; gap: 12px; font-size: .9rem; }
.topbar-user .role-badge { font-size: .72rem; }

.page { padding: 28px; max-width: 1100px; }
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 22px;
}
.page-header p { color: var(--color-text-muted); margin: 4px 0 0; }

/* --- Auth shell (login, mfa, recuperação) --- */
.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background:
    radial-gradient(1200px 500px at 50% -10%, var(--color-accent-soft), transparent 60%),
    var(--color-bg);
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  padding: 32px 28px;
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-brand .brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--color-accent); color: var(--color-accent-contrast);
  display: flex; align-items: center; justify-content: center; font-weight: 800;
}
.auth-brand span { font-weight: 700; font-size: 1.05rem; }
.auth-card h1 { font-size: 1.3rem; margin-bottom: 4px; }
.auth-card .subtitle { color: var(--color-text-muted); font-size: .9rem; margin-bottom: 22px; }
.auth-footer-links { margin-top: 18px; font-size: .87rem; display: flex; flex-direction: column; gap: 6px; }

/* --- Forms --- */
form .field { margin-bottom: 16px; }
label { display: block; font-weight: 600; font-size: .86rem; margin-bottom: 6px; }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"],
input[type="number"], input[type="date"], input[type="search"], textarea, select {
  width: 100%; padding: 10px 12px; font-size: .95rem; font-family: inherit;
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm);
  background: var(--color-surface); color: var(--color-text);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}
input[type="file"] { font-size: .88rem; }
.help-text { font-size: .8rem; color: var(--color-text-faint); margin-top: 4px; }
.field-errors { color: var(--color-danger); font-size: .83rem; margin-top: 4px; }
.non-field-errors {
  background: var(--color-danger-soft); color: var(--color-danger);
  border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 16px; font-size: .88rem;
}
.checkbox-field { display: flex; align-items: center; gap: 8px; }
.checkbox-field input { width: auto; }

/* --- Botões --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm); font-size: .92rem; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; transition: background .15s, border-color .15s, transform .05s;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--color-accent); color: var(--color-accent-contrast); }
.btn-primary:hover { background: var(--color-accent-hover); text-decoration: none; }
.btn-block { width: 100%; }
.btn-secondary { background: transparent; border-color: var(--color-border-strong); color: var(--color-text); }
.btn-secondary:hover { background: var(--color-accent-soft); text-decoration: none; border-color: var(--color-accent); }
.btn-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.btn-danger:hover { background: var(--color-danger); color: #fff; text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: .82rem; }

/* --- Cards / superfícies --- */
.card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); padding: 20px; box-shadow: var(--shadow-sm);
}

/* --- Mensagens / alertas --- */
.messages { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: .88rem; border: 1px solid transparent; }
.alert-success { background: var(--color-success-soft); color: var(--color-success); }
.alert-error { background: var(--color-danger-soft); color: var(--color-danger); }
.alert-info, .alert-warning { background: var(--color-warning-soft); color: var(--color-warning); }

/* --- Badges --- */
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  font-size: .74rem; font-weight: 700; letter-spacing: .01em;
}
.badge-neutral { background: var(--color-border); color: var(--color-text-muted); }
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.badge-accent { background: var(--color-accent-soft); color: var(--color-accent); }

/* --- Tabelas --- */
.table-wrap { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius-md); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 480px; }
thead th {
  text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--color-text-faint); padding: 12px 16px; background: var(--color-surface-raised);
  border-bottom: 1px solid var(--color-border);
}
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--color-accent-soft); }
.table-actions { display: flex; gap: 6px; justify-content: flex-end; }

.empty-state {
  text-align: center; padding: 60px 20px; color: var(--color-text-muted);
}
.empty-state h3 { color: var(--color-text); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

/* --- QR / MFA --- */
.qr-box { display: flex; justify-content: center; padding: 18px; background: #fff; border-radius: var(--radius-md); margin-bottom: 18px; }
.qr-box img { width: 200px; height: 200px; }
.backup-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-family: ui-monospace, monospace; font-size: .95rem; margin: 18px 0; }
.backup-codes code { background: var(--color-accent-soft); padding: 8px 10px; border-radius: var(--radius-sm); text-align: center; }

/* --- Responsivo --- */
@media (max-width: 880px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
  .content-area { margin-left: 0; }
  .topbar-menu-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--color-border-strong);
    background: transparent; cursor: pointer; color: var(--color-text);
  }
  .page { padding: 18px; }
  .backup-codes { grid-template-columns: 1fr; }
  .sidebar-backdrop.open { display: block; }
}
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(10, 14, 11, .45); z-index: 35;
}
