/* ==========================================================================
   Cadastro de Clientes - Estilo Integrado e Simplificado
   Segue rigorosamente a identidade visual padrão do sistema (style.css)
   ========================================================================== */

.clientes-page-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  background-color: #161717;
  color: #f4f4f5;
  padding: 30px;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  .clientes-page-container {
    padding: 20px 15px;
  }
}

/* Header */
.clientes-header {
  margin-bottom: 20px;
}

.clientes-title-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}

.clientes-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Indicador de Conexão com o Banco */
.db-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #18181b;
  border: 1px solid #3f3f46;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  color: #a1a1aa;
  letter-spacing: 0.3px;
  user-select: none;
}

.db-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #71717a;
  flex-shrink: 0;
}

.db-status-badge.online .db-status-dot {
  background-color: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}

.db-status-badge.online {
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.08);
}

.db-status-badge.offline .db-status-dot {
  background-color: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

.db-status-badge.offline {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

.clientes-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Botões Globais */
.btn-primary {
  background: #B90200;
  color: #ffffff;
  border: none;
  padding: 10px 18px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: #D60300;
}


.btn-danger {
  background: #27272a;
  color: #ef4444;
  border: 1px solid #3f3f46;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, color 0.2s;
}

.btn-danger:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}

/* Tabela e Card */
.table-card {
  background: #18181b;
  border: 1px solid #27272a;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#tableWrapper {
  overflow-y: auto;
  overflow-x: auto;
  max-height: calc(100vh - 180px);
}

.clientes-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.clientes-table th {
  background: #202024;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  color: #a1a1aa;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid #27272a;
  position: sticky;
  top: 0;
  z-index: 2;
}

.clientes-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #27272a;
  font-size: 13px;
  vertical-align: middle;
}

.clientes-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.clientes-table tr:last-child td {
  border-bottom: none;
}

/* Célula de Informações do Cliente */
.client-info-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.client-avatar {
  display: none !important;
}

.client-name-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.client-name {
  font-weight: 600;
  color: #f4f4f5;
  font-size: 13px;
}

.client-apelido-tag {
  font-size: 11px;
  color: #a1a1aa;
  background: #27272a;
  border: 1px solid #3f3f46;
  padding: 1px 6px;
  border-radius: 4px;
}

.client-address-text {
  color: #a1a1aa;
  font-size: 13px;
  line-height: 1.4;
}

/* Comprovante & Validade */
.comprovante-cell-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.badge-comprovante {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  width: fit-content;
  text-decoration: none;
  border: 1px solid #3f3f46;
  background: #27272a;
  color: #f4f4f5;
  cursor: pointer;
  font-family: inherit;
}

.badge-comprovante.has-file {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.3);
  background: rgba(74, 222, 128, 0.08);
}

.badge-comprovante.has-file:hover {
  background: rgba(74, 222, 128, 0.15);
}

.badge-comprovante.has-file.valido {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.3);
  background: rgba(74, 222, 128, 0.08);
}

.badge-comprovante.has-file.valido:hover {
  background: rgba(74, 222, 128, 0.15);
}

.badge-comprovante.has-file.atencao {
  color: #facc15;
  border-color: rgba(250, 204, 21, 0.3);
  background: rgba(250, 204, 21, 0.08);
}

.badge-comprovante.has-file.atencao:hover {
  background: rgba(250, 204, 21, 0.15);
}

.badge-comprovante.has-file.vencido {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.08);
}

.badge-comprovante.has-file.vencido:hover {
  background: rgba(239, 68, 68, 0.15);
}

.badge-comprovante.has-file.sem-ref {
  color: #a1a1aa;
  border-color: rgba(161, 161, 170, 0.3);
  background: rgba(161, 161, 170, 0.08);
}

.badge-comprovante.has-file.sem-ref:hover {
  background: rgba(161, 161, 170, 0.15);
}

.badge-comprovante.no-file {
  color: #71717a;
  border-color: #27272a;
  background: transparent;
  cursor: default;
}

.badge-validade {
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-validade .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
}

.badge-validade.valido { color: #4ade80; }
.badge-validade.atencao { color: #facc15; }
.badge-validade.vencido { color: #ef4444; }
.badge-validade.sem-ref { color: #71717a; }

.comprovante-ref-text {
  font-size: 11px;
  color: #71717a;
}

/* Ações */
.action-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-icon {
  background: #27272a;
  border: 1px solid #3f3f46;
  color: #a1a1aa;
  width: 30px;
  height: 30px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: #3f3f46;
  color: #ffffff;
}

.btn-icon.danger:hover {
  background: #ef4444;
  border-color: #ef4444;
  color: #ffffff;
}

/* Estados de Vazio / Carregando */
.state-container {
  padding: 40px 20px;
  text-align: center;
  color: #a1a1aa;
}

.state-container h3 {
  color: #f4f4f5;
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 14px 0;
}

.state-container svg {
  width: 40px;
  height: 40px;
  color: #52525b;
  margin-bottom: 12px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid #3f3f46;
  border-top-color: #B90200;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 10px auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Modal */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 20px;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: all;
}

.modal-content {
  background: #18181b;
  border: 1px solid #3f3f46;
  border-radius: 6px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.modal-content form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #27272a;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  background: #18181b;
}

.modal-header h2 {
  margin: 0;
  font-size: 14px;
  color: #ffffff;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.modal-close {
  background: transparent !important;
  border: none !important;
  color: #a1a1aa !important;
  font-size: 20px !important;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px !important;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
  flex: none !important;
  min-width: auto !important;
}

.modal-close:hover {
  color: #ffffff !important;
  background: #27272a !important;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  background: #18181b;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid #27272a;
  display: flex;
  gap: 8px;
  background: #18181b;
  flex-shrink: 0;
}

/* Upload Dropzone */
.upload-dropzone {
  border: 1px dashed #3f3f46;
  border-radius: 6px;
  padding: 14px;
  text-align: center;
  cursor: pointer;
  background: #27272a;
  transition: border-color 0.2s, background 0.2s;
}

.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: #B90200;
  background: #323238;
}

.upload-dropzone input[type="file"] {
  display: none;
}

.upload-text {
  font-size: 13px;
  color: #a1a1aa;
}

.upload-dropzone:hover .upload-text {
  color: #ffffff;
}

.file-attached-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #27272a;
  border: 1px solid #3f3f46;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 10px;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #f4f4f5;
  word-break: break-all;
}

.file-info svg {
  width: 18px;
  height: 18px;
  color: #B90200;
  flex-shrink: 0;
}

/* PDF Preview Frame */
.pdf-preview-frame {
  width: 100%;
  height: 70vh;
  border: none;
  background: #27272a;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10000;
  pointer-events: none;
}

.toast {
  pointer-events: all;
  background: #18181b;
  border: 1px solid #3f3f46;
  border-radius: 6px;
  padding: 10px 16px;
  color: #f4f4f5;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transform: translateY(10px);
  opacity: 0;
  transition: all 0.2s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success { border-left: 3px solid #10b981; }
.toast.error { border-left: 3px solid #ef4444; }
