/**
 * common.css — Estilos compartilhados entre mobile e admin
 * Sistema de Ordem de Serviço — v2.4.0
 * Carregar ANTES de mobile.css ou admin.css em todas as páginas
 */

/* ========== VARIÁVEIS CSS ========== */
:root {
  /* Cores principais */
  --bg: #0d1117;
  --sidebar-bg: #0a0e16;
  --card-bg: #111827;
  --primary: #00e5cc;
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --border: #1f2937;
  --banner-warning-bg: rgba(245,158,11,0.08);

  /* Cinzas extras (acessibilidade e consistência) */
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --yellow-500: #eab308;

  /* Bordas e sombras */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.6);

  /* Layout admin */
  --sidebar-width: 240px;

  /* Escala tipográfica */
  --text-xs: 10px;
  --text-sm: 12px;
  --text-base: 14px;
  --text-md: 16px;
  --text-lg: 20px;
  --text-xl: 24px;
  --text-2xl: 34px;

  /* Scrollbar */
  --scrollbar-thumb: #374151;
  --scrollbar-track: transparent;
}

/* ========== RESET E BASE ========== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: var(--text-base);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========== ACESSIBILIDADE ========== */

/* Focus visible — anel de foco acessível */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Desabilita animações/transições para usuários que preferem reduzir movimento */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Scrollbar escura customizada */
html {
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  scrollbar-width: thin;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gray-600);
}

/* ========== BADGES ========== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1;
  height: 22px;
}

.badge-critica    { background: rgba(239,68,68,0.18);   color: var(--danger); }
.badge-alta       { background: rgba(245,158,11,0.18);  color: var(--warning); }
.badge-normal     { background: rgba(0,229,204,0.18);   color: var(--primary); }
.badge-baixa      { background: rgba(107,114,128,0.18); color: #9ca3af; }
.badge-aberta     { background: rgba(0,229,204,0.18);   color: var(--primary); }
.badge-andamento  { background: rgba(245,158,11,0.18);  color: var(--warning); }
.badge-concluida  { background: rgba(34,197,94,0.18);   color: var(--success); }
.badge-cancelada  { background: rgba(107,114,128,0.18); color: #9ca3af; }

/* ========== BOTÕES ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.1s, box-shadow 0.2s;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.btn:active { transform: scale(0.97); }
.btn:hover { filter: brightness(1.08); }

.btn-primary {
  background: var(--primary);
  color: #0d1117;
  box-shadow: 0 2px 10px rgba(0,229,204,0.2);
}
.btn-primary:hover { box-shadow: 0 4px 16px rgba(0,229,204,0.35); }

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

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

.btn-secondary {
  background: var(--border);
  color: var(--text);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
}

.btn-warning {
  background: var(--warning);
  color: #0d1117;
}

.btn-sm {
  padding: 5px 11px;
  font-size: var(--text-sm);
  border-radius: 6px;
}

.btn-lg {
  padding: 16px 24px;
  font-size: 16px;
}

.btn-block { display: flex; width: 100%; }

.btn-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ========== ALERTAS / FLASH MESSAGES ========== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
  border-left: 4px solid transparent;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.4;
}

.alert-success { background: rgba(34,197,94,0.12);  border-color: var(--success); color: var(--success); }
.alert-danger  { background: rgba(239,68,68,0.12);  border-color: var(--danger);  color: var(--danger); }
.alert-warning { background: rgba(245,158,11,0.12); border-color: var(--warning); color: var(--warning); }
.alert-info    { background: rgba(0,229,204,0.12);  border-color: var(--primary); color: var(--primary); }

.alert-close {
  margin-left: auto;
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  font-size: 16px;
  padding: 0;
  line-height: 1;
  opacity: 0.7;
}
.alert-close:hover { opacity: 1; }

/* ========== FORMULÁRIOS ========== */
.form-group { margin-bottom: 16px; }

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

input, select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 13px;
  font-size: var(--text-base);
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,229,204,0.1);
}

