/**
 * ============================================================================
 * THEOS ECLESIAL & VERUS - UNIFIED DESIGN SYSTEM
 * Incorporating UI-Craft, Tasteful-UI, and Apple HIG Principles
 * Paróquia Nossa Senhora Aparecida - Diocese de Assis / SP
 * ============================================================================
 */

:root {
  /* Surface & Canvas Hierarchy */
  --ec-canvas: #090e1a;
  --ec-surface-0: #0b1120;
  --ec-surface-1: #0f172a;
  --ec-surface-2: #162033;
  --ec-surface-3: #1c2a42;
  --ec-surface-hover: #22324e;
  --ec-surface-overlay: rgba(11, 17, 32, 0.92);

  /* Border Tokens */
  --ec-border-subtle: rgba(255, 255, 255, 0.07);
  --ec-border-default: #2a3a52;
  --ec-border-strong: #3b506e;
  --ec-border-focus: #d4a843;

  /* Typography Colors */
  --ec-text-primary: #f8fafc;
  --ec-text-secondary: #cbd5e1;
  --ec-text-muted: #8899b0;
  --ec-text-inverse: #090e1a;

  /* Brand Accents */
  --ec-gold: #d4a843;
  --ec-gold-light: #f0d68a;
  --ec-gold-dark: #b08728;
  --ec-gold-glow: rgba(212, 168, 67, 0.22);
  --ec-teal: #00838f;
  --ec-teal-light: #00acc1;
  --ec-teal-glow: rgba(0, 131, 143, 0.22);
  --ec-purple: #8b5cf6;

  /* Status Colors */
  --ec-success: #10b981;
  --ec-success-bg: rgba(16, 185, 129, 0.12);
  --ec-success-border: rgba(16, 185, 129, 0.28);
  --ec-warning: #f59e0b;
  --ec-warning-bg: rgba(245, 158, 11, 0.12);
  --ec-warning-border: rgba(245, 158, 11, 0.28);
  --ec-danger: #ef4444;
  --ec-danger-bg: rgba(239, 68, 68, 0.12);
  --ec-danger-border: rgba(239, 68, 68, 0.28);
  --ec-info: #38bdf8;
  --ec-info-bg: rgba(56, 189, 248, 0.12);
  --ec-info-border: rgba(56, 189, 248, 0.28);

  /* Shadows & Depth */
  --ec-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --ec-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
  --ec-shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.55);
  --ec-shadow-window: 0 20px 48px -10px rgba(0, 0, 0, 0.75), 0 0 0 1px var(--ec-border-default);

  /* Radii */
  --ec-radius-xs: 3px;
  --ec-radius-sm: 5px;
  --ec-radius-md: 8px;
  --ec-radius-lg: 12px;
  --ec-radius-full: 9999px;

  /* Transitions */
  --ec-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ec-trans-fast: 0.15s var(--ec-ease);
  --ec-trans-normal: 0.25s var(--ec-ease);
}

/* ============================================================
   1. GLOBAL RESET & SCROLLBARS
   ============================================================ */
body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--ec-canvas);
  color: var(--ec-text-primary);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Tabular figures for all financial & metric numbers */
.num, .tabular, td.numeric, .stat-value, .money, .currency {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* Custom Scrollbars */
*::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
*::-webkit-scrollbar-track {
  background: rgba(11, 17, 32, 0.6);
}
*::-webkit-scrollbar-thumb {
  background: var(--ec-border-default);
  border-radius: var(--ec-radius-full);
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--ec-border-strong);
}

/* ============================================================
   2. THEOS ECLESIAL WINDOW & RIBBON SYSTEM
   ============================================================ */
.eclesial-window {
  background: var(--ec-surface-0);
  border: 1px solid var(--ec-border-default);
  border-radius: var(--ec-radius-md);
  box-shadow: var(--ec-shadow-window);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin-bottom: 1.5rem;
  transition: border-color var(--ec-trans-fast);
}

.eclesial-window:hover {
  border-color: var(--ec-border-strong);
}

/* Window Header Bar (Classic ERP Style with Diocese/Module info) */
.eclesial-window-header {
  background: linear-gradient(180deg, var(--ec-surface-1) 0%, var(--ec-surface-0) 100%);
  border-bottom: 1px solid var(--ec-border-default);
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.eclesial-window-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ec-text-primary);
}

.eclesial-window-title i {
  color: var(--ec-gold);
}

.eclesial-window-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.eclesial-win-btn {
  width: 26px;
  height: 26px;
  border-radius: var(--ec-radius-xs);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ec-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: all var(--ec-trans-fast);
}

.eclesial-win-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ec-text-primary);
  border-color: var(--ec-border-subtle);
}

.eclesial-win-btn.close:hover {
  background: var(--ec-danger);
  color: #fff;
  border-color: var(--ec-danger);
}

/* Ribbon Toolbar */
.eclesial-ribbon {
  background: var(--ec-surface-1);
  border-bottom: 1px solid var(--ec-border-default);
  padding: 0.4rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  overflow-x: auto;
}

