/* ============================================================================
   COMMON.CSS — Design Tokens + Reset + Base
   Compartilhado por todas as paginas (Login, Registro, Admin)
   ============================================================================ */

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

/* --- Design Tokens --- */
:root {
  /* Primaria: Azul Royal — Identidade Calmare */
  --primary: #0a3d91;
  --primary-dark: #082e6e;
  --primary-light: #00aeef;
  --primary-50: #eef5ff;
  --primary-100: #d9e8ff;
  --primary-alpha-10: rgba(10, 61, 145, 0.10);
  --primary-alpha-20: rgba(10, 61, 145, 0.20);

  /* Secundaria: Slate */
  --secondary: #475569;
  --secondary-light: #64748b;

  /* Acentos Calmare */
  --accent-pink: #e91e76;
  --accent-green: #a0c800;
  --accent-orange: #ff5500;

  /* Feedback */
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --info: #00aeef;
  --info-bg: #eef8ff;

  /* Neutros */
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-disabled: #94a3b8;
  --text-white: #ffffff;

  --surface: #ffffff;
  --background: #f8fafc;
  --background-alt: #f1f5f9;
  --border-color: #e2e8f0;
  --border-dark: #cbd5e1;

  /* Tipografia */
  --font-primary: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* Espacamento (base 4px) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Sombras */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.05);

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Transicoes */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Componentes */
  --switch-bg: #b0bec5;
  --switch-bg-active: var(--primary);

  /* Gradientes */
  --gradient-login: linear-gradient(135deg, #0a3d91 0%, #00aeef 100%);
}

/* --- Base Styles --- */
body {
  font-family: var(--font-primary);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--background);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.container-wide {
  max-width: 1200px;
}

/* --- Utilidades --- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================================
   HEADER BUTTONS — Altura unificada (todas as paginas)
   ============================================================================ */
.header-right .btn,
.header-right .btn-nav-link,
.header-right .user-menu-trigger {
  height: 36px;
}

/* Navigation links (Admin, Meu Painel) — estilo outline consistente */
.btn-nav-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  font-family: var(--font-primary);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
}
.btn-nav-link .material-icons { font-size: 18px; }
.btn-nav-link:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-50);
}

@media (max-width: 768px) {
  .btn-nav-link span { display: none; }
}

/* ============================================================================
   USER MENU — Componente global (header de todas as paginas)
   ============================================================================ */
.user-menu {
  position: relative;
}
.user-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-family: var(--font-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.user-menu-trigger:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-50);
}
.user-menu-trigger .material-icons:first-child {
  font-size: 20px;
}
.user-menu-trigger #user-email {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-menu-arrow {
  font-size: 18px !important;
  transition: transform 0.2s;
}
.user-menu.open .user-menu-arrow {
  transform: rotate(180deg);
}
.user-menu.open .user-menu-trigger {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-50);
}

/* Dropdown */
.user-menu-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgba(15,23,42,0.08), 0 4px 6px -4px rgba(15,23,42,0.04);
  padding: 8px 0;
  z-index: 200;
  animation: userMenuFadeIn 0.15s ease;
}
.user-menu.open .user-menu-dropdown {
  display: block;
}
@keyframes userMenuFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.user-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-primary);
  cursor: pointer;
  transition: background var(--transition-fast);
  text-align: left;
}
.user-menu-item .material-icons {
  font-size: 18px;
  color: var(--text-secondary);
}
.user-menu-item:hover {
  background: var(--background);
}
.user-menu-item:hover .material-icons {
  color: var(--error);
}
.user-menu-item:hover {
  color: var(--error);
}
.user-menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: var(--space-2) 0;
}

@media (max-width: 768px) {
  .user-menu-trigger #user-email { max-width: 80px; }
}
@media (max-width: 480px) {
  .user-menu-trigger #user-email { display: none; }
  .user-menu-arrow { display: none; }
}

/* ============================================================================
   NOTIFICATION BADGE + MENU ITEM
   ============================================================================ */
.user-menu-trigger { position: relative; }
.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--error);
  color: white;
  font-size: 11px;
  font-weight: var(--weight-bold);
  line-height: 18px;
  text-align: center;
}
.menu-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--error);
  color: white;
  font-size: 11px;
  font-weight: var(--weight-bold);
  line-height: 20px;
  text-align: center;
}

/* ============================================================================
   NOTIFICATION MODAL (leitura — global)
   ============================================================================ */
.notif-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.notif-modal.active { display: flex; }
.notif-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}
.notif-modal-container {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.notif-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-color);
}
.notif-modal-header h2 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.notif-modal-header h2 .material-icons { color: var(--primary); }
.notif-modal-close {
  background: none; border: none;
  font-size: 24px; cursor: pointer;
  color: var(--text-secondary); padding: var(--space-1);
}
.notif-modal-body {
  padding: var(--space-4) var(--space-5);
  overflow-y: auto;
  flex: 1;
}
.notif-card {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: var(--space-3);
  transition: background 0.15s;
}
.notif-card.unread {
  background: var(--primary-50);
  border-color: var(--primary-light);
}
.notif-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.notif-card-title {
  font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
  flex: 1;
}
.notif-type-badge {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}
.notif-type-informativo { background: var(--primary-50); color: var(--primary); }
.notif-type-importante { background: #fff7ed; color: #c2410c; }
.notif-type-urgente { background: var(--error-bg); color: var(--error); }
.notif-card-body {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: pre-line;
}
.notif-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-disabled);
}
.notif-card-actions { display: flex; gap: var(--space-2); }
.notif-btn-read {
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font-family: var(--font-primary);
  transition: all 0.15s;
}
.notif-btn-read:hover {
  background: var(--primary);
  color: white;
}
.notif-empty {
  text-align: center;
  padding: var(--space-6);
  color: var(--text-secondary);
}
.notif-section-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-disabled);
  margin-bottom: var(--space-2);
  margin-top: var(--space-4);
}
.notif-section-label:first-child { margin-top: 0; }
.notif-btn-dismiss {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-disabled);
  padding: 2px;
  border-radius: 50%;
  transition: all 0.15s;
  margin-left: auto;
  flex-shrink: 0;
}
.notif-btn-dismiss:hover {
  color: var(--error);
  background: var(--error-bg);
}

/* ============================================================================
   OBLIGATORY MODAL (bloqueante ao login)
   ============================================================================ */
.oblig-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  -webkit-overflow-scrolling: touch;
}
.oblig-modal.active { display: flex; }
.oblig-modal-container {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.oblig-modal-header {
  padding: var(--space-4) var(--space-5);
  background: var(--error);
  color: white;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.oblig-modal-header .material-icons { font-size: 24px; }
.oblig-modal-header h2 { font-size: var(--text-base); font-weight: var(--weight-semibold); }
.oblig-modal-body {
  padding: var(--space-5);
  overflow-y: auto;
  flex: 1;
}
.oblig-modal-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}
.oblig-modal-content {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-line;
  margin-bottom: var(--space-4);
}
.oblig-modal-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-color);
}
.oblig-checkbox-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.oblig-checkbox-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  cursor: pointer;
}
.oblig-checkbox-row label {
  font-size: var(--text-sm);
  color: var(--text-primary);
  cursor: pointer;
}
.oblig-btn-confirm {
  width: 100%;
  padding: var(--space-3);
  border: none;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: white;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  font-family: var(--font-primary);
  cursor: pointer;
  transition: opacity 0.15s;
}
.oblig-btn-confirm:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.oblig-btn-confirm:not(:disabled):hover {
  background: var(--primary-dark);
}
.oblig-counter {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--text-disabled);
  margin-top: var(--space-2);
}
