/* ================================================================
   TECHCARE COMMON DESIGN SYSTEM (Pure CSS - Mobile First Optimized)
   Theme: Modern Tech Blue & White with Fluid Animations
   ================================================================ */

:root {
  /* Brand Blue & White Palette */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-active: #1e40af;
  --primary-dark: #172554;
  --primary-light: #eff6ff;
  --primary-subtle: #f0f7ff;
  --primary-border: #bfdbfe;
  --primary-glow: rgba(37, 99, 235, 0.25);
  
  --secondary: #3b82f6;
  --secondary-hover: #2563eb;
  --secondary-light: #f8fafc;
  
  /* Status Colors with Clean Modern Tints */
  --success: #059669;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --success-text: #065f46;
  
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  --warning-text: #92400e;
  
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --danger-text: #991b1b;

  --info: #0284c7;
  --info-bg: #f0f9ff;
  --info-border: #bae6fd;
  --info-text: #0369a1;

  /* Surfaces & Backgrounds - Blue & White */
  --bg-main: #f4f8fd;
  --bg-card: #ffffff;
  --bg-subtle: #f0f5fc;
  --bg-elevated: #ffffff;
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-light: #64748b;
  --text-white: #ffffff;
  
  --border: #e2e8f0;
  --border-focus: #2563eb;
  --border-subtle: #edf2f7;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 2px 6px -1px rgba(37, 99, 235, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 16px -3px rgba(37, 99, 235, 0.08), 0 3px 6px -2px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 16px 30px -5px rgba(37, 99, 235, 0.12), 0 6px 12px -3px rgba(15, 23, 42, 0.05);
  --shadow-xl: 0 25px 45px -10px rgba(37, 99, 235, 0.18), 0 10px 18px -4px rgba(15, 23, 42, 0.06);
  
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --transition-smooth: all 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Base reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ==============================================================
   ANIMATIONS & KEYFRAMES
   ============================================================== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes sheetSlideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes pulseGlow {
  0% {
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.5);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(37, 99, 235, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0);
  }
}

@keyframes pulseDot {
  0% { transform: scale(0.95); opacity: 0.9; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.9; }
}

