/* ==========================================================================
   WhatsApp Manual Sender Dashboard - Modern Stylesheet (Cairo & Rich Theme)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&display=swap');

:root {
  --font-main: 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Colors */
  --primary: #1e3a8a;
  --primary-light: #eff6ff;
  --primary-glow: rgba(30, 58, 138, 0.15);
  
  --wa-green: #25D366;
  --wa-dark: #128C7E;
  --wa-hover: #075E54;
  --wa-glow: rgba(37, 211, 102, 0.25);

  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --border: #e2e8f0;
  --border-focus: #3b82f6;

  --text-main: #0f172a;
  --text-sub: #475569;
  --text-muted: #94a3b8;

  --success: #10b981;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;

  --danger: #ef4444;
  --danger-bg: #fef2f2;
  
  --role-father: #0284c7;
  --role-father-bg: #e0f2fe;
  --role-mother: #9333ea;
  --role-mother-bg: #f3e8ff;

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

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-main);
  color: var(--text-main);
  direction: rtl;
  text-align: right;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px 80px 20px;
}

/* ==========================================================================
   Header & Navbar
   ========================================================================== */
.app-header {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 26px;
  box-shadow: 0 4px 12px var(--wa-glow);
}

.brand-text h1 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.school-badge {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: var(--radius-full);
}

.brand-text p {
  font-size: 13px;
  color: var(--text-sub);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.connection-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: #f8fafc;
  border: 1px solid var(--border);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}

.connection-pill.online .status-dot {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.connection-pill.offline .status-dot {
  background: var(--warning);
}

.wa-mode-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
}

.mode-btn {
  border: none;
  background: transparent;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
  cursor: pointer;
  transition: var(--transition);
}

.mode-btn.active {
  background: #fff;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: var(--transition);
}

.btn-icon:hover {
  background: var(--bg-subtle);
  color: var(--primary);
  border-color: var(--primary);
}

/* ==========================================================================
   Stats Cards
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.stat-icon-wrapper {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.stat-card.total .stat-icon-wrapper { background: #eff6ff; color: #2563eb; }
.stat-card.sent .stat-icon-wrapper { background: var(--success-bg); color: var(--success); }
.stat-card.pending .stat-icon-wrapper { background: var(--warning-bg); color: var(--warning); }
.stat-card.progress-card .stat-icon-wrapper { background: #f3e8ff; color: #9333ea; }

/* Progress bar inside stats */
.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--bg-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #059669);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* ==========================================================================
   Grade Navigation Tabs
   ========================================================================== */
.grades-nav-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  scrollbar-width: thin;
}

.grades-nav {
  display: flex;
  gap: 8px;
  min-width: max-content;
}

.grade-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid transparent;
  color: var(--text-sub);
  font-family: var(--font-main);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.grade-tab:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.grade-tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.tab-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.08);
}

.grade-tab.active .tab-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.tab-sent-indicator {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: var(--success);
  color: #fff;
}

/* ==========================================================================
   Filter Toolbar
   ========================================================================== */
.toolbar-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 260px;
}

.search-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 10px 42px 10px 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  font-family: var(--font-main);
  font-size: 14px;
  color: var(--text-main);
  outline: none;
  transition: var(--transition);
}

.search-input:focus {
  background: #fff;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.search-clear {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  display: none;
}

.search-clear.visible {
  display: block;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.filter-pills {
  display: flex;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.filter-pill {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-sub);
  cursor: pointer;
  transition: var(--transition);
}

.filter-pill.active {
  background: #fff;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  user-select: none;
}

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

.btn-secondary:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
  border-color: #cbd5e1;
}

/* ==========================================================================
   Table & List View
   ========================================================================== */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-x: auto !important;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  overscroll-behavior-x: contain;
  box-shadow: var(--shadow-sm);
  width: 100%;
  position: relative;
}

.data-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  text-align: right;
  font-size: 14px;
}

