/* ============================================
   MyMedikoz Claims Portal — Styles
   ============================================ */

:root {
  --primary: #2A53C1;
  --primary-light: #EEF1FB;
  --primary-dark: #1a3a8f;
  --success: #38A169;
  --success-light: #F0FFF4;
  --warning: #D69E2E;
  --warning-light: #FFFFF0;
  --danger: #E53E3E;
  --danger-light: #FFF5F5;
  --gray-50: #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-300: #CBD5E1;
  --gray-400: #94A3B8;
  --gray-500: #64748B;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1E293B;
  --gray-900: #0F172A;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }

/* Screens */
.screen { display: none; }
.screen.active { display: block; }

/* ── Login ── */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #F8FAFC 0%, #EEF1FB 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: white;
  border-radius: 16px;
  padding: 40px;
  box-shadow: var(--shadow-md);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.logo {
  font-size: 24px;
  font-weight: 800;
  color: var(--primary);
}

.logo span {
  font-weight: 500;
  color: var(--gray-500);
  font-size: 18px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 4px;
}

.login-note {
  font-size: 11px;
  color: var(--gray-400);
  text-align: center;
  margin-top: 20px;
  line-height: 1.6;
}

/* ── Forms ── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: white;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(42,83,193,0.1);
}

/* ── Buttons ── */
.btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { opacity: 0.9; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { opacity: 0.9; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }
.btn-ghost { background: transparent; color: var(--gray-500); border: 1px solid var(--gray-200); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); border-radius: var(--radius); padding: 6px 14px; cursor: pointer; font-weight: 500; transition: all 0.15s; }
.btn-outline:hover { background: var(--primary-light); }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Top Nav ── */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: white;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-logo {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary);
}

.nav-logo span {
  font-weight: 500;
  color: var(--gray-400);
  font-size: 14px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--gray-600);
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
}
.badge-role {
  background: var(--gray-100);
  color: var(--gray-600);
  margin-left: 4px;
}

/* ── Stats ── */
.stats-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 20px 24px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--gray-200);
}

.stat-number {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
}

.stat-label {
  font-size: 11px;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* ── Tabs ── */
.tabs-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  margin-bottom: 4px;
}

.tabs {
  display: flex;
  gap: 4px;
}

.tab {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--gray-500);
  transition: all 0.2s;
}

.tab:hover { background: var(--gray-100); }
.tab.active { background: var(--primary); color: white; }

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  color: var(--gray-400);
  width: 300px;
}

.search-bar input {
  border: none;
  outline: none;
  font-size: 13px;
  font-family: inherit;
  width: 100%;
  color: var(--gray-700);
}

/* ── Claims List ── */
.claims-container {
  padding: 16px 24px;
}

.claims-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.claim-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  cursor: pointer;
  transition: all 0.15s;
}

.claim-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(42,83,193,0.08);
}

.claim-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: 14px;
  flex-shrink: 0;
}

.claim-info {
  flex: 1;
  min-width: 0;
}

.claim-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--gray-800);
}

.claim-meta {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 2px;
}

.claim-amount {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-800);
  text-align: right;
  min-width: 120px;
}

.claim-date {
  font-size: 12px;
  color: var(--gray-400);
  text-align: right;
  min-width: 100px;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  min-width: 80px;
  text-align: center;
}

.status-submitted, .status-pending, .status-under_review {
  background: #EBF5FF;
  color: #2B6CB0;
}

.status-approved {
  background: var(--success-light);
  color: var(--success);
}

.status-denied {
  background: var(--danger-light);
  color: var(--danger);
}

.status-queried {
  background: var(--warning-light);
  color: var(--warning);
}

/* ── Modal ── */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1000;
}

.modal.active { display: flex; }

.modal-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
}

.modal-content {
  position: relative;
  width: 95%;
  max-width: 1100px;
  max-height: 92vh;
  margin: auto;
  background: white;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

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

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--gray-100);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-500);
}

.modal-close:hover { background: var(--gray-200); }

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

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.detail-section {
  margin-bottom: 20px;
}

.detail-section h3 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-100);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-50);
}

.detail-label {
  font-size: 13px;
  color: var(--gray-500);
}

.detail-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
}

.detail-value.amount {
  color: var(--primary);
  font-size: 16px;
  font-weight: 700;
}

/* Patient Header */
.patient-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.patient-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}

.patient-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-800);
}

.patient-meta {
  font-size: 12px;
  color: var(--gray-500);
}

/* Health History Tabs */
.history-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.history-tab {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--gray-200);
  background: white;
  color: var(--gray-500);
  transition: all 0.2s;
}

.history-tab:hover { background: var(--gray-50); }
.history-tab.active { background: var(--primary); color: white; border-color: var(--primary); }

.health-history {
  background: var(--gray-50);
  border-radius: 8px;
  padding: 16px;
  min-height: 200px;
  max-height: 300px;
  overflow-y: auto;
}

.history-item {
  padding: 10px 12px;
  background: white;
  border-radius: 8px;
  border: 1px solid var(--gray-200);
  margin-bottom: 8px;
}

.history-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
}

.history-item-meta {
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 2px;
}

/* Flags */
.flags-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.flag-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  background: #FFF5F5;
  border: 1px solid #FED7D7;
  border-radius: 8px;
  font-size: 12px;
  color: #C53030;
  line-height: 1.5;
}

