/* =========================================================
   ONLINE-SE - Soluções Digitais
   Design system: tokens + componentes globais
   ========================================================= */

:root {
  /* Cor */
  --color-ink: #171412;
  --color-ink-soft: #2b2622;
  --color-surface: #FAF9F7;
  --color-surface-alt: #F1EEE9;
  --color-card: #FFFFFF;
  --color-border: #E8E4DE;
  --color-border-strong: #D9D3C9;

  --color-orange: #F2600C;
  --color-orange-dark: #C94A05;
  --color-orange-soft: #FDEAE0;

  --color-text: #21201E;
  --color-text-muted: #6B655D;
  --color-text-faint: #99928A;
  --color-white: #FFFFFF;

  --color-success: #157F3C;
  --color-success-soft: #E4F5EA;
  --color-danger: #C22525;
  --color-danger-soft: #FBE7E7;
  --color-warning: #B4700A;
  --color-warning-soft: #FBF0DD;

  /* Tipografia */
  --font-display: 'Sora', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', monospace;

  /* Layout */
  --sidebar-width: 264px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(23, 20, 18, .06);
  --shadow-md: 0 8px 24px rgba(23, 20, 18, .08);
  --transition-fast: 150ms ease;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font-body);
  background: var(--color-surface);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--color-ink);
  margin: 0;
}

p { margin: 0; }

a { color: inherit; text-decoration: none; }

button { font-family: inherit; cursor: pointer; }

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
}

/* Foco visível em todo elemento interativo */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--color-orange);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* =========================================================
   Botões
   ========================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.btn svg { width: 18px; height: 18px; }

.btn-primary {
  background: var(--color-orange);
  color: var(--color-white);
}

.btn-primary:hover { background: var(--color-orange-dark); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled {
  background: var(--color-text-faint);
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--color-white);
  color: var(--color-text);
  border-color: var(--color-border-strong);
}

.btn-secondary:hover { border-color: var(--color-orange); color: var(--color-orange-dark); }

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
}

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

.btn-block { width: 100%; }

.btn-loading .btn-label { opacity: .0; }
.btn-loading { position: relative; }
.btn-loading::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: var(--color-white);
  animation: spin .7s linear infinite;
}

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

/* =========================================================
   Formulários
   ========================================================= */

.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.input-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon-wrap svg:first-child {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--color-text-faint);
  pointer-events: none;
}

.input-icon-wrap .input-prefix {
  position: absolute;
  left: 14px;
  color: var(--color-text-faint);
  font-weight: 600;
  font-size: 14px;
  pointer-events: none;
}

.input-with-prefix {
  width: 100%;
  height: 46px;
  padding: 0 14px 0 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-strong);
  background: var(--color-white);
  color: var(--color-text);
  font-family: var(--font-mono);
  transition: border-color var(--transition-fast);
}

.input-with-prefix:focus {
  outline: none;
  border-color: var(--color-orange);
  box-shadow: 0 0 0 3px var(--color-orange-soft);
}

.input-icon-wrap input {
  width: 100%;
  height: 46px;
  padding: 0 14px 0 42px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-strong);
  background: var(--color-white);
  color: var(--color-text);
  transition: border-color var(--transition-fast);
}

.input-icon-wrap input:focus {
  outline: none;
  border-color: var(--color-orange);
  box-shadow: 0 0 0 3px var(--color-orange-soft);
}

.input-icon-btn {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  padding: 8px;
  border-radius: var(--radius-sm);
  color: var(--color-text-faint);
  display: flex;
}

.input-icon-btn:hover { color: var(--color-text-muted); }
.input-icon-btn svg { width: 18px; height: 18px; }

.form-error {
  background: var(--color-danger-soft);
  color: var(--color-danger);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

/* =========================================================
   Login
   ========================================================= */

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}

