@import "bootstrap-icons/font/bootstrap-icons.css";

/* Variáveis baseadas na sua marca, mas modernizadas */
:root {
  --brand-primary: #E33DCF;
  --brand-hover: #c91eb5;
  --brand-soft: rgba(227, 61, 207, 0.08);
  --text-main: #0F172A; /* Slate 900 - Preto moderno */
  --text-muted: #64748B; /* Slate 500 - Cinza moderno */
  --bg-body: #F8FAFC;
  --glass-border: rgba(255, 255, 255, 0.6);
  --glass-bg: rgba(255, 255, 255, 0.7);
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
  --radius-lg: 16px;
  --font-sans: 'Inter', sans-serif;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 20% 10%, rgba(227, 61, 207, 0.1), transparent 60%),
    radial-gradient(820px 380px at 80% 30%, rgba(227, 61, 207, 0.06), transparent 60%),
    linear-gradient(180deg, #ffffff 0%, #f5f5f7 70%);
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: var(--text-main);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  /* Garante scroll da página em todo o app */
  overflow-y: auto !important; 
/* Global select styling to match LineGestao UI */
select,
select.form-select,
select.form-control {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  height: 42px;
  border-radius: 10px;
  border: 1.5px solid rgba(15, 23, 42, 0.12);
  padding: 0 36px 0 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 20 20'%3E%3Cpath fill='%2364748B' d='M5.25 7.5 10 12.25 14.75 7.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

select:focus,
select.form-select:focus,
select.form-control:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

select:disabled,
select.form-select:disabled,
select.form-control:disabled {
  background-color: #f1f5f9;
  color: var(--text-muted);
  cursor: not-allowed;
}

select.form-select-sm,
select.form-control-sm {
  height: 36px;
  font-size: 13px;
  padding-right: 32px;
  background-position: right 10px center;
}
}

/* Utilitário de animação suave */
.fade-in-up {
  animation: fadeInUp 0.6s ease-out forwards;
  opacity: 0;
  transform: translateY(20px);
}

@keyframes fadeInUp {
  to { opacity: 1; transform: translateY(0); }
}

/* Empurra o conteúdo pra baixo do header fixo */
.app-main.has-header {
  position: relative;
  padding-top: var(--app-header-offset, 76px); /* sincroniza com a altura real do header */
  background: transparent;
}

@media (max-width: 600px) {
  .app-main.has-header {
    padding-top: var(--app-header-offset, 88px);
  }
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

img,
svg,
canvas,
video {
  max-width: 100%;
  height: auto;
}

/* Ajuste para monitores grandes: elimina o "vão" visual entre header e corpo. */
@media (min-width: 1400px) {
  .app-main.has-header {
    padding-top: var(--app-header-offset, 76px);
  }
}

/* ========================================================== */
/* 🚀 GLOBAL FIX: Proporção Horizontal e Vertical */
/* ========================================================== */

/* 1. HORIZONTAL: Mantém a proporção mais "fechada" que você gostou */
.container-geral,
.container-fat,
.container-mureg,
.container-troca,
.container-geral-responsive,
.container-dashboard,
.container-chips {
    max-width: 1100px !important; /* Largura controlada */
    width: 96% !important;        /* Margem segura em telas menores */
    margin-left: auto !important;
    margin-right: auto !important;
    display: block !important;
}

/* 2. TABELAS: Remove limites de largura mínima desnecessários */
.table-modern {
    width: 100% !important;
    min-width: unset !important;
}

/* 3. VERTICAL: Libera o crescimento dos cards em todas as páginas */
.geral-card,
.fat-card,
.mureg-card,
.troca-card,
.vigencia-page .geral-card {
    height: auto !important;      /* Cresce conforme o conteúdo */
    max-height: none !important;  /* Remove limites fixos */
    min-height: 80vh;             /* Garante um tamanho mínimo bonito */
    overflow: visible !important; /* Remove scroll interno, usa o da janela */
    margin-bottom: 40px !important; /* Respiro no final */
}

/* 4. LISTAS E WRAPPERS: Destrava o crescimento interno */
.groups-container,
.table-wrap,
.table-wrap-tall,
.inner-table-wrap {
    height: auto !important;
    max-height: none !important;  /* CRÍTICO: Remove travas de pixels */
    overflow: visible !important;
}

/* 5. PÁGINAS: Garante que o scroll do navegador funcione */
.geral-page,
.users-page,
.fat-page,
.mureg-page,
.troca-page,
.historico-page,
.perfil-page,
.dashboard-page,
.chips-page,
.parcelamentos-page,
.resumo-page,
.create-user-page {
    overflow-y: auto !important;
    height: auto !important;
    display: block !important;
}

/* ========================================================== */
/*  Modal Criar Usuário (forçar estilo global)                 */
/* ========================================================== */
app-header .modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 1400;
}

app-header .modal-card {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(720px, calc(100vw - 32px));
  background: #fff;
  border-radius: 18px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
  z-index: 1450;
  display: flex;
  flex-direction: column;
}

app-header .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

app-header .modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
}

