/*
 * override.css — Meu Gestor
 * ============================================================
 * Carregado DEPOIS de style.css, portanto tem prioridade.
 * Contém ajustes finos de layout, componentes e tema.
 *
 * ÍNDICE:
 *  1. Sidebar desktop
 *  2. App principal (#telaPrincipal, header, conteúdo)
 *  3. Overlay do nav mobile
 *  4. Chip de plano e validade
 *  5. Tela de Login (background, card, mockups iPhone)
 *  6. Formulário de cliente (mobile)
 *  7. Novo Empréstimo (desktop)
 *  8. Cards de empréstimos/clientes (.cards-grade, .card-item)
 *  9. Modal de gerenciamento (.mg-modal-box, .mg-btn)
 * 10. Responsivo Mobile (≤ 800px) — sidebar, header, nav
 * 11. Responsivo Mobile — botões de ação da tabela
 * 12. Responsivo Desktop (≥ 801px) — planos grid
 * 13. Dark mode ajustes
 * ============================================================
 */


/* ============================================================
   1. SIDEBAR DESKTOP
   ============================================================ */
nav {
  position: fixed;
  top: 0; left: 0;
  width: var(--nav-width, 240px);
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: linear-gradient(180deg, #0f172a 0%, #1a2f6e 100%) !important;
  color: var(--nav-text);
  padding-top: 0;
  padding-bottom: 80px;
  z-index: 1000;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform .3s ease;
}

nav button {
  all: unset;
  cursor: pointer;
  color: rgba(255,255,255,.75);
  width: 100%;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background .2s, color .2s;
  box-sizing: border-box;
  position: relative;
  font-family: 'Inter', sans-serif;
  border-radius: 0;
}

nav button:hover {
  background: rgba(255,255,255,.07) !important;
  color: #fff !important;
}

nav button.active {
  background: rgba(96,165,250,.18) !important;
  border-left: 3px solid #60a5fa !important;
  color: #fff !important;
}

/* Badge de avisos no menu */
nav .badge {
  position: absolute;
  right: 14px; top: 50%;
  transform: translateY(-50%);
  min-width: 18px; height: 18px;
  padding: 0 4px;
  background: #ef4444; color: #fff;
  border-radius: 999px;
  font-size: 11px; font-weight: 700; line-height: 18px;
  display: none; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px var(--nav-bg);
  pointer-events: none;
  z-index: 1;
}
nav .badge.show { display: inline-flex; }

/* Logo no rodapé do menu */
nav .nav-logo {
  position: absolute !important;
  left: 16px !important; bottom: 16px !important;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 0 !important; margin: 0 !important;
  background: none !important; box-shadow: none !important;
  width: auto !important; transform: none !important;
  justify-content: flex-start !important;
}
nav .nav-logo img {
  width: 28px !important; height: 28px !important;
  max-width: none !important; border-radius: 8px !important;
  object-fit: cover !important; margin: 0 !important;
}
.nav-logo-text {
  font-size: 13px !important; font-weight: 700 !important;
  color: rgba(255,255,255,.7) !important;
  white-space: nowrap !important;
}


/* ============================================================
   2. APP PRINCIPAL
   ============================================================ */
#telaPrincipal {
  margin-left: var(--nav-width, 240px);
}

#telaPrincipal > header {
  height: 64px !important;
  padding: 0 20px !important;
  align-items: center !important;
  border-radius: 0 0 14px 14px !important;
  margin: 0 !important;
  right: 0 !important;
}

#telaPrincipal > header .titulo-app img {
  height: 48px !important;
  width: auto !important;
}

/* Área de conteúdo */
.conteudo {
  margin-top: 24px !important;
}

#conteudo {
  margin-top: 90px !important;
}


/* ============================================================
   3. OVERLAY DO NAV MOBILE
   ============================================================ */
#navOverlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 999;
  backdrop-filter: blur(2px);
}
#navOverlay.show { display: block; }


/* ============================================================
   4. CHIP DE PLANO E VALIDADE
   ============================================================ */
#usuarioTopo {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.chip-validade {
  font-size: 11px;
  color: rgba(255,255,255,.75);
  margin-left: 6px;
}


/* ============================================================
   5. TELA DE LOGIN
   ============================================================ */

/* Background com gradiente e animações decorativas */
.login-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #1d4ed8 100%);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

/* Brilho decorativo superior direito */
.login-bg::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(59,130,246,.3) 0%, transparent 70%);
  top: -100px; right: -100px;
  border-radius: 50%;
  animation: pulseLogin 6s ease-in-out infinite;
}

