/* ============================================================
   CENTRE MANAGEMENT SYSTEM — SHARED STYLES
   ============================================================ */

:root {
  --primary: #1a56db;
  --primary-dark: #1341b0;
  --primary-light: #e8f0fe;
  --secondary: #0e9f6e;
  --secondary-dark: #057a55;
  --accent: #ff5a1f;
  --accent-light: #fff3ef;
  --warning: #e3a008;
  --warning-light: #fef3c7;
  --danger: #e02424;
  --danger-light: #fde8e8;
  --info: #3f83f8;
  --info-light: #ebf5ff;
  --dark: #111827;
  --gray-900: #1f2937;
  --gray-800: #374151;
  --gray-700: #4b5563;
  --gray-600: #6b7280;
  --gray-500: #9ca3af;
  --gray-400: #d1d5db;
  --gray-300: #e5e7eb;
  --gray-200: #f3f4f6;
  --gray-100: #f9fafb;
  --white: #ffffff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.14);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: all 0.2s ease;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Typography ── */
h1, h2, h3, h4, h5 { font-weight: 700; line-height: 1.3; color: var(--gray-900); }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }
p { color: var(--gray-700); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ── */
.container { max-width: 1280px; margin: 0 auto; padding: 0 1.25rem; }
.page-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-300);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.page-header h2 { margin: 0; font-size: 1.1rem; }
.page-content { padding: 1.5rem; }

/* ── Cards ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  border: 1px solid var(--gray-300);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--gray-300);
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--gray-900); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); color: var(--white); }
.btn-secondary { background: var(--secondary); color: var(--white); }
.btn-secondary:hover { background: var(--secondary-dark); color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #c81e1e; color: var(--white); }
.btn-warning { background: var(--warning); color: var(--white); }
.btn-warning:hover { background: #c27803; color: var(--white); }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--gray-400);
  color: var(--gray-700);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--gray-700); }
.btn-ghost:hover { background: var(--gray-200); }
.btn-whatsapp { background: #25d366; color: var(--white); }
.btn-whatsapp:hover { background: #128c7e; color: var(--white); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--gray-700); margin-bottom: 0.35rem; }
label .required { color: var(--danger); margin-left: 2px; }
input, select, textarea {
  width: 100%;
  padding: 0.55rem 0.85rem;
  border: 1.5px solid var(--gray-400);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: var(--font);
  color: var(--gray-900);
  background: var(--white);
  transition: var(--transition);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,0.12);
}
input::placeholder, textarea::placeholder { color: var(--gray-500); }
textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 0.75rem; color: var(--gray-500); margin-top: 0.25rem; }
.form-error { font-size: 0.75rem; color: var(--danger); margin-top: 0.25rem; display: none; }
.form-error.visible { display: block; }
.input-group { position: relative; }
.input-group input { padding-left: 2.5rem; }
.input-group .input-icon { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); color: var(--gray-500); font-size: 1rem; pointer-events: none; }
.input-group-append { display: flex; }
.input-group-append input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group-append .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ── Badges / Pills ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-success { background: #def7ec; color: #03543f; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-danger { background: var(--danger-light); color: #9b1c1c; }
.badge-gray { background: var(--gray-200); color: var(--gray-700); }
.badge-info { background: var(--info-light); color: #1e429f; }

/* ── Tables ── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th {
  background: var(--gray-100);
  color: var(--gray-700);
  font-weight: 600;
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 2px solid var(--gray-300);
  white-space: nowrap;
}
tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--gray-300);
  color: var(--gray-800);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-100); }
.table-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.modal-backdrop.active { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95) translateY(20px);
  transition: transform 0.25s ease;
}
.modal-backdrop.active .modal { transform: scale(1) translateY(0); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-300);
  position: sticky;
  top: 0;
  background: var(--white);
  z-index: 10;
}
.modal-header h3 { margin: 0; }
.modal-close {
  background: var(--gray-200);
  border: none;
  border-radius: 50%;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--gray-700);
  font-size: 1.1rem;
  transition: var(--transition);
}
.modal-close:hover { background: var(--gray-300); }
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--gray-300);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: var(--gray-100);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.modal-lg { max-width: 900px; }
.modal-sm { max-width: 420px; }

/* ── Alerts / Toasts ── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}
.alert-success { background: #def7ec; color: #03543f; border-left: 4px solid var(--secondary); }
.alert-warning { background: var(--warning-light); color: #92400e; border-left: 4px solid var(--warning); }
.alert-danger { background: var(--danger-light); color: #9b1c1c; border-left: 4px solid var(--danger); }
.alert-info { background: var(--info-light); color: #1e429f; border-left: 4px solid var(--info); }

#toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 0.6rem;
  max-width: 360px;
}
.toast {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.875rem;
  border-left: 4px solid var(--primary);
  animation: slideInRight 0.3s ease;
}
.toast.toast-success { border-color: var(--secondary); }
.toast.toast-error { border-color: var(--danger); }
.toast.toast-warning { border-color: var(--warning); }
.toast .toast-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.toast .toast-message { flex: 1; line-height: 1.4; }
.toast .toast-close { background: none; border: none; cursor: pointer; color: var(--gray-500); font-size: 1rem; flex-shrink: 0; }

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ── Search Bar ── */
.search-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.search-input-wrap { position: relative; flex: 1; min-width: 200px; }
.search-input-wrap input { padding-left: 2.4rem; }
.search-input-wrap .search-icon { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); color: var(--gray-500); }

