/* =============================================================
   GLEG Convênios — Design System (espelha o app GLEG)
   Organização: Tokens → Reset → Layout → Componentes → Telas
   ============================================================= */

/* ── 1. TOKENS ─────────────────────────────────────────────── */
:root {
  /* Cores do app */
  --app-blue:        #1565C0;   /* títulos do header */
  --app-blue-dark:   #0D47A1;
  --app-blue-light:  #E3F2FD;
  --app-cyan:        #00AEEF;   /* fundo bottom-nav, strips */
  --app-cyan-dark:   #0090CC;
  --app-yellow:      #FFD600;   /* ícone/label ativo no nav, badges */
  --app-yellow-dark: #F9A825;

  /* Ícones coloridos (grid de menu) */
  --icon-green:      #4CAF50;
  --icon-purple:     #7B1FA2;
  --icon-orange:     #F57C00;
  --icon-teal:       #00ACC1;
  --icon-red:        #E53935;
  --icon-pink:       #D81B60;
  --icon-indigo:     #3949AB;
  --icon-amber:      #FF8F00;

  /* Neutros */
  --bg-page:         #F4F6F9;
  --bg-card:         #FFFFFF;
  --bg-card-hover:   #FAFBFC;
  --border:          #E8EAED;
  --border-strong:   #D0D3D8;

  /* Texto */
  --text-primary:    #1A1A2E;
  --text-secondary:  #5F6368;
  --text-muted:      #9AA0A6;
  --text-white:      #FFFFFF;
  --text-link:       #1565C0;

  /* Benefício / destaque */
  --benefit-bg:      #FFF8E1;
  --benefit-border:  #FFE082;
  --benefit-text:    #5D4037;

  /* Tamanhos */
  --header-h:        56px;
  --tabs-h:          44px;
  --bottom-nav-h:    62px;
  --card-radius:     14px;
  --btn-radius:      8px;
  --chip-radius:     20px;

  /* Sombras */
  --shadow-card:     0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-card-up:  0 4px 16px rgba(0,0,0,.12);
  --shadow-header:   0 2px 4px rgba(0,0,0,.12);

  /* Tipografia */
  --font:            'Roboto', system-ui, -apple-system, sans-serif;
  --font-title:      'Roboto', system-ui, sans-serif;

  /* Transições */
  --t:               0.2s ease;
  --t-slide:         0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── 2. RESET ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  height: 100%;
}
body {
  font-family: var(--font);
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100%;
  /* Evita scroll duplo dentro do app */
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
img { max-width: 100%; display: block; }

/* ── 3. LAYOUT PRINCIPAL ───────────────────────────────────── */

/* O conteúdo fica entre header+tabs e bottom-nav */
.screen-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100vh;
}

.screen-body {
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(var(--bottom-nav-h) + 8px);
  /* scroll suave nativo */
  -webkit-overflow-scrolling: touch;
}

/* ── 4. HEADER ─────────────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  padding: 0 8px;
  box-shadow: var(--shadow-header);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 4px;
}

.header-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: background var(--t);
}
.header-btn:active { background: var(--bg-page); }
.header-btn svg { width: 22px; height: 22px; }

.header-title {
  flex: 1;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--app-blue);
  letter-spacing: .2px;
}

/* ── 5. BARRA DE BUSCA ─────────────────────────────────────── */
.search-bar {
  background: var(--bg-card);
  padding: 10px 16px 10px;
  border-bottom: 1px solid var(--border);
}

.search-input-wrap {
  position: relative;
  background: var(--bg-page);
  border-radius: var(--btn-radius);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  transition: border-color var(--t);
}
.search-input-wrap:focus-within {
  border-color: var(--app-cyan);
  background: #fff;
}
.search-input-wrap svg {
  position: absolute;
  left: 12px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 10px 36px 10px 40px;
  background: transparent;
  border: none;
  outline: none;
  font-size: 15px;
  color: var(--text-primary);
  font-family: var(--font);
}
.search-input::placeholder { color: var(--text-muted); }
.search-clear {
  position: absolute;
  right: 10px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--text-muted);
  color: #fff;
  font-size: 12px;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.search-input-wrap.has-value .search-clear { display: flex; }