.flag-icon { font-size: 14px; flex-shrink: 0; }

/* Action Panel */
.action-panel {
  background: var(--gray-50);
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
}

.action-buttons {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.action-buttons .btn { flex: 1; }

/* Attachments */
.attachments-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--gray-50);
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.attachment-item:hover { background: var(--gray-100); }

.attachment-icon { font-size: 16px; }

/* Empty / Loading States */
.loading-state, .empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
  font-size: 14px;
}

.empty-text {
  font-size: 12px;
  color: var(--gray-400);
  text-align: center;
  padding: 20px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .stats-container { grid-template-columns: repeat(2, 1fr); }
  .tabs-container { flex-direction: column; gap: 12px; }
  .search-bar { width: 100%; }
  .detail-grid { grid-template-columns: 1fr; }
  .modal-content { width: 100%; max-height: 100vh; border-radius: 0; }
  .claims-container { padding: 16px; }
  .top-nav { padding: 12px 16px; }
  .stats-container { padding: 16px; }
  .tabs-container { padding: 0 16px; }
}

/* ============================================
   Primary Nav (Claims | Members)
   ============================================ */
.primary-nav-container {
  padding: 14px 24px 0;
  border-bottom: 1px solid var(--gray-200);
  background: #fff;
}
.primary-nav {
  display: flex;
  gap: 4px;
}
.primary-tab {
  background: none;
  border: none;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}
.primary-tab:hover {
  color: var(--gray-700);
}
.primary-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* View switching */
.view {
  display: none;
}
.view.active {
  display: block;
}

/* ============================================
   Member Visits List (inside member modal)
   ============================================ */
.member-visits-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.visit-item {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 12px 14px;
}
.visit-title {
  font-weight: 600;
  color: var(--gray-800);
  font-size: 14px;
  margin-bottom: 2px;
}
.visit-meta {
  font-size: 12px;
  color: var(--gray-500);
  margin-bottom: 8px;
}
.visit-cost-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--gray-600);
  padding-top: 8px;
  border-top: 1px dashed var(--gray-200);
}
.visit-cost-row strong {
  color: var(--gray-800);
  font-weight: 600;
}

/* ============================================
   Chip list (allergies, conditions)
   ============================================ */
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}
.chip-red {
  background: var(--danger-light);
  color: var(--danger);
  border-color: rgba(229, 62, 62, 0.3);
}
.chip-amber {
  background: var(--warning-light);
  color: var(--warning);
  border-color: rgba(214, 158, 46, 0.3);
}

/* Members search + request button row */
.members-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}
.members-actions .search-bar {
  flex: 1 1 200px;
  min-width: 0;
}
.members-actions .btn { white-space: nowrap; flex-shrink: 0; }
.members-actions .full-label { display: inline; }
.members-actions .short-label { display: none; }

/* ============================================
   Mobile responsiveness + Bottom nav bar
   ============================================ */
.bottom-nav { display: none; }

@media (max-width: 720px) {
  html, body { max-width: 100vw; overflow-x: hidden; }
  body { padding-bottom: 64px; }
  * { min-width: 0; box-sizing: border-box; }

  .top-nav { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
  .nav-logo { font-size: 14px; }
  .nav-logo { font-size: 15px; }
  .nav-user { display: none; }
  .nav-right .btn-ghost { display: none; }
  .primary-nav-container { display: none; }

  .stats-container { grid-template-columns: repeat(2, 1fr); padding: 12px 14px 0; gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-number { font-size: 22px; }

  .tabs-container { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px 14px 0; }
  .tabs { overflow-x: auto; flex-wrap: nowrap; }
  .tab { white-space: nowrap; }
  .search-bar { width: 100%; }

  /* Stack search + Request button on mobile so neither overflows */
  .members-actions { flex-direction: column; align-items: stretch; }
  .members-actions .search-bar { flex: 1 1 auto; }
  .members-actions .btn { width: 100%; }
  .members-actions .full-label { display: none; }
  .members-actions .short-label { display: inline; }

  .claims-container { padding: 12px 14px 16px; }
  .claim-card {
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 12px;
    align-items: center;
  }
  .claim-card .claim-info { flex: 1 1 100%; min-width: 0; }
  .claim-card .claim-name,
  .claim-card .claim-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .claim-card .claim-amount { font-size: 13px; }
  .claim-card .claim-date { display: none; } /* save horizontal space */
  .claim-card .status-badge { font-size: 10px; padding: 2px 8px; }
  .stat-card .stat-label { font-size: 10px; }
  .stat-card .stat-number { font-size: 20px; }

  /* Modals: full screen on phone */
  .modal-content { width: 100% !important; max-width: 100% !important; max-height: 100vh; height: 100vh; border-radius: 0 !important; margin: 0 !important; }
  .modal-body { overflow-y: auto; }
  .detail-grid { grid-template-columns: 1fr !important; }

  .bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: white;
    border-top: 1px solid var(--gray-200);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    z-index: 50;
    padding: 6px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .bn-item {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 4px;
    font-family: inherit;
    color: var(--gray-500);
    font-size: 10px;
    font-weight: 600;
  }
  .bn-item span { line-height: 1; }
  .bn-item.active { color: var(--primary); }
}