input::placeholder, textarea::placeholder { color: var(--gray-500); }

textarea {
  min-height: 80px;
  resize: vertical;
  line-height: 1.5;
}

select option {
  background: var(--card-bg);
  color: var(--text);
}

/* ========== MODAIS ========== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: modalOverlayFadeIn 0.2s ease;
}

.modal-overlay.active { display: flex; }

@keyframes modalOverlayFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  width: 100%;
  max-width: 500px;
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: modalSlideUp 0.25s ease;
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-title {
  font-size: var(--text-md);
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 12px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.modal-close:hover {
  background: var(--border);
  color: var(--text);
}

/* ========== PAGINAÇÃO ========== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 22px;
  padding: 8px 0;
}

.pagination a, .pagination span {
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  min-width: 40px;
  text-align: center;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.pagination a:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(0,229,204,0.06);
}

.pagination .current {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(0,229,204,0.12);
}

/* ========== TOAST NOTIFICATIONS ========== */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  min-width: 280px;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toastSlideIn 0.3s ease;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: var(--text-base);
  color: var(--text);
}

.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-danger  { border-left: 3px solid var(--danger); }
.toast.toast-warning { border-left: 3px solid var(--warning); }
.toast.toast-info    { border-left: 3px solid var(--primary); }

.toast .toast-icon { flex-shrink: 0; font-size: 18px; }

.toast .toast-body { flex: 1; }

.toast .toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}

.toast .toast-close:hover { color: var(--text); }

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 52px;
  margin-bottom: 14px;
  opacity: 0.6;
}

.empty-state p {
  font-size: 15px;
  font-weight: 500;
}

/* ========== CARD BASE ========== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

/* ========== PASSWORD RULES (validação em tempo real) ========== */
.password-rules {
  list-style: none;
  padding: 8px;
  margin: 8px 0 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 6px;
  line-height: 1.6;
}
.password-rules li {
  padding: 2px 0;
}
/* Suporte a ambos os padrões de classe (trocar_senha.html e resetar_senha.html) */
.password-rules li.valid,
.password-rules li.valido {
  color: var(--success);
}
.password-rules li.invalid,
.password-rules li.invalido {
  color: var(--danger);
}

