/* ═══════════════════════════════════════════════════════════════
   SUAS INTELIGENTE — App CSS
   Design institucional: azul-índigo sóbrio, tipografia Plus Jakarta Sans
   ═══════════════════════════════════════════════════════════════ */

/* ─── Variables ─────────────────────────────────────────────── */
:root {
  --brand:        #1e40af;
  --brand-dark:   #1e3a8a;
  --brand-light:  #dbeafe;
  --brand-glow:   rgba(30,64,175,.15);
  --accent:       #3b82f6;
  --sidebar-bg:   #0f172a;
  --sidebar-w:    260px;
  --topbar-h:     60px;
  --text:         #0f172a;
  --text-muted:   #64748b;
  --border:       #e2e8f0;
  --surface:      #ffffff;
  --surface-alt:  #f8fafc;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.04);
  --shadow-md:    0 4px 24px rgba(0,0,0,.10);
  --transition:   .2s ease;
  font-size: 15px;
}

/* ─── Reset / Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  color: var(--text);
  background: #f1f5f9;
  margin: 0;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--brand-dark); }

/* ─── Layout ────────────────────────────────────────────────── */
.suas-wrapper {
  display: flex;
  min-height: 100vh;
}
.suas-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}
.suas-content {
  padding: 28px 32px 48px;
  flex: 1;
}