app-header .modal-body {
  padding: 18px 20px 10px;
}

app-header .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 0 20px 18px;
}

app-header .modal-card .user-form {
  display: grid;
  gap: 14px;
}

app-header .modal-card .form-field {
  display: grid;
  gap: 6px;
}

app-header .modal-card .form-field label {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
}

app-header .modal-card .form-field input,
app-header .modal-card .form-field select {
  height: 42px;
  border-radius: 10px;
  border: 1.5px solid #d7dbe6;
  padding: 0 12px;
  font-size: 14px;
  color: #0f172a;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

app-header .modal-card .form-field input:focus,
app-header .modal-card .form-field select:focus {
  outline: none;
  border-color: #2f6bff;
  box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.15);
}

app-header .modal-card .btn-primary,
app-header .modal-card .btn-secondary {
  height: 40px;
  min-width: 110px;
  border-radius: 10px;
  border: none;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

app-header .modal-card .btn-primary {
  background: #2f6bff;
  color: #fff;
  box-shadow: 0 10px 20px rgba(47, 107, 255, 0.2);
}

app-header .modal-card .btn-secondary {
  background: #e2e8f0;
  color: #0f172a;
}

app-header .modal-card .btn-primary:hover,
app-header .modal-card .btn-secondary:hover {
  transform: translateY(-1px);
}

@media (max-width: 768px) {
  app-header .modal-card {
    width: min(520px, calc(100vw - 24px));
  }

  app-header .modal-actions {
    flex-direction: column;
    align-items: stretch;
  }

  app-header .modal-card .btn-primary,
  app-header .modal-card .btn-secondary {
    width: 100%;
  }
}

/* Remove separators inside search inputs (icon / text / clear button). */
.input-group.search-group {
  > .input-group-text,
  > .form-control,
  > .btn,
  > .btn-clear {
    border: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
  }

  > :not(:first-child):not(.dropdown-menu):not(.valid-tooltip):not(.invalid-tooltip) {
    margin-left: 0 !important;
  }

  > .form-control:focus {
    box-shadow: none !important;
  }
}

/* Títulos de cliente no agrupamento: não herdar o "td-clip" das tabelas */
.client-group-card .group-header {
  gap: 12px;
}

.client-group-card .group-header .group-info {
  flex: 1 1 auto;
  min-width: 0;
}

.client-group-card .group-header .group-info > h6,
.client-group-card .group-header .group-info > h6.td-clip {
  min-width: 0;
  max-width: none !important;
  overflow: visible !important;
  text-overflow: clip !important;
  white-space: normal !important;
  word-break: normal !important;
  overflow-wrap: break-word;
  line-height: 1.25;
}

.client-group-card .group-header .group-toggle-icon {
  flex: 0 0 auto;
}

/* ========================================================== */
/*  Ajustes globais de responsividade (mobile-first)          */
/* ========================================================== */

@media (min-width: 1600px) {
  .container-geral,
  .container-fat,
  .container-mureg,
  .container-troca,
  .container-geral-responsive,
  .container-dashboard,
  .container-chips {
    max-width: 1240px !important;
  }
}

@media (min-width: 2200px) {
  .container-geral,
  .container-fat,
  .container-mureg,
  .container-troca,
  .container-geral-responsive,
  .container-dashboard,
  .container-chips {
    max-width: 1360px !important;
  }
}

@media (max-width: 1024px) {
  .container-geral,
  .container-fat,
  .container-mureg,
  .container-troca,
  .container-geral-responsive,
  .container-dashboard,
  .container-chips {
    width: min(100%, calc(100vw - 20px)) !important;
  }

  .header-actions,
  .filters-actions {
    flex-wrap: wrap;
    gap: 8px !important;
  }

  .controls,
  .filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: stretch;
  }

  .search-group,
  .input-group.search-group {
    min-width: 0;
    flex: 1 1 280px;
  }

  .page-size {
    margin-left: 0 !important;
    flex: 0 1 auto;
  }
}

