/* ==========================================================
   مُوكِّل — styles.css v8 (UI/UX Overhaul & Royal Navy/Gold Theme)
   ========================================================== */

:root {
  --navy-950: #0b1329;
  --navy-900: #0f172a;
  --navy-800: #1e293b;
  --navy-700: #334155;
  --gold-50: #fefce8;
  --gold-100: #fef9c3;
  --gold-200: #fef08a;
  --gold-400: #facc15;
  --gold-500: #eab308;
  --gold-600: #d97706;
  --gold-700: #b45309;
  --gold-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  --navy-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  --navy-gold-border: rgba(217, 119, 6, 0.35);
}

/* ============ Topbar ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border, #e2e8f0);
}

.menu-btn {
  width: 44px;
  height: 44px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius, 10px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text, #1e293b);
  transition: all var(--transition-fast, 0.15s ease);
}
.menu-btn:hover {
  background: var(--gray-100, #f1f5f9);
  border-color: var(--border, #e2e8f0);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-logo {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-radius: var(--radius, 10px);
  overflow: hidden;
}
.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.brand h1 {
  font-size: 17px;
  font-weight: 800;
  margin: 0;
  color: var(--text, #0f172a);
  letter-spacing: -0.02em;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.icon-btn {
  width: 44px;
  height: 44px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius, 10px);
  color: var(--text-soft, #64748b);
  cursor: pointer;
  transition: all var(--transition-fast, 0.15s ease);
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover {
  background: var(--gray-100, #f1f5f9);
  border-color: var(--border, #e2e8f0);
  color: var(--text, #0f172a);
}
.icon-btn.danger:hover {
  background: var(--danger-50, #fee2e2);
  color: var(--danger, #ef4444);
  border-color: var(--danger-50, #fee2e2);
}

/* ============ Drawer ============ */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition, 0.25s ease);
}
.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: -340px;
  width: 320px;
  max-width: 90vw;
  height: 100vh;
  background: var(--surface, #ffffff);
  z-index: 201;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl, 0 20px 25px -5px rgba(0, 0, 0, 0.1));
  transition: right var(--transition-slow, 0.3s cubic-bezier(0.4, 0, 0.2, 1));
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.drawer.open { right: 0; }

.drawer-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  background: linear-gradient(135deg, var(--navy-900) 0%, #1e1b4b 100%);
  color: white;
  border-bottom: 2px solid var(--gold-600);
}
.drawer-logo {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md, 12px);
  object-fit: contain;
  background: white;
  padding: 4px;
  display: none;
}
.drawer-logo[src]:not([src=""]) { display: block; }
.drawer-title {
  font-size: 16px;
  font-weight: 800;
  color: white;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}
.drawer-subtitle {
  font-size: 12.5px;
  color: var(--gold-400);
  font-weight: 600;
}

.drawer-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 20px;
}

.drawer-section {
  padding: 4px 0;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  cursor: pointer;
  color: var(--text-soft, #64748b);
  font-size: 14px;
  font-weight: 600;
  border: none;
  background: none;
  width: 100%;
  text-align: right;
  font-family: var(--font-sans);
  border-radius: var(--radius, 10px);
  transition: all var(--transition-fast, 0.15s ease);
  margin-bottom: 2px;
  letter-spacing: -0.01em;
}

.drawer-item:hover {
  background: var(--gray-50, #f8fafc);
  color: var(--text, #0f172a);
}

.drawer-item.active {
  background: #f1f5f9;
  color: var(--navy-900);
  font-weight: 700;
  border-right: 3px solid var(--gold-600);
}

.drawer-item .icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  flex-shrink: 0;
}

.drawer-footer {
  border-top: 1px solid var(--border-soft, #f1f5f9);
  padding: 16px 20px;
}

.drawer-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--navy-900) 0%, var(--gold-600) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text, #0f172a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 11.5px;
  color: var(--text-soft, #64748b);
  font-weight: 500;
}

/* ============ Main Container ============ */
#app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px 80px;
  animation: fade-up 0.3s var(--ease-out, ease-out);
}

.app-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 24px;
  gap: 12px;
}
.app-top h2 {
  font-size: 24px;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.02em;
}