.login-panel-brand {
  background: var(--color-ink);
  color: var(--color-white);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 64px;
  position: relative;
  overflow: hidden;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 38px,
    rgba(242, 96, 12, .10) 39px
  );
}

.login-panel-brand::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 15% 15%, rgba(242, 96, 12, .18), transparent 45%);
}

.login-panel-brand > * { position: relative; z-index: 1; }

.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--color-orange), var(--color-orange-dark));
  color: var(--color-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-md);
}

.login-panel-brand h1 {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--color-white);
}

.login-panel-brand .tagline {
  color: var(--color-orange);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-top: 6px;
}

.login-panel-brand .brand-sub {
  margin-top: 28px;
  max-width: 360px;
  color: rgba(255,255,255,.65);
  font-size: 15px;
  line-height: 1.6;
}

.login-panel-form {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: var(--color-surface);
}

.login-card {
  width: 100%;
  max-width: 380px;
}

.login-card h2 {
  font-size: 26px;
  font-weight: 700;
}

.login-card .muted {
  color: var(--color-text-muted);
  font-size: 14px;
  margin-top: 6px;
  margin-bottom: 32px;
  display: block;
}

@media (max-width: 860px) {
  .login-page { grid-template-columns: 1fr; }
  .login-panel-brand { display: none; }
}

/* =========================================================
   App Shell (sidebar + topbar)
   ========================================================= */

.app-main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--color-ink);
  color: var(--color-white);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  z-index: 40;
  transition: transform var(--transition-fast);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
  margin-bottom: 32px;
}

.sidebar-brand .brand-mark {
  width: 38px;
  height: 38px;
  font-size: 14px;
  margin-bottom: 0;
  flex-shrink: 0;
}

.sidebar-brand .brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.sidebar-brand .brand-text strong {
  font-family: var(--font-display);
  font-size: 14.5px;
  letter-spacing: -0.01em;
}

.sidebar-brand .brand-text span {
  font-size: 11px;
  color: rgba(255,255,255,.5);
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: rgba(255,255,255,.68);
  font-size: 14px;
  font-weight: 500;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.nav-item:hover { background: rgba(255,255,255,.06); color: var(--color-white); }

.nav-item.active {
  background: var(--color-orange);
  color: var(--color-white);
  box-shadow: var(--shadow-sm);
}

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.1);
  padding-top: 12px;
  margin-top: 12px;
}

.nav-item-logout:hover { background: var(--color-danger-soft); color: var(--color-danger); }

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 32px;
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.page-title {
  font-size: 19px;
  font-weight: 700;
  flex: 1;
}

.menu-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--color-text);
  padding: 8px;
  border-radius: var(--radius-sm);
}

.menu-toggle svg { width: 22px; height: 22px; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-orange-soft);
  color: var(--color-orange-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.user-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.main-content {
  flex: 1;
  padding: 32px;
  max-width: 1240px;
  width: 100%;
}

@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .menu-toggle { display: flex; align-items: center; justify-content: center; }
  .user-name { display: none; }
}

/* =========================================================
   Cards, stats, badges, estado vazio
   ========================================================= */

.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

@media (max-width: 1100px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .stat-grid { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stat-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-orange-soft);
  color: var(--color-orange-dark);
}

.stat-card-icon svg { width: 18px; height: 18px; }

.stat-card.tone-danger .stat-card-icon { background: var(--color-danger-soft); color: var(--color-danger); }
.stat-card.tone-success .stat-card-icon { background: var(--color-success-soft); color: var(--color-success); }
.stat-card.tone-warning .stat-card-icon { background: var(--color-warning-soft); color: var(--color-warning); }

.stat-card-label {
  font-size: 13px;
  color: var(--color-text-muted);
  font-weight: 500;
}

.stat-card-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 500;
  color: var(--color-ink);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--color-surface-alt);
  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-warning { background: var(--color-warning-soft); color: var(--color-warning); }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px;
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: var(--color-card);
}

