/* ============================================================
   Cendic Solicitações — Estilos Globais (mobile-first)
   Paleta: #238ab0 (azul primário), #1e7a9e (escuro), #2f9abc (claro)
   ============================================================ */

:root {
  --primary:      #238ab0;
  --primary-dark: #1e7a9e;
  --primary-light:#2f9abc;
  --success:      #198754;
  --warning:      #fd7e14;
  --danger:       #dc3545;
  --muted:        #6c757d;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 2px 8px rgba(0,0,0,0.1);
  --shadow-lg:    0 8px 25px rgba(0,0,0,0.2);
}

/* ---- Reset / Base ----------------------------------------- */
* { box-sizing: border-box; }

input,
select,
textarea,
button {
  font-size: 16px;
}

html,
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f0f4f8;
  margin: 0;
  padding: 0;
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y;
  overscroll-behavior-y: none;
  overscroll-behavior-x: none;
}

a { color: var(--primary); }

/* ---- Gradiente de fundo (login, splash) ------------------- */
.bg-gradient-primary {
  background: linear-gradient(135deg, #a6c0cd 0%, #238ab0 50%, #1e7a9e 100%);
  min-height: 100vh;
}

/* ---- Navbar ----------------------------------------------- */
.navbar-cendic {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.navbar-cendic .brand {
  color: white;
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.navbar-cendic .nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.navbar-cendic .btn-nav {
  background: rgba(255,255,255,0.2);
  border: none;
  border-radius: 8px;
  color: white;
  padding: 6px 12px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.navbar-cendic .btn-nav:hover {
  background: rgba(255,255,255,0.35);
}

/* Chip do usuário logado na navbar */
.navbar-usuario {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,0.18);
  border-radius: 20px;
  padding: 3px 10px 3px 7px;
  font-size: 12px;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.navbar-usuario i {
  font-size: 14px;
  opacity: 0.9;
  flex-shrink: 0;
}

.badge-msg {
  background: #dc3545;
  color: white;
  border-radius: 50%;
  font-size: 10px;
  padding: 2px 5px;
  position: absolute;
  top: -4px;
  right: -4px;
}

/* ---- Cards ------------------------------------------------- */
.card {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  border-radius: var(--radius) var(--radius) 0 0 !important;
  padding: 12px 16px;
  border: none;
}

.card-header-primary h6,
.card-header-primary h5 {
  margin: 0;
  color: white;
  font-weight: 600;
}

/* ---- Stat cards (dashboard) -------------------------------- */
.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  text-align: center;
  transition: transform 0.2s;
}

.stat-card:hover { transform: translateY(-2px); }

.stat-card .stat-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* ---- Botões ----------------------------------------------- */
.btn-primary-cendic {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  width: 100%;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(35,138,176,0.3);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary-cendic:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(35,138,176,0.4);
  color: white;
}

.btn-primary-cendic:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-success-cendic {
  background: linear-gradient(135deg, #198754, #20c997);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger-cendic {
  background: linear-gradient(135deg, #dc3545, #e74c3c);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-warning-cendic {
  background: linear-gradient(135deg, #fd7e14, #ffc107);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-outline-cendic {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-outline-cendic:hover {
  background: var(--primary);
  color: white;
}

/* ---- Formulários ------------------------------------------ */
.form-group-custom { margin-bottom: 18px; }

.form-label-custom {
  font-size: 13px;
  font-weight: 600;
  color: #495057;
  margin-bottom: 6px;
  display: block;
}

.form-control-custom {
  border: 2px solid #e9ecef;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 16px;
  width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #f8f9fa;
}

.form-control-custom:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(35,138,176,0.15);
  background: white;
  outline: none;
}

.form-control-custom:read-only {
  background: #e9ecef;
  color: var(--muted);
}

.input-with-icon {
  position: relative;
}

.input-with-icon .input-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  z-index: 1;
}

.input-with-icon .form-control-custom {
  padding-left: 38px;
}

/* ---- Badges de status ------------------------------------- */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* ---- Cards de cliente (limites) --------------------------- */
.card-cliente {
  margin: 8px 4px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: none;
  overflow: hidden;
}

.card-cliente-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  padding: 12px 14px;
}

.limite-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.limite-item {
  text-align: center;
  padding: 8px 4px;
  border-radius: var(--radius-sm);
  background: #f8f9fa;
}

.limite-label {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 3px;
  text-transform: uppercase;
}

.limite-valor {
  font-size: 13px;
  font-weight: 700;
}

.valor-positivo { color: var(--success); }
.valor-negativo { color: var(--danger); }
.valor-neutro   { color: var(--primary); }

/* ---- Loading overlay -------------------------------------- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.loading-box {
  background: white;
  border-radius: var(--radius);
  padding: 32px 40px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.loading-box .spinner {
  width: 48px;
  height: 48px;
  border: 5px solid #e9ecef;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 14px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Alertas ---------------------------------------------- */
.alert-cendic {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 14px;
  border: none;
}

.alert-error   { background: #f8d7da; color: #721c24; }
.alert-success { background: #d4edda; color: #155724; }
.alert-info    { background: #d1ecf1; color: #0c5460; }
.alert-warning { background: #fff3cd; color: #856404; }

/* ---- Tabela ----------------------------------------------- */
.table-cendic {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table-cendic th {
  background: var(--primary);
  color: white;
  padding: 10px 8px;
  text-align: left;
  font-weight: 600;
}

.table-cendic td {
  padding: 9px 8px;
  border-bottom: 1px solid #e9ecef;
  vertical-align: middle;
}

.table-cendic tr:hover td { background: #f0f7fb; }

/* ---- Filtros ---------------------------------------------- */
.filtros-bar {
  background: white;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 52px;
  z-index: 900;
}

/* ---- Animações -------------------------------------------- */
.fade-in {
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.slide-up {
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(40px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Responsividade --------------------------------------- */
@media (max-width: 576px) {
  .stat-card .stat-value { font-size: 22px; }
  .table-cendic { font-size: 12px; }
}

/* ---- PWA safe area ---------------------------------------- */
.safe-top    { padding-top:    env(safe-area-inset-top, 12px); }
.safe-bottom { padding-bottom: env(safe-area-inset-bottom, 12px); }