/* Custom Visible Scrollbar for Mobile/Desktop Table */
.table-container::-webkit-scrollbar {
  height: 8px;
}
.table-container::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}
.table-container::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 4px;
}
.table-container::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

.data-table thead {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  padding: 14px 18px;
  font-weight: 800;
  color: var(--text-sub);
  font-size: 13px;
  white-space: nowrap;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

.data-table tbody tr:last-child {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

.data-table tbody tr.row-sent {
  background: rgba(16, 185, 129, 0.02);
}

.data-table td {
  padding: 14px 18px;
  vertical-align: middle;
}

/* Table cells */
.student-cell {
  display: flex;
  flex-direction: column;
}

.student-name {
  font-weight: 700;
  color: var(--text-main);
}

.student-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.class-tag {
  background: var(--bg-subtle);
  padding: 1px 6px;
  border-radius: 4px;
}

.parent-cell {
  display: flex;
  flex-direction: column;
}

.parent-name {
  font-weight: 600;
  color: var(--text-main);
}

.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  margin-top: 4px;
}

.role-badge.father {
  background: var(--role-father-bg);
  color: var(--role-father);
}

.role-badge.mother {
  background: var(--role-mother-bg);
  color: var(--role-mother);
}

.phone-cell {
  direction: ltr;
  text-align: right;
  font-family: inherit;
  font-weight: 600;
  color: var(--text-sub);
  letter-spacing: 0.5px;
}

.auth-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
}

.auth-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.auth-label {
  color: var(--text-muted);
}

.auth-value {
  font-family: monospace;
  font-weight: 700;
  color: var(--text-main);
  background: var(--bg-subtle);
  padding: 1px 6px;
  border-radius: 4px;
}

/* Status Badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

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

.status-badge.pending {
  background: var(--warning-bg);
  color: #b45309;
  border: 1px solid var(--warning-border);
}

.status-badge:hover {
  transform: scale(1.03);
}

.status-time {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: normal;
  margin-top: 2px;
}

/* Action Buttons inside Table */
.action-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-whatsapp {
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 8px var(--wa-glow);
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-whatsapp:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px var(--wa-glow);
  background: linear-gradient(135deg, #2ae06e 0%, #159b8b 100%);
}

.btn-action-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-sub);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-action-icon:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.btn-action-icon.copy-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
}

/* ==========================================================================
   Empty State
   ========================================================================== */
.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 18px;
  color: var(--text-main);
  margin-bottom: 6px;
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: #fff;
  border-radius: 20px;
  max-width: 600px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  transform: scale(0.95);
  transition: var(--transition);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: var(--transition);
}

.modal-close:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

/* WhatsApp Message Bubble Simulation */
.wa-bubble-preview {
  background: #e5ddd5;
  background-image: radial-gradient(#d3c6ba 1px, transparent 1px);
  background-size: 16px 16px;
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid #d4cdc5;
}

.wa-message-bubble {
  background: #ffffff;
  border-radius: 12px 0 12px 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.6;
  color: #111b21;
}

.wa-bubble-time {
  text-align: left;
  font-size: 11px;
  color: #667781;
  margin-top: 6px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: #f8fafc;
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #0f172a;
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateY(20px);
  opacity: 0;
  transition: var(--transition);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success { border-right: 4px solid var(--success); }
.toast.info { border-right: 4px solid var(--primary); }
.toast.warning { border-right: 4px solid var(--warning); }

/* ==========================================================================
   View Mode Switcher Bar (Cards vs Table)
   ========================================================================== */
.view-mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.view-mode-pills {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px;
  box-shadow: var(--shadow-sm);
  width: 100%;
  max-width: 360px;
}

.view-pill {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.view-pill:hover {
  color: var(--text-main);
}

.view-pill.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.table-scroll-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--role-father);
  background: var(--role-father-bg);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(2, 132, 199, 0.2);
  animation: pulseHint 2s infinite ease-in-out;
}

@keyframes pulseHint {
  0%, 100% { opacity: 0.9; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.02); }
}