@media (max-width: 768px) {
  .app-main.has-header {
    padding-top: var(--app-header-offset, 84px);
  }

  .geral-card,
  .fat-card,
  .mureg-card,
  .troca-card,
  .vigencia-page .geral-card {
    min-height: auto !important;
    margin-bottom: 20px !important;
  }

  .header-row-top {
    gap: 12px !important;
  }

  .header-actions {
    width: 100%;
    justify-content: stretch !important;
  }

  .header-actions .btn,
  .header-actions button.btn {
    flex: 1 1 220px;
  }

  .filters-head,
  .filters-meta {
    align-items: stretch !important;
  }

  .filters-actions {
    width: 100%;
    justify-content: stretch !important;
  }

  .filters-actions .btn-primary,
  .filters-actions .btn-ghost,
  .filters-actions .btn,
  .filters-actions button {
    flex: 1 1 160px;
    justify-content: center;
  }

  .filters-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .filter-tabs {
    width: 100%;
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .filter-tabs .filter-tab {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .client-filter-wrap,
  .additional-filter-wrap,
  .search-group,
  .input-group.search-group,
  .search-box,
  .page-size {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .chips-container {
    max-width: 100% !important;
  }

  .btn-client-filter {
    width: 100%;
    min-height: 40px;
    justify-content: space-between;
    gap: 8px;
  }

  .client-dropdown,
  .additional-dropdown {
    width: min(100%, calc(100vw - 24px)) !important;
    max-width: calc(100vw - 24px) !important;
    right: auto !important;
    left: 0 !important;
  }

  .controls .page-size {
    justify-content: space-between !important;
  }

  .table-wrap,
  .table-wrap-tall,
  .inner-table-wrap,
  .parcelamentos-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrap table.table-modern,
  .inner-table-wrap table.table-modern,
  .table-wrap .table-modern,
  .parcelamentos-table-wrap .table-modern,
  table.table-modern {
    width: max-content !important;
    min-width: max(100%, 920px) !important;
  }

  .table-modern thead th,
  .table-modern td {
    padding: 10px 8px !important;
  }

  .table-modern thead th {
    font-size: 0.7rem !important;
  }

  .table-modern td {
    font-size: 0.8rem !important;
  }

  .td-clip {
    max-width: 180px !important;
  }

  .actions-col {
    min-width: 120px !important;
  }

  .modal-custom,
  .lg-modal,
  .macrophony-modal,
  .grouped-modal {
    padding: 8px !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .modal-card,
  .lg-modal-card,
  .macrophony-card,
  .grouped-card {
    width: min(100%, calc(100vw - 16px)) !important;
    max-width: calc(100vw - 16px) !important;
    max-height: min(92dvh, calc(100vh - 16px)) !important;
    border-radius: 14px !important;
    min-height: 0;
  }

  .modal-header,
  .lg-modal-card .modal-header,
  .detail-head {
    padding: 12px 14px !important;
    gap: 10px;
    flex-wrap: wrap;
  }

  .modal-title,
  .lg-modal-card .modal-title {
    min-width: 0;
    flex: 1 1 auto;
  }

  .modal-header h3,
  .detail-head h4 {
    font-size: 15px !important;
    line-height: 1.3;
  }

  .modal-body,
  .modern-body,
  .lg-modal-card .modal-body,
  .macrophony-modal-body,
  .grouped-modal-body {
    padding: 14px !important;
    overflow-y: auto;
  }

  .modal-footer,
  .modal-actions,
  .lg-modal-card .modal-footer,
  .manage-actions-footer {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    justify-content: stretch !important;
    align-items: stretch !important;
  }

  .modal-footer .btn,
  .modal-footer button,
  .modal-actions .btn,
  .modal-actions button,
  .lg-modal-card .modal-footer .btn,
  .manage-actions-footer .btn,
  .manage-actions-footer button {
    flex: 1 1 180px;
    min-width: 0 !important;
    justify-content: center;
  }

  .manage-actions-footer .btn-delete-permanent-left {
    margin-right: 0 !important;
  }

  .form-grid,
  .edit-grid,
  .info-grid,
  .details-2col,
  .finance-dashboard {
    grid-template-columns: 1fr !important;
  }

  .details-dashboard {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .macrophony-summary,
  .grouped-summary-bar {
    padding: 12px 14px !important;
    gap: 12px !important;
  }

  .toast-container {
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    padding: 8px !important;
  }

  .toast-container .toast {
    width: 100% !important;
  }
}

@media (max-width: 480px) {
  .container-geral,
  .container-fat,
  .container-mureg,
  .container-troca,
  .container-geral-responsive,
  .container-dashboard,
  .container-chips {
    width: calc(100vw - 14px) !important;
  }

  .title-badge,
  .header-title .title {
    word-break: break-word;
  }

  .header-actions .btn,
  .header-actions button.btn,
  .filters-actions .btn-primary,
  .filters-actions .btn-ghost,
  .filters-actions .btn,
  .filters-actions button,
  .modal-footer .btn,
  .modal-footer button,
  .modal-actions .btn,
  .modal-actions button {
    width: 100%;
    flex-basis: 100%;
  }

  .table-wrap table.table-modern,
  .inner-table-wrap table.table-modern,
  .table-wrap .table-modern,
  .parcelamentos-table-wrap .table-modern,
  table.table-modern {
    min-width: max(100%, 820px) !important;
  }

  .td-clip {
    max-width: 140px !important;
  }
}
