/* ═══ Society Management PWA — Components ═══ */

/* ═══ SIDEBAR ═══ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-primary);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: var(--z-sticky);
  overflow: hidden;
}
.sidebar-header {
  padding: var(--sp-5) var(--sp-5) var(--sp-3);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.sidebar-logo { display: flex; align-items: center; gap: var(--sp-2); }
.sidebar-logo-icon {
  width: 36px; height: 36px;
  background: var(--gradient-primary);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-lg); color: #fff;
  box-shadow: var(--shadow-glow-primary);
}
.sidebar-logo-text {
  font-size: var(--fs-lg); font-weight: var(--fw-bold);
  color: var(--text-primary); letter-spacing: -0.02em;
}
.sidebar-user {
  margin: var(--sp-2) var(--sp-3); padding: var(--sp-3);
  display: flex; align-items: center; gap: var(--sp-3);
  border-radius: var(--radius-md);
  background: var(--surface-glass);
  border: 1px solid var(--surface-glass-border);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
}
.sidebar-user:hover { background: var(--surface-glass-hover); }
.sidebar-avatar {
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  background: var(--gradient-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-sm); font-weight: var(--fw-bold); color: #fff;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: var(--fs-sm); font-weight: var(--fw-semibold);
  color: var(--text-primary); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role { font-size: var(--fs-xs); color: var(--text-tertiary); }
.sidebar-label {
  padding: var(--sp-4) var(--sp-5) var(--sp-2);
  font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  color: var(--text-tertiary); letter-spacing: 0.08em;
  text-transform: uppercase;
}
.sidebar-nav { padding: 0 var(--sp-3); display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-md);
  font-size: var(--fs-base); font-weight: var(--fw-medium);
  color: var(--text-secondary); cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--brand-primary); color: #fff;
  box-shadow: var(--shadow-glow-primary);
}
.nav-item.active .nav-icon svg { stroke: #fff; }
.nav-icon {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.nav-icon svg { width: 18px; height: 18px; stroke: var(--text-secondary); transition: stroke var(--duration-fast); }
.nav-item:hover .nav-icon svg { stroke: var(--text-primary); }
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: var(--fw-bold);
  padding: 2px 7px; border-radius: var(--radius-full);
}
.sidebar-fill { flex: 1; }
.sidebar-bottom {
  padding: var(--sp-3);
  border-top: 1px solid var(--border-primary);
  display: flex; flex-direction: column; gap: 2px;
}

/* ═══ TOPBAR ═══ */
.topbar {
  height: var(--topbar-height); padding: 0 var(--sp-6);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-primary);
  flex-shrink: 0; z-index: var(--z-sticky);
  backdrop-filter: blur(12px);
}
.topbar-left { display: flex; align-items: center; gap: var(--sp-2); }
.topbar-title { font-size: var(--fs-md); font-weight: var(--fw-semibold); color: var(--text-primary); }
.topbar-breadcrumb { font-size: var(--fs-sm); color: var(--text-tertiary); }
.topbar-right { display: flex; align-items: center; gap: var(--sp-3); }
.topbar-icon-btn {
  width: 36px; height: 36px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); transition: all var(--duration-fast); position: relative;
}
.topbar-icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.topbar-icon-btn svg { width: 18px; height: 18px; }
.topbar-dot {
  position: absolute; top: 6px; right: 6px; width: 8px; height: 8px;
  border-radius: var(--radius-full); background: var(--danger);
  border: 2px solid var(--bg-secondary);
}
.mobile-menu-btn { display: none; width: 36px; height: 36px; border-radius: var(--radius-md); align-items: center; justify-content: center; color: var(--text-secondary); }

