/* Kelltech ERP — CSS Unificado */

:root {
  --sidebar-w:     220px;
  --bg-body:       #0d1c2e;
  --bg-sidebar:    #0a1624;
  --bg-card:       rgba(255,255,255,0.04);
  --border:        rgba(255,255,255,0.08);
  --accent:        #1a6fc4;
  --accent-hover:  #2589e8;
  --accent-light:  rgba(26,111,196,0.15);
  --text-primary:  #e8edf2;
  --text-muted:    #7d9ab5;
  --text-sidebar:  #a8c0d6;
  --danger:        #c0392b;
  --success:       #27ae60;
  --warning:       #e67e22;
  --radius:        10px;
  --shadow:        0 4px 24px rgba(0,0,0,0.35);
  --font:          "Inter", system-ui, -apple-system, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg-body);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── Layout principal ─────────────────────────────────────────────── */

.erp-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar__brand {
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
}

.sidebar__brand img {
  max-width: 180px;
  height: auto;
  display: block;
}

.sidebar__brand-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.sidebar__brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.sidebar__nav {
  padding: 12px 0;
  flex: 1;
}

.nav-group__label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 16px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-sidebar);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
}

.nav-item.ativo {
  background: var(--accent-light);
  color: #fff;
  border-left: 3px solid var(--accent);
  padding-left: 17px;
}

.nav-item__icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar__footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.sidebar__user {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.sidebar__user strong {
  display: block;
  color: var(--text-primary);
  font-size: 13px;
}

/* ── Área principal ───────────────────────────────────────────────── */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: 52px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  flex-shrink: 0;
}

.topbar__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.topbar__tag {
  font-size: 11px;
  background: var(--accent-light);
  color: var(--accent-hover);
  border: 1px solid rgba(26,111,196,0.3);
  border-radius: 20px;
  padding: 2px 10px;
  font-weight: 600;
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

/* ── Cards ────────────────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  backdrop-filter: blur(6px);
}

.card--stat {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.card__value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.card__sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Grid de stats ────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

/* ── Tabelas ──────────────────────────────────────────────────────── */

.tabela-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: rgba(0,0,0,0.15);
}

tr:hover td { background: rgba(255,255,255,0.025); }

/* ── Botões ───────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  font-family: var(--font);
}

.btn:active { transform: scale(0.98); }

.btn--primary {
  background: var(--accent);
  color: #fff;
}
.btn--primary:hover { background: var(--accent-hover); }

.btn--secondary {
  background: rgba(255,255,255,0.07);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn--secondary:hover { background: rgba(255,255,255,0.12); }

.btn--danger {
  background: var(--danger);
  color: #fff;
}

.btn--sm {
  padding: 5px 12px;
  font-size: 12px;
}

/* ── Formulários ──────────────────────────────────────────────────── */