@keyframes shimmerEffect {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.anim-fade-in-up {
  animation: fadeInUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ==============================================================
   HEADER COMPONENT (STICKY & RESPONSIVE)
   ============================================================== */
.app-header {
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-xs);
  transition: var(--transition-smooth);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text-main);
  cursor: pointer;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.25rem;
  font-weight: 800;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.brand:hover .brand-icon {
  transform: scale(1.05);
}

.role-tag {
  font-size: 0.72rem;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 0.25rem;
  white-space: nowrap;
}

.tag-user { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.tag-provider { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.tag-admin { background: #eff6ff; color: #1e3a8a; border: 1px solid #93c5fd; }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.hub-switch-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-full);
  background: #ffffff;
  border: 1px solid #cbd5e1;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: var(--transition-smooth);
  white-space: nowrap;
}

.hub-switch-pill:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: var(--primary);
  transform: translateY(-1px);
}

/* ==============================================================
   CONTAINER & LAYOUT
   ============================================================== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem 1rem;
}

/* ==============================================================
   BUTTONS (TOUCH FRIENDLY - MIN 44PX TARGETS)
   ============================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  min-height: 44px;
  font-size: 0.92rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition-smooth);
  text-align: center;
  user-select: none;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.38);
}

.btn-success {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
}
.btn-success:hover:not(:disabled) {
  background: #047857;
  box-shadow: 0 6px 16px rgba(5, 150, 105, 0.35);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
}
.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
  box-shadow: 0 6px 16px rgba(220, 38, 38, 0.35);
}

.btn-outline {
  background: #ffffff;
  color: var(--text-main);
  border-color: #cbd5e1;
}
.btn-outline:hover:not(:disabled) {
  background: #eff6ff;
  border-color: #93c5fd;
  color: var(--primary);
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  min-height: 38px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

/* ==============================================================
   BADGES & CHIPS
   ============================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulseDot 2s infinite ease-in-out;
}

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

.badge-accepted {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.badge-in-progress {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

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

.badge-rejected, .badge-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
}

.badge-device {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* ==============================================================
   CARDS & PANELS
   ============================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
}

.card:hover {
  border-color: #bfdbfe;
}

/* ==============================================================
   FORMS & INPUTS (MOBILE OPTIMIZED: 16PX BASE TO PREVENT ZOOM)
   ============================================================== */
.form-group {
  margin-bottom: 1.15rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  padding: 0.7rem 0.95rem;
  font-size: 16px; /* Prevents auto-zoom on mobile */
  font-family: inherit;
  color: var(--text-main);
  background-color: #ffffff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition-smooth);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3.5px var(--primary-glow);
}

.form-control::placeholder {
  color: #94a3b8;
}

.form-hint {
  font-size: 0.76rem;
  color: var(--text-light);
  margin-top: 0.35rem;
}

/* ==============================================================
   MODALS (DESKTOP CENTERED + MOBILE BOTTOM SHEET)
   ============================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-box {
  background: #ffffff;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transform: scale(0.94);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid var(--border);
}

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

.confirmation-overlay {
  z-index: 2000;
}

.confirmation-dialog {
  width: min(440px, 100%);
  max-height: calc(100vh - 2rem);
  padding: 1.6rem;
  align-items: center;
  text-align: center;
}

.confirmation-icon {
  display: grid;
  width: 48px;
  height: 48px;
  margin-bottom: 0.9rem;
  place-items: center;
  border: 1px solid #fed7aa;
  border-radius: 50%;
  background: #fff7ed;
  color: #c2410c;
  font-size: 1.5rem;
  font-weight: 800;
}

.confirmation-title {
  margin: 0;
  color: #17233b;
  font-size: 1.15rem;
  font-weight: 800;
}

.confirmation-message {
  width: 100%;
  margin: 0.75rem 0 1.25rem;
  color: #58667c;
  font-size: 0.9rem;
  line-height: 1.55;
  text-align: left;
  white-space: pre-line;
}

.confirmation-actions {
  display: flex;
  width: 100%;
  justify-content: flex-end;
  gap: 0.6rem;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: #ffffff;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #0f172a;
}

.modal-close {
  background: #f1f5f9;
  border: none;
  font-size: 1.4rem;
  color: #64748b;
  cursor: pointer;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.modal-close:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.modal-body {
  padding: 1.35rem 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  background: #f8fafc;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ==============================================================
   TOAST NOTIFICATIONS
   ============================================================== */
#toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  left: 1.25rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  align-items: flex-end;
}

.toast {
  pointer-events: auto;
  background: #0f172a;
  color: #ffffff;
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  animation: fadeInUp 0.25s ease-out;
  min-width: 280px;
  max-width: 460px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.toast.toast-success { background: #064e3b; border-left: 4px solid #10b981; }
.toast.toast-danger { background: #7f1d1d; border-left: 4px solid #ef4444; }
.toast.toast-warning { background: #78350f; border-left: 4px solid #f59e0b; }
.toast.toast-info { background: #1e3a8a; border-left: 4px solid #3b82f6; }

/* Real-time live status indicator */
.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.76rem;
  font-weight: 700;
  color: #1e40af;
  background: #eff6ff;
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-full);
  border: 1px solid #bfdbfe;
  white-space: nowrap;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2563eb;
  box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.7);
  animation: pulseGlow 1.8s infinite;
}

/* ==============================================================
   GRID HELPERS
   ============================================================== */
.grid {
  display: grid;
  gap: 1.25rem;
}

.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Responsive tables container */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: #ffffff;
}

/* ==============================================================
   MOBILE SPECIFIC RULES (<= 640px)
   Converts Modals to Mobile Bottom Sheets & Full Touch UI
   ============================================================== */
@media (max-width: 900px) {
  .grid-cols-3, .grid-cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .container {
    padding: 0.85rem 0.75rem 5rem 0.75rem;
  }

  .grid-cols-2, .grid-cols-3, .grid-cols-4 {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .header-inner {
    padding: 0.65rem 0.75rem;
    gap: 0.5rem;
  }

  /* Mobile Bottom Sheet Modals */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal-box {
    border-radius: 24px 24px 0 0;
    max-height: 92vh;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .modal-overlay.active .modal-box {
    transform: translateY(0);
  }

  .modal-header {
    padding: 1rem 1.25rem;
  }

  .modal-body {
    padding: 1rem 1.25rem;
  }

  .modal-footer {
    padding: 0.85rem 1.25rem;
    justify-content: stretch;
  }

  .modal-footer .btn {
    flex: 1;
    min-height: 46px;
  }

  #toast-container {
    right: 0.75rem;
    left: 0.75rem;
    bottom: 4.5rem;
    align-items: stretch;
  }

  .toast {
    min-width: unset;
    width: 100%;
  }

  .btn {
    min-height: 44px;
  }
}