/* ── 6. ABAS DE FILTRO ─────────────────────────────────────── */
.filter-tabs-wrap {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--header-h);
  z-index: 90;
}

.filter-tabs {
  display: flex;
  overflow-x: auto;
  padding: 0 12px;
  gap: 4px;
  scrollbar-width: none;
}
.filter-tabs::-webkit-scrollbar { display: none; }

.filter-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 14px;
  height: var(--tabs-h);
  white-space: nowrap;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2.5px solid transparent;
  transition: color var(--t), border-color var(--t);
  flex-shrink: 0;
}
.filter-tab:active { color: var(--app-blue); }
.filter-tab.active {
  color: var(--app-blue);
  border-bottom-color: var(--app-blue);
  font-weight: 700;
}

.tab-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: .6;
}

/* ── 7. CONTADOR DE RESULTADOS ─────────────────────────────── */
.results-bar {
  padding: 12px 16px 4px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: .3px;
  text-transform: uppercase;
}

/* ── 8. LISTA DE CARDS ─────────────────────────────────────── */
.cards-list {
  padding: 0 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── 9. CARD DE CONVÊNIO ───────────────────────────────────── */
.convenio-card {
  background: var(--bg-card);
  border-radius: var(--card-radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: box-shadow var(--t), transform var(--t);
  -webkit-tap-highlight-color: transparent;
}
.convenio-card:active {
  box-shadow: var(--shadow-card-up);
  transform: scale(.992);
}

/* Cabeçalho do card */
.card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 10px;
}

.card-cat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
  /* cor definida inline via data-theme */
}

.card-heading { flex: 1; min-width: 0; }

.card-cat-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  margin-bottom: 2px;
  /* cor via CSS custom property herdada do tema */
}

.card-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

/* Destaque do benefício */
.card-benefit {
  margin: 0 14px 10px;
  background: var(--benefit-bg);
  border: 1px solid var(--benefit-border);
  border-radius: var(--btn-radius);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-benefit-icon { font-size: 18px; flex-shrink: 0; }
.card-benefit-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--benefit-text);
  line-height: 1.35;
}