.empty-state-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: var(--color-orange-soft);
  color: var(--color-orange-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.empty-state-icon svg { width: 26px; height: 26px; }

.empty-state h2 { font-size: 18px; margin-bottom: 8px; }
.empty-state p { color: var(--color-text-muted); font-size: 14px; max-width: 340px; }

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-heading h3 { font-size: 15px; font-weight: 700; }
.section-heading span { font-size: 13px; color: var(--color-text-faint); }

/* =========================================================
   Toolbar, tabela, badges de status extra
   ========================================================= */

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.toolbar .search-wrap { flex: 1; min-width: 220px; max-width: 360px; }

.toolbar .search-wrap .input-icon-wrap input { height: 44px; }

.toolbar-spacer { flex: 1; }

.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  user-select: none;
}

.checkbox-inline input { width: 16px; height: 16px; accent-color: var(--color-orange); }

.table-wrapper {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.data-table thead th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-faint);
  font-weight: 700;
  padding: 14px 20px;
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border);
}

.data-table tbody td {
  padding: 14px 20px;
  font-size: 14px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--color-surface-alt); }

.data-table .cell-primary { font-weight: 600; color: var(--color-ink); }
.data-table .cell-muted { color: var(--color-text-muted); font-size: 13px; }

.data-table .cell-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-strong);
  background: var(--color-white);
  color: var(--color-text-muted);
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { border-color: var(--color-orange); color: var(--color-orange-dark); }
.icon-btn.icon-btn-danger:hover { border-color: var(--color-danger); color: var(--color-danger); background: var(--color-danger-soft); }

.table-empty-row td {
  padding: 56px 20px;
  text-align: center;
  color: var(--color-text-muted);
}

/* =========================================================
   Modal
   ========================================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(23, 20, 18, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.modal > form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

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

.modal-header h2 { font-size: 17px; }

.modal-close {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
}

.modal-close:hover { background: var(--color-surface-alt); color: var(--color-text); }
.modal-close svg { width: 20px; height: 20px; }

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

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

.form-section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-text-faint);
  font-weight: 700;
  margin: 24px 0 12px;
}

.form-section-title:first-child { margin-top: 0; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

.form-grid .form-group.span-2 { grid-column: 1 / -1; }

@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
}

.plain-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-strong);
  background: var(--color-white);
  color: var(--color-text);
}

.plain-input:focus {
  outline: none;
  border-color: var(--color-orange);
  box-shadow: 0 0 0 3px var(--color-orange-soft);
}

.field-hint { font-size: 12px; color: var(--color-text-faint); margin-top: 2px; }

.field-error {
  font-size: 12px;
  color: var(--color-danger);
  margin-top: 2px;
  font-weight: 500;
}

.plain-input.input-error {
  border-color: var(--color-danger);
}

.plain-input.input-error:focus {
  box-shadow: 0 0 0 3px var(--color-danger-soft);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}

.switch-row .switch-label { font-size: 14px; font-weight: 600; color: var(--color-text); }
.switch-row .switch-desc { font-size: 12.5px; color: var(--color-text-muted); margin-top: 2px; }

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

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

.switch-track {
  position: absolute;
  inset: 0;
  background: var(--color-border-strong);
  border-radius: 999px;
  transition: background var(--transition-fast);
  cursor: pointer;
}

.switch-track::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: var(--color-white);
  border-radius: 50%;
  transition: transform var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.switch input:checked + .switch-track { background: var(--color-orange); }
.switch input:checked + .switch-track::before { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--color-orange); outline-offset: 2px; }

fieldset { border: none; padding: 0; margin: 0; }
fieldset:disabled { opacity: .5; }

/* =========================================================
   Toast
   ========================================================= */

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

.toast {
  min-width: 240px;
  max-width: 340px;
  background: var(--color-ink);
  color: var(--color-white);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border-left: 4px solid var(--color-orange);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { border-left-color: var(--color-danger); }