/* ── Stats Grid ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-300);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.stat-card .stat-label { font-size: 0.78rem; font-weight: 600; color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 800; color: var(--gray-900); line-height: 1.1; }
.stat-card .stat-sub { font-size: 0.78rem; color: var(--gray-500); }
.stat-card .stat-icon { font-size: 1.4rem; margin-bottom: 0.2rem; }

/* ── Tabs ── */
.tab-nav {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid var(--gray-300);
  margin-bottom: 1.25rem;
  overflow-x: auto;
  padding-bottom: 0;
}
.tab-btn {
  padding: 0.6rem 1rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-600);
  border-bottom: 2.5px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
  white-space: nowrap;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--gray-500);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.4; }
.empty-state h3 { color: var(--gray-700); margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.875rem; }

/* ── Avatar ── */
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  object-fit: cover;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.3rem; }
.avatar-xl { width: 96px; height: 96px; font-size: 2rem; }

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  justify-content: center;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}
.page-btn {
  width: 34px; height: 34px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: var(--white);
  cursor: pointer;
  font-size: 0.875rem;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
  color: var(--gray-700);
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: var(--white); border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Loading Spinner ── */
.spinner {
  width: 36px; height: 36px;
  border: 3.5px solid var(--gray-300);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto;
}
.spinner-sm { width: 18px; height: 18px; border-width: 2.5px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.75);
  display: flex; align-items: center; justify-content: center;
  border-radius: inherit;
  z-index: 50;
}

/* ── Member Card Inline ── */
.member-inline {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.member-inline .info { line-height: 1.3; }
.member-inline .info strong { font-size: 0.875rem; display: block; }
.member-inline .info span { font-size: 0.775rem; color: var(--gray-500); }

/* ── Divider ── */
.divider { height: 1px; background: var(--gray-300); margin: 1.25rem 0; }
.divider-label { text-align: center; position: relative; margin: 1.25rem 0; }
.divider-label::before { content: ''; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--gray-300); }
.divider-label span { position: relative; background: var(--white); padding: 0 0.75rem; font-size: 0.78rem; color: var(--gray-500); font-weight: 600; }

/* ── Utility ── */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--gray-500); }
.text-danger { color: var(--danger); }
.text-success { color: var(--secondary); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.p-0 { padding: 0; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rounded { border-radius: var(--radius); }
.w-full { width: 100%; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  h1 { font-size: 1.4rem; }
  .page-content { padding: 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .modal { max-width: 100%; margin: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; position: fixed; bottom: 0; max-height: 95vh; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .btn { padding: 0.45rem 0.85rem; font-size: 0.82rem; }
  .btn-sm { padding: 0.3rem 0.55rem; font-size: 0.75rem; }
}