/* ==========================================================================
   Mobile Cards View (Responsive & Touch-Optimized)
   ========================================================================== */
.cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.recipient-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

.recipient-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.recipient-card.card-sent {
  background: #f8fafc;
  border-color: var(--success-border);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.08);
}

/* Card Header */
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.card-student-info {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.card-index-badge {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 4px 8px;
  border-radius: 8px;
  line-height: 1;
}

.card-student-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.card-student-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.3;
}

.card-student-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.card-status-pill {
  cursor: pointer;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  transition: var(--transition);
  user-select: none;
}

.card-status-pill.sent {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.card-status-pill.pending {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.card-status-pill:hover {
  transform: scale(1.04);
}

/* Card Body */
.card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.card-parent-details {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-parent-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.card-phone-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-phone-link {
  font-size: 14px;
  font-weight: 800;
  color: var(--role-father);
  text-decoration: none;
  background: var(--role-father-bg);
  padding: 4px 10px;
  border-radius: 8px;
  transition: var(--transition);
}

.card-phone-link:hover {
  background: var(--role-father);
  color: #fff;
}

/* Credentials Box */
.card-creds-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.card-cred-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cred-label {
  color: var(--text-muted);
  font-weight: 600;
}

.cred-value {
  color: var(--text-main);
  font-weight: 700;
}

.btn-cred-copy {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 12px;
  color: var(--text-sub);
  border-radius: 4px;
}

.btn-cred-copy:hover {
  background: rgba(0,0,0,0.06);
  color: var(--primary);
}

.card-sent-time {
  font-size: 11px;
  color: var(--success);
  font-weight: 700;
}

/* Card Actions */
.card-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.card-main-action {
  width: 100%;
  justify-content: center;
  padding: 12px;
  font-size: 15px;
  font-weight: 800;
  border-radius: 12px;
}

.card-secondary-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-secondary-actions .btn-action-icon {
  flex: 1;
  width: auto;
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 900px) {
  .header-content {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
  }
  .toolbar-card {
    flex-direction: column;
    align-items: stretch;
  }
  .search-box {
    width: 100%;
  }
  .filter-group {
    width: 100%;
    justify-content: space-between;
  }
  .toolbar-actions {
    width: 100%;
    justify-content: stretch;
  }
  .toolbar-actions .btn {
    flex: 1;
  }
  .data-table th, .data-table td {
    padding: 10px 12px;
  }

  /* Sticky right columns in table mode */
  .data-table th:first-child,
  .data-table td:first-child {
    position: sticky;
    right: 0;
    background: #fff;
    z-index: 10;
    box-shadow: -2px 0 4px rgba(0, 0, 0, 0.04);
  }
  .data-table thead th:first-child {
    background: #f8fafc;
    z-index: 11;
  }
  .data-table th:nth-child(2),
  .data-table td:nth-child(2) {
    position: sticky;
    right: 40px;
    background: #fff;
    z-index: 10;
    box-shadow: -3px 0 6px rgba(0, 0, 0, 0.06);
  }
  .data-table thead th:nth-child(2) {
    background: #f8fafc;
    z-index: 11;
  }
  .data-table tbody tr.row-sent td:first-child,
  .data-table tbody tr.row-sent td:nth-child(2) {
    background: #f0fdf4;
  }
}

@media (max-width: 600px) {
  .container {
    padding: 12px 10px 60px 10px;
  }
  .header-content {
    padding: 12px 12px;
    gap: 12px;
  }
  .brand-icon {
    width: 40px;
    height: 40px;
    font-size: 22px;
  }
  .brand-text h1 {
    font-size: 16px;
    flex-wrap: wrap;
  }
  .brand-text p {
    font-size: 11.5px;
  }
  .header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    width: 100%;
  }
  .connection-pill {
    padding: 4px 8px;
    font-size: 11px;
  }
  .mode-toggle-group {
    flex: 1;
    min-width: 160px;
  }
  .mode-btn {
    padding: 5px 8px;
    font-size: 11px;
  }
  .btn-change-phone-global {
    padding: 6px 10px;
    font-size: 12px;
  }
  .btn-logout {
    padding: 6px 10px;
    font-size: 12px;
  }
  .btn-icon {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  /* Compact 2-column stats on mobile */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
  }
  .stat-card {
    padding: 12px 10px;
  }
  .stat-value {
    font-size: 20px;
  }
  .stat-label {
    font-size: 11px;
  }
  .stat-icon-wrapper {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  /* Full-width segmented filter pills on mobile */
  .toolbar-card {
    padding: 12px;
    gap: 12px;
    margin-bottom: 16px;
  }
  .filter-group {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .filter-pills {
    width: 100%;
    display: flex;
  }
  .filter-pill {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    font-size: 12px;
  }

  .view-mode-pills {
    max-width: 100%;
  }

  .cards-container {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

/* ==========================================================================
   Edit Phone Modal & Phone Change System Styles (Orbyte V3 Design)
   ========================================================================== */

/* Global Change Phone Button in Header */
.btn-change-phone-global {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  background: rgba(2, 132, 199, 0.1);
  color: var(--role-father);
  border: 1px solid rgba(2, 132, 199, 0.25);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-main);
  cursor: pointer;
  transition: var(--transition);
}

.btn-change-phone-global:hover {
  background: var(--role-father);
  color: #fff;
  border-color: var(--role-father);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
  transform: translateY(-1px);
}

/* Mini Edit Button next to phone cell */
.phone-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-mini-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  opacity: 0.6;
  transition: var(--transition);
}

.phone-cell:hover .btn-mini-edit,
.btn-mini-edit:hover {
  opacity: 1;
  background: rgba(2, 132, 199, 0.12);
  border-color: rgba(2, 132, 199, 0.3);
  color: var(--role-father);
  transform: scale(1.08);
}

/* Edit action icon button in table row */
.btn-action-icon.edit-phone-btn {
  background: rgba(2, 132, 199, 0.08);
  border-color: rgba(2, 132, 199, 0.2);
  color: var(--role-father);
}

.btn-action-icon.edit-phone-btn:hover {
  background: var(--role-father);
  color: #fff;
  border-color: var(--role-father);
}

/* Large Modal Card */
.modal-card-lg {
  max-width: 680px;
  width: 94%;
}

.modal-title-with-icon {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-icon-badge {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.modal-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
}

/* Lookup Section */
.phone-lookup-section {
  background: var(--bg-subtle);
  padding: 16px;
  border-radius: 14px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
}

.input-with-btn {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.input-with-btn .form-input {
  flex: 1;
}

/* Details Box */
.details-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 16px;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 20px;
}

@media (max-width: 600px) {
  .details-grid {
    grid-template-columns: 1fr;
  }
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.detail-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.detail-value {
  font-size: 14px;
  color: var(--text-main);
  font-weight: 700;
}

.text-danger {
  color: var(--danger) !important;
}

/* Associated Children Chips */
.associated-children-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

.children-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.children-chips-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.child-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.child-chip:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.child-chip-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.child-chip-meta {
  font-size: 11px;
  color: var(--text-sub);
  background: var(--bg-subtle);
  padding: 2px 8px;
  border-radius: 6px;
}

/* Phone Input Wrapper */
.phone-input-wrapper {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
  transition: var(--transition);
}

.phone-input-wrapper:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.phone-input-wrapper.is-valid {
  border-color: var(--success);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15);
}

.phone-input-wrapper.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15);
}

.country-prefix {
  padding: 12px 14px;
  background: var(--bg-subtle);
  font-weight: 700;
  font-size: 14px;
  color: var(--text-sub);
  border-left: 1px solid var(--border);
  user-select: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.phone-input {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 12px 14px !important;
  font-size: 16px !important;
  font-weight: 700 !important;
  letter-spacing: 1px;
}

.input-feedback {
  font-size: 12px;
  margin-top: 6px;
  color: var(--text-muted);
  font-weight: 500;
  transition: var(--transition);
}

.input-feedback.success {
  color: var(--success);
  font-weight: 700;
}

.input-feedback.error {
  color: var(--danger);
  font-weight: 700;
}

/* Sync Targets Checklist */
.sync-targets-box {
  margin-top: 18px;
  background: rgba(30, 58, 138, 0.03);
  border: 1px solid rgba(30, 58, 138, 0.12);
  border-radius: 14px;
  padding: 14px 16px;
}

.sync-targets-header {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 10px;
}

.sync-targets-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 0;
}

.sync-targets-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-sub);
}

.sync-targets-list li strong {
  color: var(--text-main);
  margin-left: 4px;
}

.sync-targets-list .check-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: var(--success-bg);
  color: var(--success);
  border-radius: 50%;
  font-weight: 900;
  font-size: 11px;
  flex-shrink: 0;
  margin-top: 2px;
}