/* Linhas de info */
.card-infos {
  padding: 0 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.card-info-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.card-info-row svg {
  width: 15px; height: 15px;
  flex-shrink: 0;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Rodapé do card */
.card-footer {
  padding: 10px 14px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-validity {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
}
.validity-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #4CAF50;
  flex-shrink: 0;
}

.card-detail-link {
  font-size: 14px;
  font-weight: 700;
  color: var(--app-blue);
  letter-spacing: .1px;
}

/* ── 10. TEMAS DAS CATEGORIAS ──────────────────────────────── */
/* Cada tema define --cat-color e --cat-bg para o card inteiro */
.theme-psicologia  { --cat-color: #7B1FA2; --cat-bg: #F3E5F5; }
.theme-odontologia { --cat-color: #0277BD; --cat-bg: #E1F5FE; }
.theme-laboratorio { --cat-color: #2E7D32; --cat-bg: #E8F5E9; }
.theme-saude       { --cat-color: #C62828; --cat-bg: #FFEBEE; }
.theme-imagem      { --cat-color: #E65100; --cat-bg: #FFF3E0; }
.theme-educacao    { --cat-color: #00838F; --cat-bg: #E0F7FA; }
.theme-comercio    { --cat-color: #F57F17; --cat-bg: #FFFDE7; }

.card-cat-icon    { background: var(--cat-bg, #EEE); }
.card-cat-label   { color: var(--cat-color, #555); }

/* ── 11. TELA DE DETALHE (SLIDE-UP) ────────────────────────── */
.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  pointer-events: none;
  /* Fundo escurecido */
}
.detail-overlay.open { pointer-events: all; }

.detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  opacity: 0;
  transition: opacity var(--t-slide);
}
.detail-overlay.open .detail-backdrop { opacity: 1; }

.detail-screen {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-radius: 20px 20px 0 0;
  max-height: 93dvh;
  max-height: 93vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform var(--t-slide);
  box-shadow: 0 -4px 24px rgba(0,0,0,.18);
}
.detail-overlay.open .detail-screen { transform: translateY(0); }

/* Alça de arrastar */
.detail-handle {
  width: 40px; height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
}

/* Header do detalhe */
.detail-header {
  padding: 12px 16px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.detail-header-icon {
  width: 50px; height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
  background: var(--cat-bg, #EEE);
}

.detail-header-text { flex: 1; min-width: 0; }
.detail-cat {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--cat-color, #555);
  margin-bottom: 2px;
}
.detail-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.detail-close {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--bg-page);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
  color: var(--text-secondary);
  transition: background var(--t);
}
.detail-close:active { background: var(--border); }

/* Abas internas do detalhe */
.detail-tabs-wrap {
  border-bottom: 1px solid var(--border);
  margin-top: 12px;
  flex-shrink: 0;
}
.detail-tabs {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 12px;
}
.detail-tabs::-webkit-scrollbar { display: none; }

.detail-tab {
  padding: 0 14px;
  height: 40px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2.5px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color var(--t), border-color var(--t);
}
.detail-tab.active {
  color: var(--app-blue);
  border-bottom-color: var(--app-blue);
  font-weight: 700;
}

/* Corpo do detalhe */
.detail-body {
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(env(safe-area-inset-bottom, 0px) + 20px);
}
.detail-body::-webkit-scrollbar { width: 3px; }
.detail-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

/* Seções dentro do detalhe */
.detail-section { margin-bottom: 20px; }

.section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

/* Benefício destacado */
.benefit-box {
  background: var(--benefit-bg);
  border: 1px solid var(--benefit-border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}
.benefit-big-icon { font-size: 32px; flex-shrink: 0; }
.benefit-box-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #A07800;
  margin-bottom: 4px;
}
.benefit-box-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--benefit-text);
  line-height: 1.4;
}

/* Linha de info (ícone + label + valor) */
.info-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.info-row:last-child { border-bottom: none; }

.info-row-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--bg-page);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.info-row-icon svg { width: 18px; height: 18px; color: var(--app-blue); }

.info-row-content { flex: 1; min-width: 0; }
.info-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.info-value {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  word-break: break-word;
}

/* Tags de serviços */
.tags-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  background: var(--bg-page);
  border: 1px solid var(--border-strong);
  border-radius: var(--chip-radius);
  padding: 4px 11px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* Vigência */
.validity-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #E8F5E9;
  border: 1px solid #A5D6A7;
  color: #2E7D32;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--chip-radius);
}
.validity-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: #4CAF50; }

/* Obs */
.obs-box {
  background: #FFF8E1;
  border-left: 3px solid var(--app-yellow-dark);
  border-radius: 0 8px 8px 0;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* ── 12. BOTTOM NAVIGATION ─────────────────────────────────── */
.bottom-nav {
  height: var(--bottom-nav-h);
  background: var(--app-cyan);
  display: flex;
  align-items: center;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  /* iOS safe area */
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -2px 8px rgba(0,0,0,.18);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  color: rgba(255,255,255,.8);
  transition: color var(--t);
}
.nav-item.active { color: var(--app-yellow); }

.nav-item svg { width: 22px; height: 22px; }

.nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 72px;
  text-align: center;
}

/* ── 13. ESTADO VAZIO ──────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 24px;
  text-align: center;
  color: var(--text-muted);
}
.empty-icon { font-size: 56px; margin-bottom: 16px; }
.empty-title { font-size: 17px; font-weight: 700; color: var(--text-secondary); margin-bottom: 6px; }
.empty-sub   { font-size: 14px; line-height: 1.5; }

/* ── 14. UTILITÁRIOS ───────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}

/* Evita que o body role quando o modal está aberto */
body.modal-open { overflow: hidden; }