/* ═══ BUTTONS ═══ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-2); padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-md); font-size: var(--fs-base);
  font-weight: var(--fw-medium); line-height: 1; cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap; border: none; height: 38px;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-primary { background: var(--gradient-primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { box-shadow: var(--shadow-glow-primary); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-accent { background: var(--gradient-accent); color: #1A1A2E; }
.btn-accent:hover { box-shadow: var(--shadow-glow-accent); transform: translateY(-1px); }
.btn-outline { background: transparent; border: 1px solid var(--border-primary); color: var(--text-secondary); }
.btn-outline:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--text-tertiary); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { box-shadow: var(--shadow-glow-danger); }
.btn-sm { height: 32px; padding: var(--sp-1) var(--sp-3); font-size: var(--fs-sm); }
.btn-lg { height: 44px; padding: var(--sp-3) var(--sp-6); font-size: var(--fs-md); }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }

/* ═══ CARDS ═══ */
.card {
  background: var(--bg-elevated); border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg); padding: var(--sp-5);
  transition: all var(--duration-normal) var(--ease-out);
}
.card:hover { border-color: var(--surface-glass-border); box-shadow: var(--shadow-md); }
.card-glass {
  background: var(--surface-glass); border: 1px solid var(--surface-glass-border);
  backdrop-filter: blur(12px); border-radius: var(--radius-lg); padding: var(--sp-5);
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-4); }
.card-title { font-size: var(--fs-md); font-weight: var(--fw-semibold); color: var(--text-primary); }
.card-subtitle { font-size: var(--fs-sm); color: var(--text-tertiary); margin-top: var(--sp-1); }

/* ═══ FORM INPUTS ═══ */
.form-group { display: flex; flex-direction: column; gap: var(--sp-2); }
.form-label { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-secondary); }
.form-input {
  height: 42px; padding: 0 var(--sp-4); background: var(--input-bg);
  border: 1px solid var(--input-border); border-radius: var(--radius-md);
  color: var(--text-primary); font-size: var(--fs-base);
  transition: all var(--duration-fast); width: 100%;
}
.form-input::placeholder { color: var(--input-placeholder); }
.form-input:focus { border-color: var(--input-focus-border); box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15); }
.form-select {
  height: 42px; padding: 0 var(--sp-8) 0 var(--sp-4);
  background: var(--input-bg); border: 1px solid var(--input-border);
  border-radius: var(--radius-md); color: var(--text-primary);
  font-size: var(--fs-base); appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238888A0' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  cursor: pointer; width: 100%;
}
.form-select:focus { border-color: var(--input-focus-border); box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15); }
textarea.form-input { height: auto; min-height: 100px; padding: var(--sp-3) var(--sp-4); resize: vertical; }

/* ═══ BADGES ═══ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--radius-full);
  font-size: var(--fs-xs); font-weight: var(--fw-semibold);
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-primary { background: rgba(108,92,231,0.12); color: var(--brand-primary-light); }
.badge-dot::before { content: ''; width: 6px; height: 6px; border-radius: var(--radius-full); background: currentColor; }

/* ═══ TABLES ═══ */
.table-wrapper { overflow-x: auto; border: 1px solid var(--border-primary); border-radius: var(--radius-lg); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: var(--sp-3) var(--sp-4); text-align: left;
  font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  color: var(--text-tertiary); text-transform: uppercase;
  letter-spacing: 0.06em; background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-primary);
}
.data-table td { padding: var(--sp-3) var(--sp-4); font-size: var(--fs-base); color: var(--text-primary); border-bottom: 1px solid var(--border-secondary); }
.data-table tbody tr { transition: background var(--duration-fast); }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ═══ MODAL ═══ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px); display: flex;
  align-items: center; justify-content: center;
  z-index: var(--z-modal); opacity: 0; visibility: hidden;
  transition: all var(--duration-normal); padding: var(--sp-4);
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--bg-elevated); border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl); width: 100%; max-width: 480px;
  max-height: 90dvh; overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--duration-normal) var(--ease-spring);
  box-shadow: var(--shadow-xl);
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--border-primary);
}
.modal-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.modal-close {
  width: 32px; height: 32px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-tertiary); transition: all var(--duration-fast);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal-body { padding: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-4); }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end;
  gap: var(--sp-3); padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border-primary);
}

/* ═══ TOAST ═══ */
.toast-container {
  position: fixed; top: var(--sp-4); right: var(--sp-4);
  z-index: var(--z-toast); display: flex; flex-direction: column;
  gap: var(--sp-2); pointer-events: none;
}
.toast {
  background: var(--bg-elevated); border: 1px solid var(--border-primary);
  border-radius: var(--radius-md); padding: var(--sp-3) var(--sp-4);
  display: flex; align-items: center; gap: var(--sp-3);
  box-shadow: var(--shadow-lg); pointer-events: all;
  min-width: 280px; max-width: 400px;
  animation: toast-in var(--duration-normal) var(--ease-spring) forwards;
}
.toast.removing { animation: toast-out var(--duration-normal) var(--ease-out) forwards; }
.toast-content { flex: 1; }
.toast-title { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-primary); }
.toast-msg { font-size: var(--fs-xs); color: var(--text-secondary); margin-top: 2px; }
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-warning { border-left: 3px solid var(--warning); }