.eclesial-ribbon-group {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0 0.4rem;
  border-right: 1px solid var(--ec-border-subtle);
}

.eclesial-ribbon-group:last-child {
  border-right: none;
}

.eclesial-ribbon-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.65rem;
  min-width: 68px;
  min-height: 52px;
  border-radius: var(--ec-radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ec-text-secondary);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--ec-trans-fast);
  text-align: center;
  gap: 0.2rem;
}

.eclesial-ribbon-btn i {
  font-size: 1.1rem;
  color: var(--ec-gold);
  transition: transform var(--ec-trans-fast);
}

.eclesial-ribbon-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--ec-border-subtle);
  color: var(--ec-text-primary);
  transform: translateY(-1px);
}

.eclesial-ribbon-btn:hover i {
  transform: scale(1.1);
}

.eclesial-ribbon-btn:active {
  transform: translateY(0) scale(0.97);
}

.eclesial-ribbon-btn.active {
  background: rgba(212, 168, 67, 0.12);
  border-color: rgba(212, 168, 67, 0.35);
  color: var(--ec-gold-light);
  font-weight: 600;
}

.eclesial-ribbon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

/* ============================================================
   3. PROFESSIONAL DATA TABLES (High Density & Legibility)
   ============================================================ */
.eclesial-table-container {
  position: relative;
  overflow-x: auto;
  border: 1px solid var(--ec-border-default);
  border-radius: var(--ec-radius-md);
  background: var(--ec-surface-0);
  box-shadow: var(--ec-shadow-sm);
}

.eclesial-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
}

.eclesial-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #111a2e;
}

.eclesial-table th {
  padding: 0.65rem 0.85rem;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ec-gold);
  border-bottom: 2px solid var(--ec-border-default);
  white-space: nowrap;
  user-select: none;
}

.eclesial-table td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--ec-border-subtle);
  color: var(--ec-text-secondary);
  transition: background var(--ec-trans-fast), color var(--ec-trans-fast);
  white-space: nowrap;
}

.eclesial-table tbody tr {
  cursor: default;
  transition: background var(--ec-trans-fast);
}

.eclesial-table tbody tr:hover {
  background: var(--ec-surface-hover);
}

.eclesial-table tbody tr:hover td {
  color: var(--ec-text-primary);
}

.eclesial-table tbody tr.selected {
  background: rgba(212, 168, 67, 0.15) !important;
  border-left: 3px solid var(--ec-gold);
}

.eclesial-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

/* ============================================================
   4. TASTEFUL FORM CONTROLS
   ============================================================ */
.eclesial-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.eclesial-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ec-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.eclesial-label.required::after {
  content: '*';
  color: var(--ec-danger);
}

.eclesial-input,
.eclesial-select,
.eclesial-textarea {
  background: var(--ec-canvas);
  border: 1px solid var(--ec-border-default);
  color: var(--ec-text-primary);
  padding: 0.5rem 0.75rem;
  border-radius: var(--ec-radius-sm);
  font-family: inherit;
  font-size: 0.82rem;
  width: 100%;
  box-sizing: border-box;
  transition: border-color var(--ec-trans-fast), box-shadow var(--ec-trans-fast);
}

.eclesial-input:focus,
.eclesial-select:focus,
.eclesial-textarea:focus {
  outline: none;
  border-color: var(--ec-gold);
  box-shadow: 0 0 0 3px var(--ec-gold-glow);
}

.eclesial-input::placeholder {
  color: var(--ec-text-muted);
  opacity: 0.55;
}

.eclesial-input:disabled,
.eclesial-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: rgba(0, 0, 0, 0.25);
}

/* Search Box with Clear Button */
.eclesial-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.eclesial-search-wrap i.search-icon {
  position: absolute;
  left: 0.75rem;
  font-size: 0.8rem;
  color: var(--ec-text-muted);
  pointer-events: none;
}

.eclesial-search-wrap input {
  padding-left: 2.2rem !important;
  padding-right: 2rem !important;
}

.eclesial-search-wrap .search-clear-btn {
  position: absolute;
  right: 0.55rem;
  background: none;
  border: none;
  color: var(--ec-text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.2rem 0.4rem;
  border-radius: var(--ec-radius-xs);
  display: none;
}

.eclesial-search-wrap .search-clear-btn:hover {
  color: var(--ec-text-primary);
}

/* ============================================================
   5. TACTILE STATUS BADGES
   ============================================================ */
.eclesial-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--ec-radius-full);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.eclesial-badge.success {
  background: var(--ec-success-bg);
  color: var(--ec-success);
  border: 1px solid var(--ec-success-border);
}

.eclesial-badge.warning {
  background: var(--ec-warning-bg);
  color: var(--ec-warning);
  border: 1px solid var(--ec-warning-border);
}

.eclesial-badge.danger {
  background: var(--ec-danger-bg);
  color: var(--ec-danger);
  border: 1px solid var(--ec-danger-border);
}

.eclesial-badge.info {
  background: var(--ec-info-bg);
  color: var(--ec-info);
  border: 1px solid var(--ec-info-border);
}