/* ========== UTILITÁRIOS ========== */
.text-primary { color: var(--primary) !important; }
.text-danger  { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-muted   { color: var(--text-muted) !important; }
.text-warning { color: var(--warning) !important; }
.text-center  { text-align: center !important; }
.text-right   { text-align: right !important; }
.text-sm      { font-size: var(--text-sm) !important; }
.text-xs      { font-size: var(--text-xs) !important; }
.text-base    { font-size: var(--text-base) !important; }
.text-bold    { font-weight: 700 !important; }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mr-1 { margin-right: 8px; }
.ml-1 { margin-left: 8px; }

.p-1  { padding: 8px; }
.p-2  { padding: 16px; }
.p-3  { padding: 24px; }

.d-flex         { display: flex !important; }
.d-inline       { display: inline !important; }
.align-center   { align-items: center !important; }
.align-start    { align-items: flex-start !important; }
.align-baseline { align-items: baseline !important; }
.justify-between { justify-content: space-between !important; }
.justify-end    { justify-content: flex-end !important; }
.justify-center { justify-content: center !important; }
.flex-wrap      { flex-wrap: wrap !important; }
.gap-0          { gap: 4px; }
.gap-1          { gap: 8px; }
.gap-2          { gap: 16px; }
.gap-3          { gap: 24px; }
.w-100          { width: 100% !important; }
.flex-1         { flex: 1 !important; }
.text-left      { text-align: left; }

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ========== AVATAR ========== */
.avatar-circle {
  border-radius: 50%;
  overflow: hidden;
  background: var(--border);
  flex-shrink: 0;
}

.avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Avatar só com img dentro de qualquer container */
.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.avatar-xs  { width: 32px; height: 32px; }
.avatar-sm  { width: 38px; height: 38px; }
.avatar-md  { width: 44px; height: 44px; }
.avatar-lg  { width: 56px; height: 56px; }

/* ========== CARD VARIANTS (border-left colorida) ========== */
.card-danger  { border-left: 4px solid var(--danger) !important; }
.card-warning { border-left: 4px solid var(--warning) !important; }
.card-success { border-left: 4px solid var(--success) !important; }
.card-primary { border-left: 4px solid var(--primary) !important; }
.card-muted   { border-left: 4px solid var(--gray-500) !important; }

/* ========== INSTRUCTION BANNER ========== */
.instruction-card {
  border-left: 4px solid var(--warning);
  background: #1a1a2e;
  margin-bottom: 12px;
  font-size: var(--text-sm);
  color: var(--text);
  line-height: 1.5;
}

.instruction-card strong { color: var(--warning); }
.instruction-card em { color: var(--text-muted); }

/* ========== BANNER: AVISO DE SEGURANÇA ========== */
.security-banner {
  font-size: var(--text-sm);
  color: var(--warning);
  line-height: 1.6;
  text-align: center;
}

.security-banner em {
  font-style: italic;
  color: var(--text-muted);
}

/* ========== BANNER: AVISO DO SISTEMA ========== */
.banner-aviso {
  background: rgba(245,158,11,0.15);
  border-bottom: 1px solid var(--warning);
  color: var(--warning);
  text-align: center;
  padding: 8px 16px;
  font-size: var(--text-sm);
  font-weight: 600;
}

/* ========== BOTÕES ESPECIAIS ========== */
.btn-nav {
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
  width: 100%;
  padding: 0;
}

/* ========== SEARCH BAR (formulário de busca inline) ========== */
.search-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.search-bar input[type="text"],
.search-bar input[type="search"] {
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
  flex: 1;
  min-width: 0;
}

.search-input {
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
}

/* ========== CHECK INDICATOR (círculo de seleção) ========== */
.check-indicator {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

.check-indicator-lg {
  width: 28px;
  height: 28px;
  font-size: 16px;
}

/* ========== MEMBER / MATERIAL SELECTION CARD ========== */
.selection-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 4px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  color: var(--text);
  font-size: 13px;
  width: 100%;
}

.selection-card:hover {
  border-color: #374151;
}

.selection-card.selected {
  border-color: var(--primary);
  background: rgba(0,229,204,0.05);
}

.selection-card .card-info {
  flex: 1;
  line-height: 1.2;
  text-align: left;
}

.selection-card .card-info-title {
  font-weight: 600;
  font-size: 13px;
}

.selection-card .card-info-sub {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

/* ========== LABEL COM CHECKBOX INLINE ========== */
.form-check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 0;
}

.form-check-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

/* ========== SECTION SUBTITLE ========== */
.section-subtitle {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
}

/* ========== FOOTER ========== */
.app-footer,
.mobile-footer,
.login-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 10px;
  color: #9ca3af;
  opacity: 0.5;
  line-height: 1.6;
  pointer-events: none;
}

.app-footer { padding: 8px 24px 12px; }

.mobile-footer { padding: 8px 16px 80px; }

.login-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 16px 12px;
}

/* ========== ERROR PAGES ========== */
.error-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
  background-image: radial-gradient(ellipse at 50% 30%, rgba(0,229,204,0.03) 0%, transparent 70%);
}

.error-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: errorCardIn 0.5s ease;
}

@keyframes errorCardIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.error-logo {
  display: block;
  margin: 0 auto 28px;
  height: 52px;
}

.error-icon {
  display: inline-flex;
  margin-bottom: 20px;
  opacity: 0.9;
}

.error-code {
  font-size: 72px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  letter-spacing: -2px;
  margin-bottom: 4px;
}

.error-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.error-desc {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 28px;
  max-width: 340px;
  margin-left: auto;
  margin-right: auto;
}

.error-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.error-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 10px;
  color: #9ca3af;
  opacity: 0.5;
  line-height: 1.6;
  pointer-events: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 16px 12px;
}