/* ============ Royal Navy & Gold Case Cards ============ */
.royal-case-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 18px 20px;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.royal-case-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 5px;
  background: linear-gradient(180deg, var(--gold-500) 0%, var(--gold-700) 100%);
  border-radius: 0 16px 16px 0;
}

.royal-case-card:hover {
  transform: translateY(-2px);
  border-color: #cbd5e1;
  box-shadow: 0 10px 24px -4px rgba(15, 23, 42, 0.08), 0 0 0 1px rgba(217, 119, 6, 0.15);
}

.case-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-right: 6px;
}

.case-card-title-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.case-card-num {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 16.5px;
  font-weight: 800;
  color: var(--navy-900);
  font-family: var(--font-sans);
}

.case-card-client {
  font-size: 13.5px;
  color: #475569;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.case-card-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-right: 6px;
}

.case-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}

.case-badge-court {
  background: #f8fafc;
  color: #1e293b;
  border: 1px solid #e2e8f0;
}

.case-badge-circuit {
  background: var(--gold-50);
  color: var(--gold-700);
  border: 1px solid var(--gold-200);
}

.case-badge-hearing {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}
.case-badge-hearing.has-date {
  background: #fefce8;
  color: #92400e;
  border: 1px solid #fde68a;
  font-family: var(--font-mono);
}

.case-badge-type {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
}

.case-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
  padding-right: 6px;
}

.case-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ============ AI Analysis Button ============ */
.btn-ai-analyze {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #312e81 100%);
  color: #fef08a;
  border: 1px solid rgba(250, 204, 21, 0.4);
  border-radius: 12px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.15);
  transition: all 0.2s ease;
}

.btn-ai-analyze:hover {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #ffffff;
  border-color: #facc15;
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.25);
  transform: translateY(-1px);
}

.btn-ai-analyze .ai-sparkle {
  font-size: 15px;
  color: #facc15;
  animation: pulse-gold 2s infinite ease-in-out;
}

@keyframes pulse-gold {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.15); }
}

/* ============ Detail Tabs & Detail Cards ============ */
.case-tabs-container {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  padding: 4px;
  background: #f1f5f9;
  border-radius: 14px;
  overflow-x: auto;
  scrollbar-width: none;
}
.case-tabs-container::-webkit-scrollbar { display: none; }

.case-detail-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 700;
  font-family: var(--font-sans);
  color: #64748b;
  background: transparent;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  flex: 1;
  min-width: fit-content;
}

.case-detail-tab:hover {
  color: var(--navy-900);
}

.case-detail-tab.active {
  background: var(--navy-900);
  color: #fef08a;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
}

.case-section-box {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
}

.case-section-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}

.case-section-box-header h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: var(--navy-900);
  display: flex;
  align-items: center;
  gap: 8px;
}

.case-grid-items {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.case-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #f8fafc;
  font-size: 13.5px;
}
.case-info-row:last-child { border-bottom: none; }
.case-info-row .label { color: #64748b; font-weight: 600; }
.case-info-row .val { color: #0f172a; font-weight: 700; }

.sub-item-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.2s ease;
}
.sub-item-card:hover {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 4px 10px rgba(0,0,0,0.03);
}

.sub-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sub-item-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy-900);
}

.sub-item-meta {
  font-size: 12.5px;
  color: #64748b;
  line-height: 1.5;
}

.sub-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

/* ============ Detail View Hero Banner ============ */
.case-hero-banner {
  background: linear-gradient(135deg, #0b1329 0%, #1e293b 70%, #1e1b4b 100%);
  border: 1px solid rgba(217, 119, 6, 0.4);
  border-radius: 20px;
  padding: 24px 28px;
  color: white;
  margin-bottom: 24px;
  box-shadow: 0 12px 32px -8px rgba(15, 23, 42, 0.35);
  position: relative;
  overflow: hidden;
}

.case-hero-banner::after {
  content: '';
  position: absolute;
  top: -50px;
  left: -50px;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.15) 0%, transparent 70%);
  pointer-events: none;
}