.eclesial-badge.gold {
  background: rgba(212, 168, 67, 0.15);
  color: var(--ec-gold-light);
  border: 1px solid rgba(212, 168, 67, 0.3);
}

.eclesial-badge.purple {
  background: rgba(139, 92, 246, 0.15);
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

/* ============================================================
   6. INTERACTIVE TOASTS & MODALS
   ============================================================ */
.eclesial-toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 10000;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.6rem;
  pointer-events: none;
}

.eclesial-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.1rem;
  border-radius: var(--ec-radius-md);
  background: var(--ec-surface-2);
  border: 1px solid var(--ec-border-strong);
  box-shadow: var(--ec-shadow-lg);
  color: var(--ec-text-primary);
  font-size: 0.83rem;
  font-weight: 500;
  min-width: 280px;
  max-width: 420px;
  animation: toastSlideIn 0.28s var(--ec-ease);
  position: relative;
  overflow: hidden;
}

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

.eclesial-toast.closing {
  animation: toastSlideOut 0.22s var(--ec-ease) forwards;
}

@keyframes toastSlideOut {
  to {
    opacity: 0;
    transform: translateX(30px);
  }
}

.eclesial-toast::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--ec-gold);
  width: 100%;
  animation: toastProgress var(--toast-duration, 4s) linear forwards;
}

@keyframes toastProgress {
  from { width: 100%; }
  to { width: 0%; }
}

/* Modal Window Backdrop */
.eclesial-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 18, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ec-trans-normal);
}

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

.eclesial-modal-dialog {
  background: var(--ec-surface-0);
  border: 1px solid var(--ec-border-strong);
  border-radius: var(--ec-radius-md);
  box-shadow: var(--ec-shadow-window);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--ec-trans-normal);
}

.eclesial-modal-backdrop.active .eclesial-modal-dialog {
  transform: scale(1) translateY(0);
}

.eclesial-modal-header {
  background: var(--ec-surface-1);
  border-bottom: 1px solid var(--ec-border-default);
  padding: 0.75rem 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.eclesial-modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  color: var(--ec-text-secondary);
  font-size: 0.85rem;
}

.eclesial-modal-footer {
  background: var(--ec-surface-1);
  border-top: 1px solid var(--ec-border-default);
  padding: 0.75rem 1.1rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
}

/* ============================================================
   7. KEYBOARD NAVIGATION & ACCESSIBILITY FOCUS
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--ec-gold) !important;
  outline-offset: 2px !important;
}

button:active {
  transform: scale(0.97);
}

/* Skeleton Loading State for Data Fetching */
.eclesial-skeleton {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.04) 25%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.04) 75%);
  background-size: 200% 100%;
  animation: ecSkeleton 1.5s infinite;
  border-radius: var(--ec-radius-xs);
  min-height: 18px;
}

@keyframes ecSkeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   8. COMMAND PALETTE & QUICK SEARCH (Ctrl+K)
   ============================================================ */
.topbar-search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--ec-border-default);
  color: var(--ec-text-muted);
  border-radius: var(--ec-radius-full);
  padding: 0.35rem 0.85rem;
  font-size: 0.76rem;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--ec-trans-fast);
}

.topbar-search-trigger:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--ec-border-strong);
  color: var(--ec-text-primary);
}

.topbar-search-trigger kbd {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--ec-border-default);
  border-radius: 4px;
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  font-family: inherit;
  color: var(--ec-text-secondary);
}

.eclesial-palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10001;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  animation: fadeIn 0.15s ease-out;
}

.eclesial-palette-dialog {
  background: #0f172a;
  border: 1px solid var(--ec-border-strong);
  border-radius: var(--ec-radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.08);
  width: 100%;
  max-width: 580px;
  overflow: hidden;
  animation: mIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.eclesial-palette-input-wrap {
  display: flex;
  align-items: center;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--ec-border-default);
  gap: 0.75rem;
  background: #0b1120;
}

.eclesial-palette-input-wrap i {
  color: var(--ec-gold);
  font-size: 1.1rem;
}

.eclesial-palette-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ec-text-primary);
  font-size: 0.95rem;
  font-family: inherit;
}

.eclesial-palette-input::placeholder {
  color: var(--ec-text-muted);
}

.eclesial-palette-list {
  max-height: 380px;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.eclesial-palette-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  border-radius: var(--ec-radius-md);
  color: var(--ec-text-secondary);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all var(--ec-trans-fast);
  border: 1px solid transparent;
}

.eclesial-palette-item:hover,
.eclesial-palette-item.active {
  background: rgba(212, 168, 67, 0.12);
  color: var(--ec-gold-light);
  border-color: rgba(212, 168, 67, 0.25);
}

.eclesial-palette-item i {
  width: 22px;
  text-align: center;
  margin-right: 0.5rem;
  color: var(--ec-gold);
}

.eclesial-palette-footer {
  padding: 0.5rem 1rem;
  background: #0b1120;
  border-top: 1px solid var(--ec-border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--ec-text-muted);
}