/* Brilho decorativo inferior esquerdo */
.login-bg::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(99,102,241,.2) 0%, transparent 70%);
  bottom: -80px; left: -80px;
  border-radius: 50%;
  animation: pulseLogin 8s ease-in-out infinite reverse;
}

@keyframes pulseLogin {
  0%,100% { transform: scale(1); opacity: .6; }
  50%      { transform: scale(1.15); opacity: 1; }
}

/* Card de login com glassmorphism */
.card-login {
  max-width: 420px !important;
  width: 100% !important;
  margin: 0 !important;
  position: relative;
  z-index: 2;
  backdrop-filter: blur(16px);
  background: rgba(255,255,255,.97) !important;
  border: 1px solid rgba(255,255,255,.3);
  box-shadow: 0 24px 64px rgba(0,0,0,.35) !important;
}

/* Grid de vantagens no card de login */
.login-vantagens {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.login-vant-item {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-align: left;
}

/* Mini cards de planos na tela de login */
.login-planos {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 8px;
  margin-top: 14px;
}
.login-plano {
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
  position: relative;
}
.login-plano.destaque { border-color: #1e3a8a; background: #eff6ff; }
.login-plano.anual    { border-color: #f59e0b; background: #fffbeb; }

.login-plano-badge  { font-size: 9px; font-weight: 700; color: #1e3a8a; margin-bottom: 4px; }
.login-plano.anual .login-plano-badge { color: #d97706; }
.login-plano-nome   { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.login-plano-preco  { font-size: 18px; font-weight: 800; color: var(--primary); margin: 2px 0; }
.login-plano.anual .login-plano-preco { color: #d97706; }
.login-plano-desc   { font-size: 10px; color: var(--text-muted); }

/* Mockups iPhone decorativos (visíveis só no desktop) */
.iphone-mock {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  width: 200px;
  background: #1a1a2e;
  border-radius: 36px;
  padding: 12px;
  box-shadow: 0 30px 80px rgba(0,0,0,.5), inset 0 0 0 1px rgba(255,255,255,.1);
  z-index: 1;
  opacity: .85;
}
.mock-esq { left: 4%;  transform: translateY(-50%) rotate(-6deg); }
.mock-dir { right: 4%; transform: translateY(-50%) rotate(6deg);  }

.iphone-screen {
  background: #f8fafc;
  border-radius: 26px;
  overflow: hidden;
  min-height: 380px;
  padding-bottom: 8px;
}
.iphone-bar {
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px 4px;
}
.iphone-dot    { width: 8px; height: 8px; background: #1a1a2e; border-radius: 50%; opacity: 0; }
.iphone-island { width: 60px; height: 14px; background: #1a1a2e; border-radius: 10px; }

.mock-header  { background: #1e3a8a; color: #fff; font-size: 11px; font-weight: 700; padding: 8px 12px; margin-bottom: 8px; }
.mock-cards   { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 0 8px 6px; }
.mock-card    { border-radius: 10px; padding: 8px 6px; font-size: 10px; text-align: center; font-weight: 600; line-height: 1.5; }
.mock-card span  { font-size: 13px; font-weight: 800; display: block; }
.mock-card small { font-size: 9px; opacity: .8; }
.mock-card.blue   { background: #dbeafe; color: #1e40af; }
.mock-card.green  { background: #dcfce7; color: #166534; }
.mock-card.orange { background: #fef3c7; color: #92400e; }

.mock-card-full { margin: 0 8px 6px; border-radius: 10px; padding: 7px 10px; font-size: 10px; font-weight: 600; }
.mock-card-full.orange { background: #fef3c7; color: #92400e; }
.mock-card-full.blue   { background: #dbeafe; color: #1e40af; }
.mock-card-full.green  { background: #dcfce7; color: #166534; }

.mock-list-title { font-size: 10px; font-weight: 700; color: #475569; padding: 4px 10px; }
.mock-list-item  { display: flex; align-items: center; justify-content: space-between; font-size: 10px; padding: 5px 10px; border-bottom: 1px solid #f1f5f9; color: #334155; }

.mock-badge       { font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 999px; }
.mock-badge.green { background: #dcfce7; color: #166534; }
.mock-badge.red   { background: #fee2e2; color: #991b1b; }
.mock-badge.blue  { background: #dbeafe; color: #1e40af; }

.mock-search     { margin: 0 8px 8px; background: #f1f5f9; border-radius: 8px; padding: 6px 10px; font-size: 10px; color: #94a3b8; }
.mock-bottom-bar { display: flex; justify-content: space-around; padding: 8px 10px 4px; border-top: 1px solid #e2e8f0; font-size: 14px; margin-top: 8px; }

/* Oculta mockups no mobile */
@media (max-width: 900px) {
  .iphone-mock { display: none !important; }
}


/* ============================================================
   6. FORMULÁRIO DE CLIENTE (mobile)
   Unificado: remove duplicata anterior
   ============================================================ */
@media (max-width: 800px) {
  #formCliente {
    width: 100% !important;
    padding: 0 !important;
  }
  #formCliente .ui-form {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 0 16px 0 !important;
    box-sizing: border-box !important;
    border-radius: 12px !important;
    padding: 20px 16px !important;
  }
  #formCliente .ui-grid-2 {
    grid-template-columns: 1fr !important;
    width: 100% !important;
  }
  #formCliente input {
    width: 100% !important;
    box-sizing: border-box !important;
  }
  #formCliente .ui-actions {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    grid-column: 1 / -1 !important;
  }
  #formCliente .btn-cancelar,
  #formCliente .btn-salvar {
    width: 100% !important;
    padding: 14px !important;
    font-size: 15px !important;
    text-align: center !important;
  }
}


/* ============================================================
   7. NOVO EMPRÉSTIMO (desktop)
   ============================================================ */
@media (min-width: 801px) {
  .novo-emp {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 20px;
  }
  .novo-emp .calc-modo {
    display: inline-flex;
    background: #fff !important;
  }
  .novo-emp h2 {
    margin-bottom: 20px !important;
  }
}

/* Calc modo fundo branco (todos os tamanhos) */
.novo-emp .calc-modo {
  background: #fff !important;
}


/* ============================================================
   8. CARDS DE EMPRÉSTIMOS / CLIENTES
   ============================================================ */

/* Grid responsivo: 1 coluna mobile, múltiplas no desktop */
.cards-grade {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 801px) {
  .cards-grade {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

/* Card individual */
.card-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-top: 3px solid var(--primary);
  border-radius: 16px;
  padding: 10px 12px;
  position: relative;
  overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.card-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
}

/* Avatar circular com inicial do nome */
.card-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #fff;
  margin-bottom: 6px;
}

/* Textos do card */
.card-nome  { font-size: 13px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px; }
.card-sub   { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.card-valor { font-size: 19px; font-weight: 900; color: var(--text); margin-bottom: 2px; }
.card-info  { font-size: 11px; color: var(--text-muted); margin-bottom: 3px; }

/* Badges coloridos de status */
.card-cli-badge {
  display: inline-block; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 20px;
  margin-right: 4px; margin-bottom: 4px;
}

/* Botões de ação do card */
.card-btns { display: flex; gap: 6px; margin-top: 8px; }
.card-btn  {
  flex: 1; padding: 6px 4px; border-radius: 8px; border: none;
  font-size: 11px; font-weight: 700; cursor: pointer;
  font-family: inherit; display: flex; align-items: center;
  justify-content: center; gap: 4px;
}


/* ============================================================
   9. MODAL DE GERENCIAMENTO
   Aparece como bottom sheet (desliza de baixo para cima)
   ============================================================ */
#mgModal {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.55); z-index: 2000;
  align-items: flex-end; justify-content: center;
  backdrop-filter: blur(2px);
}
#mgModal.show { display: flex; }

/* Caixa do modal */
.mg-modal-box {
  background: var(--card-bg); border-radius: 20px 20px 0 0;
  width: 100%; max-width: 560px; max-height: 88vh;
  display: flex; flex-direction: column;
  animation: mgSlideUp .25s ease;
}
@keyframes mgSlideUp {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* Alça de arrasto */
.mg-modal-handle {
  width: 40px; height: 4px; background: var(--border);
  border-radius: 2px; margin: 12px auto 16px;
  flex-shrink: 0;
}

/* Corpo com scroll */
.mg-modal-body {
  flex: 1; overflow-y: auto;
  padding: 0 16px 8px;
}

.mg-modal-titulo { font-size: 17px; font-weight: 800; color: var(--text); margin-bottom: 16px; }

/* Seções e linhas de dados */
.mg-secao-label {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-muted);
  margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.mg-linha {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 0; border-bottom: 1px solid var(--border);
  font-size: 13px; gap: 8px;
}
.mg-linha:last-child { border-bottom: none; }
.mg-linha .lbl { color: var(--text-muted); flex-shrink: 0; }
.mg-linha .val { font-weight: 600; text-align: right; color: var(--text); }
.mg-linha .val.verde    { color: #16a34a; font-weight: 700; }
.mg-linha .val.vermelho { color: #dc2626; font-weight: 800; }
.mg-linha .val.grande   { font-size: 17px; font-weight: 800; }

/* Botões de ação do modal — grid 2 colunas, fixos no rodapé */
.mg-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 10px 16px 80px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--card-bg);
}
.mg-btn {
  min-width: unset; padding: 10px 6px;
  border-radius: 9px; border: none;
  font-size: 12px; font-weight: 700; cursor: pointer;
  font-family: inherit; text-align: center;
}
/* Último botão ímpar ocupa linha inteira */
.mg-btns .mg-btn:last-child:nth-child(odd) { grid-column: 1 / -1; }

/* Variantes de cor dos botões do modal */
.mg-btn.verde    { background: #16a34a; color: #fff; }
.mg-btn.amarelo  { background: #d97706; color: #fff; }
.mg-btn.roxo     { background: #7c3aed; color: #fff; }
.mg-btn.vermelho { background: #dc2626; color: #fff; }
.mg-btn.indigo   { background: #6366f1; color: #fff; }
.mg-btn.cinza    { background: var(--border); color: var(--text); }
.mg-btn.azul     { background: var(--primary); color: #fff; }


/* ============================================================
   10. RESPONSIVO MOBILE (≤ 800px) — Sidebar, header, nav
   ============================================================ */
@media (max-width: 800px) {

  /* Sidebar desliza para fora à esquerda */
  nav {
    transform: translateX(-100%) !important;
    z-index: 1001 !important;
    padding-top: 70px !important;
    box-shadow: 4px 0 24px rgba(0,0,0,.2);
  }
  nav.nav-aberta { transform: translateX(0) !important; }

  /* Remove margem da sidebar */
  #telaPrincipal { margin-left: 0 !important; }

  /* Header ocupa tela toda */
  #telaPrincipal > header {
    left: 0px !important;
    right: 0px !important;
    border-radius: 0px !important;
    padding: 35px 14px !important;
    margin: 0px !important;
    }

  /* Botão hamburguer visível */
  #btnMenuToggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
  }

  /* Conteúdo com padding para barra inferior */
  .conteudo { padding-bottom: 90px !important; }

  /* Chip de validade em bloco */
  .chip-validade {
    display: block;
    margin-left: 0;
    font-size: 10px;
    color: var(--text-muted);
  }

  /* Logo rodapé — sem texto */
  nav .nav-logo      { left: 12px !important; bottom: 12px !important; }
  .nav-logo-text     { display: none !important; }
}


/* ============================================================
   11. RESPONSIVO MOBILE — Botões de ação da tabela
   ============================================================ */
@media (max-width: 800px) {
  .table-acoes-fixas { width: 70px !important; }

  .td-fixo {
    flex-direction: column !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 10px 6px !important;
  }

  /* Botões de gerenciar e editar — tamanho padrão quadrado */
  .btn-gerenciar,
  .btn-editar {
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    border-radius: 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Gerenciar: azul, sem texto, ícone via ::after */
  .btn-gerenciar {
    background: #3b82f6 !important;
    font-size: 0 !important;
  }
  .btn-gerenciar::after { content: "⚙️"; font-size: 18px; }

  /* Editar: amarelo com ícone */
  .btn-editar { font-size: 18px !important; }
}


/* ============================================================
   12. RESPONSIVO DESKTOP (≥ 801px)
   ============================================================ */

/* Grid de planos: 3 colunas no desktop, 1 no mobile */
.planos-grid-resp { grid-template-columns: repeat(3,1fr) !important; }
@media (max-width: 800px) {
  .planos-grid-resp { grid-template-columns: 1fr !important; }
}


/* ============================================================
   13. DARK MODE AJUSTES
   ============================================================ */
body.dark-mode nav .nav-logo-text {
  color: rgba(255,255,255,.5) !important;
}

/* Sidebar dark — mais profundo */
body.dark-mode nav {
  background: linear-gradient(180deg, #080d14 0%, #0f1a3a 100%) !important;
}

/* Barra inferior dark — glassmorphism escuro */
body.dark-mode #barraInferior {
  background: rgba(17,24,39,0.94) !important;
  border-top: 1px solid rgba(59,130,246,.15) !important;
  box-shadow: 0 -1px 0 rgba(59,130,246,.1), 0 -8px 24px rgba(0,0,0,.3) !important;
}
body.dark-mode #barraInferior button {
  color: #4b5563 !important;
}
body.dark-mode #barraInferior button.active {
  color: #60a5fa !important;
}

/* Header dark */
body.dark-mode header {
  background: linear-gradient(135deg, #080d14, #0f1a3a) !important;
  border-bottom: 1px solid rgba(255,255,255,.06) !important;
}