/* Save button */
.btn-save-phone {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 11px 22px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-main);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-save-phone:hover:not(:disabled) {
  background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(2, 132, 199, 0.45);
}

.btn-save-phone:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* Modal Loading Spinner */
.modal-loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  text-align: center;
  gap: 12px;
  color: var(--text-sub);
  font-size: 14px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3.5px solid var(--border);
  border-top-color: var(--role-father);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   Fullscreen Protected Authentication Screen (Hostinger Cloud Security)
   ========================================================================== */
.auth-screen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 50% 20%, #1e3a8a 0%, #0f172a 100%);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.auth-container {
  width: 100%;
  max-width: 460px;
}

.auth-card {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  padding: 36px 28px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.2);
  text-align: center;
  transition: transform 0.3s ease;
}

.auth-card.shake {
  animation: authShake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes authShake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}

.auth-icon-badge {
  width: 68px;
  height: 68px;
  border-radius: 20px;
  background: rgba(30, 58, 138, 0.08);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin: 0 auto 16px auto;
  box-shadow: 0 8px 16px rgba(30, 58, 138, 0.1);
}

.auth-header-text h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
}

.auth-header-text p {
  font-size: 13px;
  color: var(--text-sub);
  line-height: 1.5;
}

.auth-notice-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-sub);
  font-weight: 600;
  margin: 18px 0 22px 0;
}