.case-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.case-hero-title {
  font-size: 24px;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.02em;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.case-hero-sub {
  font-size: 14px;
  color: #cbd5e1;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.case-hero-pills {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.case-hero-pill {
  padding: 6px 14px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.case-hero-pill.gold {
  background: rgba(245, 158, 11, 0.2);
  color: #fde047;
  border: 1px solid rgba(245, 158, 11, 0.4);
}
.case-hero-pill.navy {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* ============ Stats Grid ============ */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat {
  background: var(--surface, #ffffff);
  border: 1px solid var(--border-soft, #e2e8f0);
  border-radius: var(--radius-md, 14px);
  padding: 20px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
  transition: all var(--transition, 0.2s ease);
  position: relative;
  overflow: hidden;
}

.stat::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  background: var(--navy-900);
  opacity: 0;
  transition: opacity var(--transition, 0.2s ease);
}

.stat:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.06);
  border-color: var(--border, #cbd5e1);
}

.stat:hover::before { opacity: 1; }

.stat .l {
  font-size: 12.5px;
  color: var(--text-soft, #64748b);
  margin-bottom: 8px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat .n {
  font-size: 26px;
  font-weight: 800;
  color: var(--text, #0f172a);
  line-height: 1.2;
  letter-spacing: -0.03em;
  font-family: var(--font-mono);
}

.stat .n.primary { color: var(--navy-900); }
.stat .n.success { color: #10b981; }
.stat .n.danger { color: #ef4444; }
.stat .n.gold { color: var(--gold-600); }

/* ============ Filter Bar ============ */
.filter-bar {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 16px;
}
.filter-bar-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.filter-item {
  flex: 1;
  min-width: 160px;
}
.filter-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  background: #f8fafc;
  color: #1e293b;
}
.filter-input:focus {
  outline: none;
  border-color: var(--navy-900);
  background: #ffffff;
}

.filter-tabs {
  display: flex;
  gap: 8px;
}
.filter-tabs button {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s ease;
}
.filter-tabs button.active {
  background: var(--navy-900);
  color: #ffffff;
  border-color: var(--navy-900);
}

/* ============ Badges & Utilities ============ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1;
}
.badge.active {
  background: #dcfce7;
  color: #15803d;
}
.badge.suspended {
  background: #fee2e2;
  color: #b91c1c;
}
.badge.trial {
  background: #fef3c7;
  color: #b45309;
}

.btn {
  min-height: 40px;
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-sans);
  border: 1px solid transparent;
}
.btn-primary, button.primary {
  background: var(--navy-900);
  color: white;
  border: 1px solid var(--navy-900);
}
.btn-primary:hover, button.primary:hover {
  background: #1e293b;
}

.btn-ghost, button.ghost {
  background: transparent;
  color: #475569;
  border: 1px solid #e2e8f0;
}
.btn-ghost:hover, button.ghost:hover {
  background: #f8fafc;
  color: #0f172a;
}

/* ============ Modal ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 28px;
  width: 100%;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
  animation: fade-up 0.3s ease;
  max-height: 90vh;
  overflow-y: auto;
}

/* ============ Bottom Nav (Mobile) ============ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 150;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid #e2e8f0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
}
.bottom-nav:not([hidden]) { display: block; }
.bottom-nav-inner {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  max-width: 600px;
  margin: 0 auto;
}
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 4px 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 600;
  color: #64748b;
  transition: all 0.2s;
  position: relative;
}
.bottom-nav-item.active {
  color: var(--navy-900);
}
.bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40%;
  height: 3px;
  background: var(--gold-600);
  border-radius: 0 0 4px 4px;
}

.signup-logo img {
  width: 48px !important;
  height: 48px !important;
  object-fit: contain !important;
}

.brand-logo img, .landing-logo img {
  max-width: 48px;
  max-height: 48px;
  object-fit: contain;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
  .menu-btn { display: none !important; }
  .bottom-nav:not([hidden]) { display: block !important; }
  #app { padding-bottom: 90px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .case-card-header { flex-direction: column; }
  .case-hero-banner { padding: 18px 20px; }
  .case-hero-title { font-size: 20px; }
}
