/* ============================================================
   SISTEMA CAC GESTÃO — Estilos
   ============================================================ */

:root {
  --sidebar-bg:    #1a2e44;
  --sidebar-hover: #243d5a;
  --sidebar-active:#2e5080;
  --accent:        #3b82f6;
  --accent-dark:   #2563eb;
  --success:       #22c55e;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --text-muted:    #6b7280;
  --border:        #e5e7eb;
  --bg-light:      #f9fafb;
  --sidebar-w:     240px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  background: var(--bg-light);
  color: #1f2937;
}

/* ---- TELA DE LOGIN ---- */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #518DD9;
}
.login-card {
  background: #233041;
  border-radius: 12px;
  padding: 40px 40px 48px;
  text-align: center;
  width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.login-card .logo { margin-bottom: 12px; line-height: 1; }
.login-card h1 { font-size: 22px; font-weight: 700; margin: 0 0 4px; color: #ffffff; }
.login-card p  { color: rgba(255,255,255,.6); margin: 0 0 32px; font-size: 13px; }
.btn-ms {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 12px 20px;
  background: #377D22; color: white; border: none; border-radius: 6px;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: background .2s;
}
.btn-ms:hover { background: #2d6a1b; }

/* ---- SETUP (criação inicial das listas) ---- */
#setup-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: #518DD9;
}
.setup-card {
  background: white; border-radius: 12px; padding: 40px;
  width: 420px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.setup-card h2 { margin: 0 0 12px; color: #1a2e44; }
.setup-card p  { color: var(--text-muted); margin: 0 0 24px; }
#setup-progress { font-size: 13px; color: var(--text-muted); margin-top: 16px; min-height: 20px; }

/* ---- LAYOUT PRINCIPAL ---- */
#app-shell { display: flex; min-height: 100vh; }

/* ---- SIDEBAR ---- */
#sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100; overflow-y: auto;
}
.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-header .brand { font-size: 16px; font-weight: 700; color: white; }
.sidebar-header .user-info { font-size: 12px; color: rgba(255,255,255,.5); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#sidebar nav { flex: 1; padding: 12px 0; }
.nav-section { padding: 8px 16px 4px; font-size: 10px; font-weight: 600; color: rgba(255,255,255,.35); text-transform: uppercase; letter-spacing: .08em; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; color: rgba(255,255,255,.7);
  cursor: pointer; text-decoration: none;
  border-left: 3px solid transparent; transition: all .15s;
  font-size: 13px;
}
.nav-item:hover  { background: var(--sidebar-hover); color: white; border-left-color: rgba(255,255,255,.2); }
.nav-item.active { background: var(--sidebar-active); color: white; border-left-color: var(--accent); }
.nav-item i { font-size: 16px; width: 18px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.btn-logout {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 12px;
  background: rgba(255,255,255,.06); border: none;
  border-radius: 6px; color: rgba(255,255,255,.6);
  font-size: 13px; cursor: pointer; transition: all .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.12); color: white; }

/* ---- CONTEÚDO PRINCIPAL ---- */
#main-content {
  margin-left: var(--sidebar-w);
  flex: 1; display: flex; flex-direction: column; min-height: 100vh;
}
#page-header {
  background: white; border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
#page-header h2 { margin: 0; font-size: 16px; font-weight: 600; color: #1f2937; }
#page-content { padding: 24px; flex: 1; }

/* ---- CARDS / PAINEIS ---- */
.card {
  background: white; border-radius: 10px;
  border: 1px solid var(--border); overflow: hidden;
}
.card-header {
  padding: 14px 20px; background: white;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card-body { padding: 20px; }

/* ---- DASHBOARD STATS ---- */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: white; border-radius: 10px;
  border: 1px solid var(--border); padding: 20px;
  display: flex; align-items: center; gap: 16px;
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.stat-icon.blue   { background: #eff6ff; color: #3b82f6; }
.stat-icon.green  { background: #f0fdf4; color: #22c55e; }
.stat-icon.yellow { background: #fffbeb; color: #f59e0b; }
.stat-icon.red    { background: #fef2f2; color: #ef4444; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---- TABELAS ---- */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: 10px 14px;
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .05em;
  background: var(--bg-light); border-bottom: 1px solid var(--border);
}
td {
  padding: 11px 14px; border-bottom: 1px solid var(--border);
  vertical-align: middle; font-size: 13px;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-light); }

/* ---- BADGES DE STATUS ---- */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-green  { background: #dcfce7; color: #166534; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-gray   { background: #f3f4f6; color: #374151; }
.badge-purple { background: #f3e8ff; color: #7c3aed; }

/* ---- FORMULÁRIOS ---- */
.form-section {
  background: white; border-radius: 10px;
  border: 1px solid var(--border); margin-bottom: 20px;
}
.form-section-title {
  padding: 12px 20px; font-size: 13px; font-weight: 600;
  color: #374151; background: var(--bg-light);
  border-bottom: 1px solid var(--border); border-radius: 10px 10px 0 0;
}
.form-body { padding: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.form-full { grid-column: 1 / -1; }

label { display: block; font-size: 12px; font-weight: 600; color: #374151; margin-bottom: 5px; }
input[type=text], input[type=date], input[type=email],
input[type=number], input[type=url], select, textarea {
  width: 100%; padding: 8px 12px;
  border: 1px solid #d1d5db; border-radius: 6px;
  font-size: 13px; font-family: inherit; color: #1f2937;
  background: white; transition: border-color .15s, box-shadow .15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}
textarea { resize: vertical; min-height: 72px; }
select { cursor: pointer; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ---- CHECKBOXES DE CATEGORIA ---- */
.checkbox-group { display: flex; gap: 20px; flex-wrap: wrap; }
.checkbox-item { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; font-weight: 400; color: #374151; margin-bottom: 0; }
.checkbox-item input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }

/* ---- CHECKLIST DE PROCESSOS ---- */
.checklist-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.checklist-item:last-child { border-bottom: none; }
.checklist-item input[type=checkbox] {
  width: 18px; height: 18px; margin-top: 2px; flex-shrink: 0;
  accent-color: var(--accent); cursor: pointer;
}
.checklist-item.done .checklist-nome { text-decoration: line-through; color: var(--text-muted); }
.checklist-nome { font-size: 13px; font-weight: 500; flex: 0 0 220px; min-width: 0; }
.checklist-obs { flex: 1; }
.checklist-obs input {
  border: 1px solid #e5e7eb; padding: 5px 10px; border-radius: 5px;
  font-size: 12px; width: 100%;
}
.checklist-progress {
  background: var(--bg-light); border-radius: 6px; padding: 10px 14px;
  margin-bottom: 16px; display: flex; align-items: center; gap: 12px;
}
.progress-bar-wrap { flex: 1; background: #e5e7eb; border-radius: 10px; height: 8px; }
.progress-bar { height: 8px; border-radius: 10px; background: var(--accent); transition: width .3s; }
.progress-text { font-size: 12px; font-weight: 600; color: #374151; white-space: nowrap; }

/* ---- ABAS ---- */
.tabs { border-bottom: 1px solid var(--border); margin-bottom: 20px; display: flex; gap: 0; }
.tab-btn {
  padding: 10px 18px; font-size: 13px; font-weight: 500;
  color: var(--text-muted); border: none; background: none;
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: all .15s;
}
.tab-btn:hover { color: #374151; }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ---- BOTÕES ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 6px; font-size: 13px;
  font-weight: 600; cursor: pointer; border: none;
  text-decoration: none; transition: all .15s; white-space: nowrap;
}
.btn-primary   { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-success   { background: var(--success); color: white; }
.btn-success:hover { background: #16a34a; }
.btn-danger    { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-outline   { background: white; color: #374151; border: 1px solid #d1d5db; }
.btn-outline:hover { background: var(--bg-light); }
.btn-ghost     { background: transparent; color: var(--text-muted); border: 1px solid transparent; }
.btn-ghost:hover { background: var(--bg-light); color: #374151; }
.btn-sm        { padding: 5px 10px; font-size: 12px; }
.btn-whatsapp  { background: #25d366; color: white; }
.btn-whatsapp:hover { background: #128c7e; }
.btn-group     { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- ALERTAS VALIDADE ---- */
.alert-card {
  border-left: 4px solid; border-radius: 8px; padding: 12px 16px;
  display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px;
}
.alert-card.red    { border-color: var(--danger); background: #fef2f2; }
.alert-card.orange { border-color: #f97316; background: #fff7ed; }
.alert-card.yellow { border-color: var(--warning); background: #fffbeb; }
.alert-card i { font-size: 18px; margin-top: 2px; flex-shrink: 0; }
.alert-card.red i    { color: var(--danger); }
.alert-card.orange i { color: #f97316; }
.alert-card.yellow i { color: var(--warning); }

/* ---- BUSCA ---- */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: white; border: 1px solid #d1d5db;
  border-radius: 8px; padding: 8px 12px; flex: 1; max-width: 360px;
}
.search-bar i { color: var(--text-muted); }
.search-bar input {
  border: none; outline: none; width: 100%; font-size: 13px;
  box-shadow: none; padding: 0;
}

/* ---- TOOLBAR ---- */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; flex-wrap: wrap; gap: 10px;
}

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center; padding: 48px 24px; color: var(--text-muted);
}
.empty-state i { font-size: 48px; opacity: .3; display: block; margin-bottom: 12px; }
.empty-state p { margin: 0 0 16px; }

/* ---- LOADING ---- */
#loading-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
}
.spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,.2);
  border-top-color: white; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- TOAST ---- */
#toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 10000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: #1f2937; color: white; border-radius: 8px;
  padding: 12px 16px; font-size: 13px; min-width: 260px;
  display: flex; align-items: flex-start; gap: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  animation: slideIn .25s ease;
}
.toast.success { background: #166534; }
.toast.error   { background: #991b1b; }
.toast.warning { background: #854d0e; }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ---- INFO ITEM (leitura de dados) ---- */
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.info-item label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; display: block; }
.info-item .value { font-size: 14px; color: #1f2937; word-break: break-word; }
.info-item .value.empty { color: #d1d5db; font-style: italic; }

.btn-copy {
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
  padding: 0; border: 1px solid var(--border); border-radius: 4px;
  background: white; color: var(--text-muted);
  font-size: 12px; cursor: pointer; transition: all .15s;
  opacity: 0;
}
.info-item:hover .btn-copy,
.copy-hover-wrap:hover .btn-copy { opacity: 1; }
.btn-copy:hover { background: var(--bg-light); color: var(--accent); border-color: var(--accent); }
.btn-copy.copied { background: #f0fdf4; color: var(--success); border-color: var(--success); opacity: 1; }

/* ---- PÁGINA PERFIL DO CLIENTE ---- */
.profile-header {
  background: white; border: 1px solid var(--border);
  border-radius: 10px; padding: 20px 24px; margin-bottom: 20px;
  display: flex; align-items: center; gap: 16px;
}
.profile-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--sidebar-active); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; flex-shrink: 0;
}
.profile-info h2 { margin: 0 0 4px; font-size: 18px; }
.profile-info p  { margin: 0; color: var(--text-muted); font-size: 13px; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  #sidebar { display: none; }
  #main-content { margin-left: 0; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: span 1; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