/* ═══ EMPTY STATE ═══ */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--sp-12) var(--sp-6); text-align: center; }
.empty-state-icon { font-size: 3rem; margin-bottom: var(--sp-4); opacity: 0.5; }
.empty-state-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); color: var(--text-primary); margin-bottom: var(--sp-2); }
.empty-state-desc { font-size: var(--fs-base); color: var(--text-tertiary); max-width: 360px; margin-bottom: var(--sp-6); }

/* ═══ SKELETON LOADERS ═══ */
.skeleton { background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-hover) 50%, var(--bg-tertiary) 75%); background-size: 200% 100%; animation: skeleton-shimmer 1.5s infinite; border-radius: var(--radius-md); }
.skeleton-text { height: 14px; width: 80%; }
.skeleton-title { height: 20px; width: 60%; }
.skeleton-card { height: 120px; width: 100%; }

/* ═══ PROGRESS BAR ═══ */
.progress { height: 6px; background: var(--bg-tertiary); border-radius: var(--radius-full); overflow: hidden; }
.progress-bar { height: 100%; border-radius: var(--radius-full); transition: width var(--duration-slow) var(--ease-out); }
.progress-bar.success { background: var(--gradient-accent); }
.progress-bar.warning { background: var(--gradient-warm); }
.progress-bar.danger { background: var(--danger); }
.progress-bar.primary { background: var(--gradient-primary); }

/* ═══ BOTTOM NAV ═══ */
.bottom-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; height: var(--bottom-nav-height); background: var(--bg-secondary); border-top: 1px solid var(--border-primary); z-index: var(--z-sticky); padding: 0 var(--sp-2); backdrop-filter: blur(12px); }
.bottom-nav-items { display: flex; align-items: center; justify-content: space-around; height: 100%; }
.bottom-nav-item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: var(--sp-1) var(--sp-3); border-radius: var(--radius-md); color: var(--text-tertiary); font-size: 10px; font-weight: var(--fw-medium); transition: all var(--duration-fast); cursor: pointer; }
.bottom-nav-item svg { width: 20px; height: 20px; }
.bottom-nav-item.active { color: var(--brand-primary); }

/* ═══ INSTALL BANNER ═══ */
.install-banner {
  position: fixed; top: var(--sp-4); left: 50%;
  transform: translateX(-50%) translateY(-150%);
  background: var(--bg-elevated); border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl); padding: var(--sp-4) var(--sp-5);
  display: flex; align-items: center; gap: var(--sp-4);
  box-shadow: var(--shadow-xl); z-index: var(--z-toast);
  max-width: 400px; width: calc(100% - var(--sp-8));
  transition: transform var(--duration-slow) var(--ease-spring);
}
.install-banner.show { transform: translateX(-50%) translateY(0); }
.install-banner-icon { width: 44px; height: 44px; border-radius: var(--radius-lg); background: var(--gradient-primary); display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.install-banner-content { flex: 1; }
.install-banner-title { font-size: var(--fs-base); font-weight: var(--fw-semibold); color: var(--text-primary); }
.install-banner-desc { font-size: var(--fs-xs); color: var(--text-tertiary); margin-top: 2px; }
.install-banner-close {
  background: transparent; border: none; font-size: 18px;
  color: var(--text-tertiary); padding: 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  margin-left: 4px;
}

/* ═══ MOBILE ═══ */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .sidebar.open { display: flex; position: fixed; inset: 0; width: 100%; max-width: 300px; z-index: var(--z-overlay); box-shadow: var(--shadow-xl); }
  .sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: calc(var(--z-overlay) - 1); }
  .sidebar-backdrop.open { display: block; }
  .mobile-menu-btn { display: flex; }
  .bottom-nav { display: block; }
  .topbar { padding: 0 var(--sp-4); }
  .topbar-breadcrumb { display: none; }
}
