/* ============================================================
   WA MASS — Main Stylesheet
   Fonte: Manrope (display) + DM Sans (body)
   Tema: menu colorido no topo, conteúdo branco/clean
   ============================================================ */

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

:root {
  /* Paleta principal */
  --primary:       #1a7f5a;
  --primary-dark:  #135f43;
  --primary-light: #e6f5ef;
  --accent:        #25d366;  /* verde WhatsApp */
  --accent-2:      #128c7e;

  /* Superfícies */
  --bg:            #f5f7f9;
  --surface:       #ffffff;
  --surface-2:     #f0f2f5;
  --border:        #e2e6ea;
  --border-light:  #edf0f3;

  /* Texto */
  --text:          #1a1f2e;
  --text-muted:    #6b7280;
  --text-light:    #9ca3af;

  /* Status */
  --success:       #10b981;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --info:          #3b82f6;

  /* Nav */
  --nav-bg:        #0f3d2b;
  --nav-height:    60px;

  /* Misc */
  --radius:        10px;
  --radius-sm:     6px;
  --radius-lg:     16px;
  --shadow:        0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-sm:     0 1px 3px rgba(0,0,0,.06);
  --transition:    .18s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ============================================================
   TOPNAV
   ============================================================ */
.topnav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-height);
  background: var(--nav-bg);
  display: flex; align-items: center; gap: 0;
  box-shadow: 0 2px 16px rgba(0,0,0,.25);
}

.topnav__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 24px;
  text-decoration: none;
  min-width: 220px;
  border-right: 1px solid rgba(255,255,255,.08);
}

.topnav__brand-icon {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

.topnav__brand-text {
  font-family: 'Manrope', sans-serif;
  font-weight: 800; font-size: 1.1rem;
  color: #fff; letter-spacing: -.3px;
}

.topnav__brand-text span { color: var(--accent); }

.topnav__menu {
  display: flex; align-items: center; flex: 1;
  list-style: none; padding: 0 16px; gap: 2px;
}

.topnav__menu li a {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.7); font-size: .875rem;
  font-weight: 500; text-decoration: none;
  transition: var(--transition);
}

.topnav__menu li a:hover,
.topnav__menu li a.active {
  background: rgba(255,255,255,.1);
  color: #fff;
}

.topnav__menu li a.active { background: rgba(37,211,102,.18); color: var(--accent); }

.topnav__right {
  display: flex; align-items: center; gap: 8px;
  padding: 0 20px;
}

.topnav__tenant-badge {
  font-size: .78rem; font-weight: 600;
  background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.85);
  padding: 4px 10px; border-radius: 20px;
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.topnav__user-btn {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: #fff; border-radius: var(--radius-sm);
  padding: 6px 12px; cursor: pointer; font-size: .85rem;
  font-family: inherit; transition: var(--transition);
  position: relative;
}
.topnav__user-btn:hover { background: rgba(255,255,255,.15); }

.topnav__dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  min-width: 180px; display: none; z-index: 200;
}
.topnav__dropdown.open { display: block; }
.topnav__dropdown a {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; color: var(--text); font-size: .875rem;
  text-decoration: none; transition: var(--transition);
}
.topnav__dropdown a:hover { background: var(--surface-2); }
.topnav__dropdown hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* ============================================================
   LAYOUT PRINCIPAL
   ============================================================ */
.page-wrap {
  padding-top: var(--nav-height);
  min-height: 100vh;
}

.container {
  max-width: 1280px; margin: 0 auto; padding: 0 24px;
}

.page-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
  margin-bottom: 28px;
}

.page-header__inner {
  display: flex; align-items: center; justify-content: space-between;
}

.page-header h1 {
  font-family: 'Manrope', sans-serif;
  font-size: 1.35rem; font-weight: 700;
  color: var(--text);
}

.page-header p {
  font-size: .875rem; color: var(--text-muted); margin-top: 2px;
}

.content-area { padding-bottom: 48px; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-light);
}

.card-header h3 {
  font-family: 'Manrope', sans-serif;
  font-size: 1rem; font-weight: 700; color: var(--text);
}

.card-body { padding: 22px; }

/* ============================================================
   KPI CARDS
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex; align-items: flex-start; gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.kpi-card__icon {
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}

.kpi-card__icon.green  { background: #e6f5ef; }
.kpi-card__icon.blue   { background: #eff6ff; }
.kpi-card__icon.orange { background: #fff7ed; }
.kpi-card__icon.red    { background: #fef2f2; }
.kpi-card__icon.purple { background: #f5f3ff; }

.kpi-card__info { flex: 1; min-width: 0; }

.kpi-card__value {
  font-family: 'Manrope', sans-serif;
  font-size: 1.7rem; font-weight: 800;
  color: var(--text); line-height: 1.1;
}

.kpi-card__label {
  font-size: .8rem; color: var(--text-muted); margin-top: 3px;
}

/* ============================================================
   TABELAS
   ============================================================ */