.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="date"],
select,
textarea {
  width: 100%;
  background: #0d1e30;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-primary);
  padding: 9px 13px;
  font-size: 13px;
  font-family: var(--font);
  transition: border-color 0.15s;
  outline: none;
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237d9ab5' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

select option {
  background: #0d1e30;
  color: var(--text-primary);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

/* ── Badges ───────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge--green  { background: rgba(39,174,96,0.18);  color: #2ecc71; }
.badge--blue   { background: rgba(26,111,196,0.18); color: #5dade2; }
.badge--orange { background: rgba(230,126,34,0.18); color: #f39c12; }
.badge--red    { background: rgba(192,57,43,0.18);  color: #e74c3c; }
.badge--gray   { background: rgba(255,255,255,0.08); color: var(--text-muted); }

/* ── Alerts ───────────────────────────────────────────────────────── */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
}

.alert--erro    { background: rgba(192,57,43,0.15); border: 1px solid rgba(192,57,43,0.3); color: #e74c3c; }
.alert--sucesso { background: rgba(39,174,96,0.15); border: 1px solid rgba(39,174,96,0.3); color: #2ecc71; }
.alert--info    { background: rgba(26,111,196,0.15); border: 1px solid rgba(26,111,196,0.3); color: #5dade2; }

/* ── Página de login ──────────────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  position: relative;
  overflow: hidden;
  background: #070f22; /* fallback enquanto imagem carrega */
  background-image:
    /* vinheta lateral */
    radial-gradient(ellipse 120% 100% at 50% 50%, transparent 38%, rgba(4,12,30,0.62) 100%),
    /* faixas escuras topo e rodapé */
    linear-gradient(180deg,
      rgba(4,12,30,0.80) 0%,
      rgba(4,12,30,0.22) 28%,
      rgba(4,12,30,0.14) 52%,
      rgba(4,12,30,0.38) 78%,
      rgba(4,12,30,0.80) 100%),
    /* brilho azul Kelltech no centro */
    radial-gradient(ellipse 80% 55% at 50% 52%, rgba(23,61,134,0.28) 0%, transparent 70%);
}

/* montanha de fundo — filtro só aplica à imagem */
.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('../img/bg.jpg') center center / cover no-repeat;
  transform: scale(1.06);
  filter: saturate(0.55) brightness(0.72) contrast(1.08);
  z-index: 0;
}

/* garantir que card e qualquer filho fiquem acima da imagem */
.login-page > * {
  position: relative;
  z-index: 1;
}

.login-card {
  width: min(420px, 96vw);
  background: rgba(10, 22, 44, 0.75);
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 18px;
  padding: 40px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 24px 60px rgba(0,0,0,0.55), 0 1px 0 rgba(255,255,255,0.08) inset;
}

.login-card__logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-card__logo img {
  max-width: 160px;
  height: auto;
}

.login-card__logo-text {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.login-card h1 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-card p {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 24px;
}

.btn--full { width: 100%; justify-content: center; }

/* ── Utilitários ──────────────────────────────────────────────────── */

.mt-4  { margin-top: 16px; }
.mt-8  { margin-top: 32px; }
.mb-4  { margin-bottom: 16px; }
.mb-8  { margin-bottom: 32px; }
.flex  { display: flex; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }

/* ── Responsive ───────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Modal de confirmação / alerta (KModal) ───────────────────────── */

.k-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 18, 32, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: k-fade-in .13s ease;
}

.k-modal {
  background: #112035;
  border: 1px solid rgba(255,255,255,.1);
  border-top: 3px solid var(--accent);
  border-radius: 12px;
  width: 440px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 16px 56px rgba(0,0,0,.6);
  animation: k-slide-up .15s ease;
  overflow: hidden;
}

.k-modal--danger { border-top-color: var(--danger); }

.k-modal__header {
  padding: 1.1rem 1.4rem .8rem;
  display: flex;
  align-items: center;
  gap: .6rem;
}

.k-modal__icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  background: var(--accent-light);
  color: var(--accent);
}

.k-modal--danger .k-modal__icon {
  background: rgba(192,57,43,.15);
  color: #e74c3c;
}

.k-modal__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.k-modal__body {
  padding: 0 1.4rem 1.2rem;
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.6;
}

.k-modal__footer {
  padding: .85rem 1.4rem;
  display: flex;
  gap: .6rem;
  justify-content: flex-end;
  background: rgba(255,255,255,.03);
  border-top: 1px solid var(--border);
}

/* ── Loader overlay — identidade Kelltech (KLoader) ──────────────── */

.k-loader {
  position: fixed;
  inset: 0;
  background: rgba(6, 13, 26, 0.92);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9500;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: k-fade-in .18s ease;
}

/* Área do ícone animado */
.k-loader__icon {
  position: relative;
  width: 88px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 22px;
}

/* Anel externo — gira no sentido horário */
.k-loader__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2.5px solid rgba(26,111,196,.14);
  border-top-color: var(--accent);
  animation: k-spin .95s linear infinite;
}

/* Anel interno — gira no sentido anti-horário */
.k-loader__ring2 {
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  border: 2px solid rgba(37,137,232,.11);
  border-bottom-color: rgba(37,137,232,.65);
  animation: k-spin .6s linear infinite reverse;
}

/* Círculo de fundo do K */
.k-loader__circle {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(145deg, #0c1e3d 0%, #14336a 100%);
  border: 1px solid rgba(26,111,196,.38);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 0 22px rgba(26,111,196,.22),
    inset 0 1px 0 rgba(255,255,255,.07);
  animation: k-glow 2s ease-in-out infinite;
}

/* Letra K Kelltech */
.k-loader__k {
  font-size: 21px;
  font-weight: 800;
  color: #e8edf2;
  font-family: "Inter", system-ui, sans-serif;
  letter-spacing: -0.5px;
  user-select: none;
  line-height: 1;
}

.k-loader__text {
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-family: var(--font);
  animation: k-fade-pulse 1.8s ease-in-out infinite;
}

@keyframes k-glow {
  0%, 100% {
    box-shadow: 0 0 16px rgba(26,111,196,.20), inset 0 1px 0 rgba(255,255,255,.07);
  }
  50% {
    box-shadow: 0 0 34px rgba(26,111,196,.52), inset 0 1px 0 rgba(255,255,255,.12);
  }
}

@keyframes k-fade-pulse {
  0%, 100% { opacity: .38; }
  50%       { opacity: .95; }
}

/* ── Animações ────────────────────────────────────────────────────── */

@keyframes k-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes k-slide-up {
  from { transform: translateY(14px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

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

/* Acessibilidade: foco visível no modal */
.k-modal .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