/* ─── Sidebar ───────────────────────────────────────────────── */
.suas-sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow-y: auto;
  transition: transform var(--transition);
}
.suas-sidebar::-webkit-scrollbar { width: 4px; }
.suas-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand-icon {
  width: 40px; height: 40px;
  background: var(--brand);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff;
  flex-shrink: 0;
}
.brand-name  { font-size: 17px; font-weight: 800; color: #fff; line-height: 1.1; display: block; }
.brand-sub   { font-size: 10px; font-weight: 500; color: rgba(255,255,255,.4); text-transform: uppercase; letter-spacing: .08em; display: block; }

/* Menu */
.sidebar-menu { flex: 1; padding: 16px 12px; }
.menu-label {
  font-size: 10px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: rgba(255,255,255,.3);
  padding: 14px 8px 6px; margin-bottom: 2px;
}
.menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.6);
  font-weight: 500; font-size: 14px;
  transition: all var(--transition);
  margin-bottom: 2px;
}
.menu-item i { font-size: 17px; flex-shrink: 0; }
.menu-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.menu-item.active {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 8px rgba(30,64,175,.4);
}

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  flex: 1; min-width: 0;
  color: rgba(255,255,255,.7);
  text-decoration: none;
}
.sidebar-user:hover { color: #fff; }
.user-avatar {
  width: 36px; height: 36px;
  background: var(--brand); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; color: #fff;
  flex-shrink: 0;
}
.user-name  { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { display: block; font-size: 11px; color: rgba(255,255,255,.4); text-transform: capitalize; }
.btn-logout {
  color: rgba(255,255,255,.4);
  font-size: 18px; padding: 4px;
  transition: color var(--transition);
  flex-shrink: 0;
}
.btn-logout:hover { color: #f87171; }

/* ─── Top Bar ───────────────────────────────────────────────── */
.suas-topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 32px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 0 var(--border);
}
.topbar-toggle {
  display: none;
  background: none; border: none;
  font-size: 22px; color: var(--text-muted);
  cursor: pointer; padding: 4px;
}
.topbar-title { font-weight: 700; font-size: 16px; color: var(--text); flex: 1; }
.topbar-date  { font-size: 13px; color: var(--text-muted); }

/* ─── Page Header ───────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 28px; gap: 16px; flex-wrap: wrap;
}
.page-title { font-size: 26px; font-weight: 800; margin: 0; color: var(--text); }
.page-sub   { font-size: 14px; color: var(--text-muted); margin: 4px 0 0; }

/* ─── Cards ─────────────────────────────────────────────────── */
.card-suas {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-suas-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}
.card-suas-header h5, .card-suas-header h6 {
  margin: 0; font-weight: 700; font-size: 15px; color: var(--text);
  display: flex; align-items: center;
}
.border-danger-soft { border-color: #fecaca !important; }

/* ─── Stat Cards (Dashboard) ────────────────────────────────── */
.stat-card {
  border-radius: var(--radius);
  padding: 24px;
  position: relative; overflow: hidden;
  border: 1px solid transparent;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.stat-card::before {
  content: ''; position: absolute;
  top: -20px; right: -20px;
  width: 100px; height: 100px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
}
.stat-blue   { background: linear-gradient(135deg, #1e40af, #3b82f6); color: #fff; }
.stat-orange { background: linear-gradient(135deg, #c2410c, #f97316); color: #fff; }
.stat-green  { background: linear-gradient(135deg, #166534, #22c55e); color: #fff; }
.stat-purple { background: linear-gradient(135deg, #6b21a8, #a855f7); color: #fff; }
.stat-icon   { font-size: 28px; opacity: .85; margin-bottom: 8px; }
.stat-value  { font-size: 38px; font-weight: 800; line-height: 1; margin-bottom: 4px; }
.stat-label  { font-size: 13px; opacity: .85; font-weight: 500; margin-bottom: 12px; }
.stat-link   { font-size: 12px; font-weight: 600; opacity: .9; display: flex; align-items: center; gap: 4px; margin-top: auto; color: inherit; }
.stat-link:hover { opacity: 1; }

/* ─── Tables ────────────────────────────────────────────────── */
.table-suas {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
.table-suas thead th {
  padding: 12px 16px;
  background: var(--surface-alt);
  border-bottom: 2px solid var(--border);
  font-weight: 700; font-size: 12px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-muted);
  white-space: nowrap;
}
.table-suas tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table-suas tbody tr:last-child td { border-bottom: none; }
.table-suas tbody tr:hover { background: var(--surface-alt); }
.table-suas tfoot td { padding: 12px 16px; border-top: 2px solid var(--border); background: var(--surface-alt); }

/* ─── Badges ────────────────────────────────────────────────── */
.badge-type {
  display: inline-block;
  background: var(--brand-light);
  color: var(--brand-dark);
  font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 20px;
  white-space: nowrap;
}
.badge-rma {
  display: inline-block;
  background: #fef3c7; color: #92400e;
  font-size: 11px; font-weight: 800;
  padding: 3px 9px; border-radius: 20px;
  font-family: 'JetBrains Mono', monospace;
}
.badge-audit {
  display: inline-block;
  background: #f1f5f9; color: var(--text-muted);
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
}
.mono-text { font-family: 'JetBrains Mono', monospace; font-size: 12px; }

/* ─── Action Buttons ────────────────────────────────────────── */
.action-btns { display: flex; gap: 4px; align-items: center; }
.btn-action {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-muted);
  font-size: 14px; cursor: pointer; transition: all var(--transition);
  text-decoration: none;
}
.btn-action:hover { background: var(--brand-light); color: var(--brand); border-color: var(--brand); }
.btn-action-danger:hover { background: #fee2e2; color: #dc2626; border-color: #dc2626; }

/* ─── Form sections ─────────────────────────────────────────── */
.suas-form { max-width: 1200px; }
.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.form-section-title {
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-muted);
  margin-bottom: 20px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
}
.form-label { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-label.required::after { content: ' *'; color: #dc2626; }
.form-label-sm { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; display: block; }
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  padding: 9px 13px;
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
  outline: none;
}

/* RMA Preview */
.rma-preview-box { background: #f8fafc; }
.rma-auto-badge {
  background: var(--surface-alt);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px; text-align: center; margin-bottom: 12px;
  transition: all var(--transition);
}
.rma-auto-badge.rma-active {
  background: #fefce8;
  border-color: #fbbf24;
}
.rma-code { font-size: 42px; font-weight: 900; color: #92400e; font-family: 'JetBrains Mono', monospace; line-height: 1; }
.rma-desc { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.rma-big-badge {
  display: inline-block;
  background: #fef3c7; color: #92400e;
  font-size: 56px; font-weight: 900;
  padding: 12px 28px; border-radius: var(--radius);
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 8px;
}

/* ─── Family Search ─────────────────────────────────────────── */
.family-search-wrap { position: relative; }
.family-suggestions {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 200;
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 260px; overflow-y: auto;
  margin-top: 4px;
}
.suggestion-item {
  padding: 10px 14px; cursor: pointer; font-size: 14px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover { background: var(--brand-light); }
.family-selected-badge {
  display: inline-flex; align-items: center;
  background: #dcfce7; color: #166534;
  border-radius: 20px; padding: 4px 14px;
  font-size: 13px; font-weight: 600;
}
.btn-clear-family {
  background: none; border: none; color: inherit;
  cursor: pointer; padding: 0; font-size: 14px; line-height: 1;
}

/* ─── Dashboard Extras ──────────────────────────────────────── */
.prod-item { margin-bottom: 14px; }
.alert-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.alert-item:last-child { border-bottom: none; }

/* Detail view */
.detail-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); margin-bottom: 4px; }
.detail-value { font-size: 15px; color: var(--text); }

/* ─── RMA Month Cards ───────────────────────────────────────── */
.rma-month-card {
  display: block; padding: 14px; border-radius: var(--radius);
  border: 1.5px solid var(--border); background: var(--surface);
  text-align: center; transition: all var(--transition);
  text-decoration: none; color: var(--text);
}
.rma-month-card:hover { border-color: var(--accent); box-shadow: 0 4px 12px var(--brand-glow); color: var(--text); }
.rma-closed { border-color: #86efac; background: #f0fdf4; }
.rma-open   { border-color: #fde68a; background: #fffbeb; }
.rma-empty  { opacity: .7; }
.rma-month-label  { font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.rma-month-status { font-size: 12px; display: flex; align-items: center; justify-content: center; gap: 5px; }
.rma-exported     { font-size: 10px; color: var(--text-muted); margin-top: 4px; }

/* RMA Form Fields */
.rma-field .form-label { font-size: 12px; }
.rma-input { font-family: 'JetBrains Mono', monospace; font-weight: 600; }
.rma-count-card {
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px; text-align: center;
}
.rma-count-code { font-size: 12px; font-weight: 800; font-family: 'JetBrains Mono', monospace; color: var(--brand); text-transform: uppercase; }
.rma-count-val  { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1.1; }
.rma-count-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ─── Prontuário Timeline ───────────────────────────────────── */
.prontuario-timeline { position: relative; }
.prontuario-timeline::before {
  content: ''; position: absolute; left: 10px; top: 0; bottom: 0;
  width: 2px; background: var(--border);
}
.timeline-item {
  display: flex; gap: 20px;
  padding-bottom: 24px;
  position: relative;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  width: 22px; height: 22px;
  background: var(--brand); border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px var(--border);
  flex-shrink: 0; position: relative; z-index: 1;
  margin-top: 2px;
}
.timeline-content {
  flex: 1; background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px;
}

/* Pending cards */
.pend-card {
  padding: 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 10px;
}
.pend-open   { border-left: 3px solid #ef4444; }
.pend-closed { border-left: 3px solid #22c55e; opacity: .75; }

/* ─── Reports ───────────────────────────────────────────────── */
.report-card {
  display: block; padding: 28px;
  background: var(--surface); border-radius: var(--radius);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow); transition: all var(--transition);
  text-decoration: none; color: var(--text);
}
.report-card:hover {
  border-color: var(--accent); box-shadow: 0 4px 20px var(--brand-glow);
  transform: translateY(-2px); color: var(--text);
}
.report-icon { font-size: 36px; color: var(--brand); margin-bottom: 14px; }
.report-title { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.report-desc  { font-size: 13px; color: var(--text-muted); }

/* ─── Login Page ────────────────────────────────────────────── */
.login-page { background: #0f172a; min-height: 100vh; }
.login-split {
  display: flex; min-height: 100vh;
}

/* Hero */
.login-hero {
  flex: 1; background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 60%, #3b82f6 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 60px; position: relative; overflow: hidden;
}
.login-hero::before {
  content: '';
  position: absolute; top: -100px; right: -100px;
  width: 400px; height: 400px;
  background: rgba(255,255,255,.06); border-radius: 50%;
}
.login-hero::after {
  content: '';
  position: absolute; bottom: -80px; left: -80px;
  width: 300px; height: 300px;
  background: rgba(255,255,255,.04); border-radius: 50%;
}
.login-hero-content { max-width: 420px; position: relative; z-index: 1; }
.hero-badge {
  display: inline-block; background: rgba(255,255,255,.15);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 20px; padding: 4px 14px;
  font-size: 12px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: rgba(255,255,255,.9);
  margin-bottom: 24px;
}
.hero-title {
  font-size: 64px; font-weight: 900; color: #fff;
  line-height: .95; margin-bottom: 20px;
}
.hero-desc {
  font-size: 17px; color: rgba(255,255,255,.75); line-height: 1.6;
  margin-bottom: 32px;
}
.hero-features { display: flex; flex-direction: column; gap: 10px; }
.feature-item {
  display: flex; align-items: center; gap: 10px;
  color: rgba(255,255,255,.85); font-size: 15px; font-weight: 500;
}
.feature-item i { color: #86efac; font-size: 16px; }

/* Form Panel */
.login-form-panel {
  width: 480px; background: #fff;
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
}
.login-box { width: 100%; max-width: 380px; }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; background: var(--brand);
  border-radius: 16px; font-size: 32px; color: #fff;
  box-shadow: 0 8px 24px rgba(30,64,175,.35);
}
.login-heading { font-size: 26px; font-weight: 800; text-align: center; margin-bottom: 6px; }
.login-sub     { font-size: 14px; color: var(--text-muted); text-align: center; margin-bottom: 28px; }

.form-group-login { margin-bottom: 18px; }
.form-group-login label { font-size: 13px; font-weight: 600; display: block; margin-bottom: 8px; }
.input-with-icon { position: relative; }
.input-with-icon > i:first-child {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 16px; pointer-events: none;
}
.input-with-icon .form-control { padding-left: 42px; padding-right: 42px; height: 48px; font-size: 15px; border-radius: 10px; }
.input-eye {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 4px; font-size: 16px;
}
.btn-login {
  width: 100%; height: 50px; background: var(--brand); color: #fff;
  border: none; border-radius: 10px; font-size: 15px; font-weight: 700;
  cursor: pointer; transition: all var(--transition); margin-top: 4px;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit;
}
.btn-login:hover { background: var(--brand-dark); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(30,64,175,.35); }
.login-footer-note {
  text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 20px;
}

/* ─── Buttons ───────────────────────────────────────────────── */
.btn {
  font-family: inherit; font-weight: 600; border-radius: var(--radius-sm);
  font-size: 14px; padding: 8px 18px;
  display: inline-flex; align-items: center; transition: all var(--transition);
}
.btn-primary   { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); box-shadow: 0 2px 8px var(--brand-glow); color: #fff; }
.btn-success:hover { box-shadow: 0 2px 8px rgba(34,197,94,.2); }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-sm { padding: 5px 12px; font-size: 13px; border-radius: 6px; }

/* ─── Misc ──────────────────────────────────────────────────── */
.progress-bar { background: var(--brand); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-switch .form-check-input { width: 40px; height: 22px; }

/* ─── Print ─────────────────────────────────────────────────── */
@media print {
  .suas-sidebar, .suas-topbar, .btn, .action-btns, .card-suas-header .btn { display: none !important; }
  .suas-main { margin-left: 0 !important; }
  .suas-content { padding: 0 !important; }
  body { background: #fff; }
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 991px) {
  .suas-sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
  }
  .suas-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.4);
  }
  .suas-main { margin-left: 0; }
  .topbar-toggle { display: flex; }
  .suas-content { padding: 20px 20px 40px; }
  .login-split { flex-direction: column; }
  .login-hero { padding: 40px 24px; flex: none; min-height: 280px; }
  .hero-title { font-size: 44px; }
  .login-form-panel { width: 100%; padding: 32px 24px; }
}

@media (max-width: 576px) {
  .page-header { flex-direction: column; align-items: flex-start; }
  .suas-content { padding: 16px 14px 32px; }
}