.table-wrap { overflow-x: auto; }

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

thead th {
  background: var(--surface-2);
  padding: 11px 16px;
  text-align: left; font-size: .78rem;
  font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: .875rem; color: var(--text);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }

/* ============================================================
   BADGES / STATUS
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-size: .75rem; font-weight: 600; white-space: nowrap;
}

.badge-success  { background: #d1fae5; color: #065f46; }
.badge-danger   { background: #fee2e2; color: #991b1b; }
.badge-warning  { background: #fef3c7; color: #92400e; }
.badge-info     { background: #dbeafe; color: #1e40af; }
.badge-neutral  { background: #f3f4f6; color: #374151; }
.badge-running  { background: #d1fae5; color: #065f46; }
.badge-paused   { background: #fef3c7; color: #92400e; }
.badge-draft    { background: #f3f4f6; color: #6b7280; }
.badge-done     { background: #dbeafe; color: #1e40af; }

.dot {
  width: 7px; height: 7px; border-radius: 50%; display: inline-block;
}
.dot-green  { background: var(--success); }
.dot-red    { background: var(--danger); }
.dot-yellow { background: var(--warning); }
.dot-blue   { background: var(--info); }

/* ============================================================
   BOTÕES
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-family: inherit; font-size: .875rem; font-weight: 600;
  cursor: pointer; border: none; text-decoration: none;
  transition: var(--transition); white-space: nowrap;
  line-height: 1;
}

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

.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.92); }

.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.9); }

.btn-warning   { background: var(--warning); color: #fff; }
.btn-warning:hover { filter: brightness(.92); }

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

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

.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

/* ============================================================
   FORMULÁRIOS
   ============================================================ */
.form-group { margin-bottom: 20px; }

label {
  display: block; margin-bottom: 6px;
  font-size: .83rem; font-weight: 600; color: var(--text);
}

.form-control {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: .875rem; color: var(--text);
  background: var(--surface);
  transition: var(--transition); outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,127,90,.12);
}

.form-control::placeholder { color: var(--text-light); }

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

.form-hint {
  font-size: .78rem; color: var(--text-muted); margin-top: 5px;
}

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

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress-bar-wrap {
  background: var(--surface-2);
  border-radius: 99px; height: 8px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .5s ease;
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: .875rem; display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 16px;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

/* ============================================================
   MODAIS
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.45); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  transform: translateY(16px);
  transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }

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

.modal-header h3 {
  font-family: 'Manrope', sans-serif;
  font-size: 1.05rem; font-weight: 700;
}

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

/* ============================================================
   PAGINAÇÃO
   ============================================================ */
.pagination {
  display: flex; gap: 4px; align-items: center;
  justify-content: center; margin-top: 24px;
}

.pagination a, .pagination span {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  font-size: .85rem; font-weight: 500; text-decoration: none;
  color: var(--text-muted); border: 1px solid var(--border);
  transition: var(--transition);
}

.pagination a:hover { background: var(--surface-2); color: var(--text); }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ============================================================
   UPLOAD AREA
   ============================================================ */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px; text-align: center;
  cursor: pointer; transition: var(--transition);
  background: var(--surface-2);
}
.upload-area:hover, .upload-area.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}
.upload-area__icon { font-size: 2.2rem; margin-bottom: 10px; opacity: .7; }
.upload-area__text { font-size: .875rem; color: var(--text-muted); }
.upload-area__sub  { font-size: .78rem; color: var(--text-light); margin-top: 5px; }

/* ============================================================
   CHIP / TAG
   ============================================================ */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 20px;
  background: var(--primary-light); color: var(--primary-dark);
  font-size: .78rem; font-weight: 600;
}

/* ============================================================
   SSE / LIVE INDICATOR
   ============================================================ */
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
  display: inline-block;
  animation: pulse-dot 1.5s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .5; transform: scale(.8); }
}

/* ============================================================
   UTILITÁRIOS
   ============================================================ */
.mt-4 { margin-top: 4px; }  .mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; }
.mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }

.flex { display: flex; } .flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.grid { display: grid; }

.text-sm { font-size: .85rem; }
.text-xs { font-size: .78rem; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-bold { font-weight: 700; }
.text-center { text-align: center; }

.w-full { width: 100%; }
.hidden { display: none !important; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .topnav__brand { min-width: auto; padding: 0 16px; }
  .topnav__menu { display: none; }
  .form-row-2, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .container { padding: 0 16px; }
}

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