/* ============================================================
   MODAL MODERNO — Padrao visual unificado pros modais do Nodus
   ============================================================
   Anatomia:
     [Header com gradient + avatar + nome/meta + chip]
     [Body com cards limpos + inputs prefix/suffix + pills]
     [Footer sticky com botoes coloridos por contexto]

   Variantes de header (definir no proprio elemento):
     .tm-header.h-blue   → Lancamento Mensal, Hora Extra
     .tm-header.h-amber  → Vales, financeiro/adiantamento
     .tm-header.h-pink   → Atestados, saude
     .tm-header.h-purple → Complementos avulsos (controle interno)
     .tm-header.h-green  → Aprovacoes, sucesso

   Botoes:
     .tm-btn-save.blue / .amber / .pink / .purple / .green
   ============================================================ */

/* ─── MODAL BOX ─────────────────────────────────────────────── */
/* z-index 10010: acima do fichaOverlay (9999) e dos outros overlays do app.
   Necessario porque varios modais (Hora Extra, Atestado upload preview) abrem
   POR DENTRO da ficha do colab. */
.tm-modal-overlay {
  position: fixed; inset: 0; z-index: 10010;
  background: rgba(15,23,42,.55);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  padding: 12px;
}
.tm-modal-box {
  background: #fff;
  border-radius: 18px;
  width: min(560px, 96vw);
  max-height: 92vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
  display: flex; flex-direction: column;
  animation: tmModalIn .25s cubic-bezier(.16,1,.3,1);
}
@keyframes tmModalIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── HEADER ─────────────────────────────────────────────────── */
.tm-header {
  color: #fff;
  padding: 20px 22px 16px;
  position: relative; overflow: hidden;
  flex-shrink: 0;
}
.tm-header::before {
  content: ''; position: absolute;
  top: -40%; right: -10%;
  width: 240px; height: 240px;
  background: radial-gradient(circle, rgba(255,255,255,.15), transparent 60%);
  pointer-events: none;
}
.tm-header.h-blue   { background: linear-gradient(135deg, #0891b2 0%, #06b6d4 60%, #14b8a6 100%); }
.tm-header.h-amber  { background: linear-gradient(135deg, #d97706 0%, #f59e0b 60%, #fbbf24 100%); }
.tm-header.h-pink   { background: linear-gradient(135deg, #be185d 0%, #ec4899 60%, #f472b6 100%); }
.tm-header.h-purple { background: linear-gradient(135deg, #6d28d9 0%, #8b5cf6 60%, #a78bfa 100%); }
.tm-header.h-green  { background: linear-gradient(135deg, #047857 0%, #10b981 60%, #34d399 100%); }
.tm-header.h-red    { background: linear-gradient(135deg, #b91c1c 0%, #ef4444 60%, #f87171 100%); }

.tm-close {
  position: absolute; top: 12px; right: 12px;
  width: 30px; height: 30px;
  border-radius: 8px;
  background: rgba(255,255,255,.18);
  border: 0; color: #fff; font-size: 1.1rem;
  cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s; padding: 0;
  z-index: 2;
}
.tm-close:hover { background: rgba(255,255,255,.3); }

.tm-h-row {
  display: flex; align-items: center; gap: 14px;
  position: relative; z-index: 1;
  padding-right: 36px;
}
.tm-avatar {
  width: 50px; height: 50px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.05rem;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,.3);
  letter-spacing: .5px;
}
.tm-info { flex: 1; min-width: 0; }
.tm-eyebrow {
  font-size: .65rem; opacity: .85;
  font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; margin-bottom: 2px;
}
.tm-name {
  font-size: 1rem; font-weight: 700;
  line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tm-meta {
  font-size: .68rem; opacity: .92;
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tm-h-chip {
  display: inline-block;
  background: rgba(255,255,255,.18);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: .65rem;
  margin-top: 6px;
  font-weight: 500;
}
.tm-h-chip strong { font-weight: 700; }

/* Centered header (sem avatar, modo "novo X" generico) */
.tm-header-centered {
  text-align: center; position: relative; z-index: 1;
  padding-right: 24px;
}
.tm-header-centered .tm-h-emoji {
  font-size: 1.8rem; margin-bottom: 4px;
}
.tm-header-centered .tm-name {
  white-space: normal;
  font-size: 1.1rem;
}
.tm-header-centered .tm-meta {
  white-space: normal;
}

/* ─── BODY ───────────────────────────────────────────────────── */
.tm-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
  display: flex; flex-direction: column;
  gap: 12px;
  background: var(--bg-secondary, #f8fafc);
}

/* ─── CARDS ──────────────────────────────────────────────────── */
.tm-card {
  background: #fff;
  border: 1px solid var(--glass-border, #e2e8f0);
  border-radius: 12px;
  padding: 14px;
}
.tm-card-title {
  display: flex; align-items: center; gap: 8px;
  font-size: .78rem; font-weight: 700;
  color: var(--text-primary, #0f172a);
  margin-bottom: 10px;
}
.tm-card-icon {
  width: 26px; height: 26px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem;
  flex-shrink: 0;
}
.tm-card-meta {
  font-size: .6rem; color: var(--text-tertiary, #94a3b8);
  font-weight: 500; margin-left: auto;
  font-style: italic;
}

/* ─── GRIDS ──────────────────────────────────────────────────── */
.tm-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tm-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
@media (max-width: 480px) {
  .tm-grid-2, .tm-grid-3 { grid-template-columns: 1fr; }
}

/* ─── FIELDS ─────────────────────────────────────────────────── */
.tm-field { margin-bottom: 0; }
.tm-field + .tm-field { margin-top: 10px; }
.tm-field label {
  display: block;
  font-size: .6rem; font-weight: 700;
  color: var(--text-secondary, #64748b);
  text-transform: uppercase; letter-spacing: .4px;
  margin-bottom: 5px;
}
.tm-field label .opt {
  color: #94a3b8; font-weight: 500;
  text-transform: none; letter-spacing: 0;
  margin-left: 4px;
}

/* Input com prefix (R$, 🕒, etc) ou suffix (dias, %, h) */
.tm-input-wrap { position: relative; display: flex; align-items: center; }
.tm-prefix {
  position: absolute; left: 11px;
  top: 50%; transform: translateY(-50%);
  font-size: .68rem; color: #94a3b8;
  font-weight: 600; pointer-events: none;
  z-index: 1;
}
.tm-suffix {
  position: absolute; right: 11px;
  top: 50%; transform: translateY(-50%);
  font-size: .68rem; color: #94a3b8;
  font-weight: 600; pointer-events: none;
  z-index: 1;
}
.tm-input-wrap input {
  width: 100%;
  padding: 10px 12px 10px 30px;
  border: 1.5px solid var(--glass-border, #e2e8f0);
  border-radius: 9px;
  font-size: .9rem; font-family: 'Space Mono', monospace; font-weight: 600;
  background: #fff;
  color: var(--text-primary, #0f172a);
  transition: border-color .15s, box-shadow .15s;
  box-sizing: border-box;
}
.tm-input-wrap.has-suffix input { padding: 10px 38px 10px 12px; }
.tm-input-wrap.has-both input { padding: 10px 38px 10px 30px; }
.tm-input-wrap input:focus {
  outline: 0;
  border-color: var(--accent, #0891b2);
  box-shadow: 0 0 0 3px rgba(8,145,178,.12);
}

/* Input plano (sem prefix) */
.tm-input-plain {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--glass-border, #e2e8f0);
  border-radius: 9px;
  font-size: .85rem; font-family: inherit;
  background: #fff;
  color: var(--text-primary, #0f172a);
  transition: border-color .15s, box-shadow .15s;
  box-sizing: border-box;
}
.tm-input-plain:focus {
  outline: 0;
  border-color: var(--accent, #0891b2);
  box-shadow: 0 0 0 3px rgba(8,145,178,.12);
}
textarea.tm-input-plain { resize: vertical; min-height: 60px; font-family: inherit; }

/* Select customizado */
.tm-select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--glass-border, #e2e8f0);
  border-radius: 9px;
  font-size: .85rem; font-family: inherit;
  background: #fff;
  color: var(--text-primary, #0f172a);
  cursor: pointer;
  box-sizing: border-box;
}

/* ─── PILLS (escolha entre opções) ───────────────────────────── */
.tm-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.tm-pill {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--glass-border, #e2e8f0);
  background: #fff;
  color: var(--text-secondary, #64748b);
  font-size: .7rem; font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
  white-space: nowrap;
}
.tm-pill:hover { border-color: #94a3b8; }
.tm-pill.active { background: rgba(8,145,178,.08); border-color: #0891b2; color: #0891b2; font-weight: 700; }
.tm-pill.amber.active { background: rgba(217,119,6,.08); border-color: #d97706; color: #d97706; }
.tm-pill.pink.active { background: rgba(236,72,153,.08); border-color: #ec4899; color: #ec4899; }
.tm-pill.purple.active { background: rgba(139,92,246,.08); border-color: #8b5cf6; color: #7c3aed; }
.tm-pill.green.active { background: rgba(16,185,129,.08); border-color: #10b981; color: #059669; }
.tm-pill.red.active { background: rgba(239,68,68,.08); border-color: #ef4444; color: #dc2626; }

/* Pills horizontais 50/50 (recorrencia, sim/nao) */
.tm-pills-row {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.tm-pills-row .tm-pill {
  text-align: center; padding: 10px;
  font-size: .72rem;
}

/* ─── CARD DE CALCULO/RESUMO (gradient sutil) ────────────────── */
.tm-info-card {
  background: linear-gradient(135deg, rgba(8,145,178,.04), rgba(245,158,11,.04));
  border: 1px solid rgba(245,158,11,.2);
  border-radius: 12px; padding: 14px;
}
.tm-info-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(0,0,0,.06);
  font-size: .72rem;
}
.tm-info-row:last-child { border-bottom: 0; }
.tm-info-label { color: var(--text-secondary, #64748b); font-weight: 500; }
.tm-info-val { font-weight: 700; font-family: 'Space Mono', monospace; color: var(--text-primary, #0f172a); }
.tm-info-row.total {
  margin-top: 6px; padding-top: 12px;
  border-top: 2px solid rgba(8,145,178,.2);
  border-bottom: 0;
}
.tm-info-row.total .tm-info-label {
  text-transform: uppercase; letter-spacing: .8px; font-weight: 700; font-size: .68rem;
}
.tm-info-row.total .tm-info-val {
  font-size: 1.3rem; color: var(--accent, #0891b2);
}

/* Variantes de cor no card de info */
.tm-info-card.amber { background: linear-gradient(135deg, rgba(217,119,6,.05), rgba(245,158,11,.04)); border-color: rgba(217,119,6,.2); }
.tm-info-card.amber .tm-info-row.total .tm-info-val { color: #d97706; }
.tm-info-card.pink { background: linear-gradient(135deg, rgba(190,24,93,.04), rgba(236,72,153,.04)); border-color: rgba(236,72,153,.2); }
.tm-info-card.pink .tm-info-row.total .tm-info-val { color: #be185d; }

/* ─── CHECKBOX ROW ───────────────────────────────────────────── */
.tm-check-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0;
  font-size: .76rem;
  color: var(--text-secondary, #64748b);
  cursor: pointer;
}
.tm-check-row input[type="checkbox"] {
  accent-color: var(--accent, #0891b2);
  width: 16px; height: 16px;
  margin: 0;
  flex-shrink: 0;
}

/* ─── UPLOAD AREA ────────────────────────────────────────────── */
.tm-upload {
  border: 2px dashed var(--glass-border, #e2e8f0);
  border-radius: 10px;
  padding: 20px 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.tm-upload:hover { border-color: var(--accent, #0891b2); background: rgba(8,145,178,.02); }
.tm-upload-icon { font-size: 1.6rem; margin-bottom: 6px; }
.tm-upload-label { font-size: .8rem; font-weight: 700; color: var(--accent, #0891b2); margin-bottom: 2px; }
.tm-upload-sub { font-size: .65rem; color: #94a3b8; }
.tm-upload input[type="file"] { display: none; }
.tm-upload.has-file { border-style: solid; border-color: #10b981; background: rgba(16,185,129,.04); }
.tm-upload.has-file .tm-upload-label { color: #059669; }

/* ─── FOOTER ─────────────────────────────────────────────────── */
.tm-footer {
  display: flex; gap: 8px;
  padding: 13px 20px;
  background: var(--bg-secondary, #f8fafc);
  border-top: 1px solid var(--glass-border, #e2e8f0);
  flex-shrink: 0;
  align-items: center;
}
.tm-btn {
  flex: 1; min-width: 0;
  padding: 11px 12px;
  border-radius: 9px;
  font-weight: 700; font-size: .8rem;
  cursor: pointer; border: 0;
  font-family: inherit;
  transition: all .15s;
  white-space: nowrap;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  overflow: hidden; text-overflow: ellipsis;
}
.tm-btn-icon { font-size: .95rem; flex-shrink: 0; }
.tm-btn-text { overflow: hidden; text-overflow: ellipsis; }

.tm-btn-ghost { background: transparent; color: var(--text-secondary, #64748b); border: 1.5px solid var(--glass-border, #e2e8f0); }
.tm-btn-ghost:hover { background: rgba(0,0,0,.03); border-color: var(--text-secondary, #64748b); }

.tm-btn-secondary { background: rgba(8,145,178,.08); color: #0891b2; border: 1.5px solid rgba(8,145,178,.3); }
.tm-btn-secondary:hover { background: rgba(8,145,178,.15); border-color: #0891b2; }

.tm-btn-save { color: #fff; flex: 1.6; }
.tm-btn-save:hover { transform: translateY(-1px); }
.tm-btn-save.blue   { background: linear-gradient(135deg, #0891b2, #06b6d4); box-shadow: 0 2px 8px rgba(8,145,178,.25); }
.tm-btn-save.amber  { background: linear-gradient(135deg, #d97706, #f59e0b); box-shadow: 0 2px 8px rgba(217,119,6,.25); }
.tm-btn-save.pink   { background: linear-gradient(135deg, #be185d, #ec4899); box-shadow: 0 2px 8px rgba(190,24,93,.25); }
.tm-btn-save.purple { background: linear-gradient(135deg, #6d28d9, #8b5cf6); box-shadow: 0 2px 8px rgba(109,40,217,.25); }
.tm-btn-save.green  { background: linear-gradient(135deg, #047857, #10b981); box-shadow: 0 2px 8px rgba(4,120,87,.25); }
.tm-btn-save.red    { background: linear-gradient(135deg, #b91c1c, #ef4444); box-shadow: 0 2px 8px rgba(185,28,28,.25); }
.tm-btn-save:hover.blue   { box-shadow: 0 4px 12px rgba(8,145,178,.35); }
.tm-btn-save:hover.amber  { box-shadow: 0 4px 12px rgba(217,119,6,.35); }
.tm-btn-save:hover.pink   { box-shadow: 0 4px 12px rgba(190,24,93,.35); }
.tm-btn-save:hover.purple { box-shadow: 0 4px 12px rgba(109,40,217,.35); }
.tm-btn-save:hover.green  { box-shadow: 0 4px 12px rgba(4,120,87,.35); }

/* ─── ALERT BOXES (avisos contextuais) ───────────────────────── */
.tm-alert {
  padding: 10px 12px; border-radius: 9px;
  font-size: .7rem; line-height: 1.5;
  display: flex; gap: 8px; align-items: flex-start;
  margin-bottom: 6px;
}
.tm-alert .tm-alert-icon { font-size: 1rem; flex-shrink: 0; }
.tm-alert.info    { background: rgba(8,145,178,.06); border-left: 3px solid #0891b2; color: #0c4a6e; }
.tm-alert.warn    { background: linear-gradient(135deg, rgba(245,158,11,.08), rgba(245,158,11,.04)); border: 1px solid rgba(245,158,11,.25); border-left: 3px solid #f59e0b; color: #78350f; }
.tm-alert.success { background: linear-gradient(135deg, rgba(16,185,129,.08), rgba(16,185,129,.04)); border: 1px solid rgba(16,185,129,.25); border-left: 3px solid #10b981; color: #065f46; }
.tm-alert.danger  { background: rgba(239,68,68,.06); border-left: 3px solid #ef4444; color: #991b1b; }

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 480px) {
  .tm-modal-overlay { padding: 6px; }
  .tm-modal-box { width: 100%; max-height: 96vh; border-radius: 14px; }
  .tm-header { padding: 16px 16px 14px; }
  .tm-avatar { width: 44px; height: 44px; font-size: 1rem; }
  .tm-name { font-size: .92rem; }
  .tm-h-chip { font-size: .6rem; padding: 2px 8px; }
  .tm-body { padding: 14px 14px; }
  .tm-card { padding: 12px; }
  .tm-card-title { font-size: .75rem; }
  .tm-footer { padding: 11px 14px; gap: 6px; }
  .tm-btn { padding: 11px 8px; font-size: .75rem; }
  .tm-btn-text-mobile-hide { display: none; }
  .tm-info-row.total .tm-info-val { font-size: 1.1rem; }
}