.password-field-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: #fff;
  transition: var(--transition);
  overflow: hidden;
}

.password-field-wrapper:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.password-input {
  width: 100%;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 12px 14px !important;
  font-size: 15px !important;
  font-family: inherit;
  letter-spacing: 0.5px;
}

.btn-toggle-eye {
  background: none;
  border: none;
  padding: 0 14px;
  cursor: pointer;
  font-size: 16px;
  opacity: 0.6;
  transition: var(--transition);
}

.btn-toggle-eye:hover {
  opacity: 1;
}

.auth-error-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  margin-top: 10px;
  text-align: right;
  line-height: 1.5;
}

.auth-remember-wrapper {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin: 16px 0 20px 0;
}

.checkbox-container {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.checkbox-container input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
  cursor: pointer;
}

.checkbox-label-text {
  font-size: 13px;
  color: var(--text-sub);
  font-weight: 600;
}

.btn-auth-login {
  width: 100%;
  background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 100%);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-main);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(30, 58, 138, 0.35);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-auth-login:hover:not(:disabled) {
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(30, 58, 138, 0.45);
}

.btn-auth-login:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.auth-card-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #f1f5f9;
  font-size: 11.5px;
  color: var(--text-muted);
}

.auth-card-footer strong {
  color: var(--primary);
}

/* Header Logout Button */
.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(239, 68, 68, 0.08);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-main);
  cursor: pointer;
  transition: var(--transition);
}

.btn-logout:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
  transform: translateY(-1px);
}


