/* MediCore Hospital Management System - Global Styles */

/* CSS Custom Properties for theming */
:root {
  --bg-primary: #f8f9fa;
  --bg-surface: #ffffff;
  --bg-elevated: #ffffff;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --accent-primary: #2563eb;
  --accent-primary-light: #dbeafe;
  --accent-secondary: #10b981;
  --accent-tertiary: #f59e0b;
  --accent-danger: #ef4444;
  --border-color: #e5e7eb;
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --header-height: 64px;
  --radius-lg: 16px;
  --radius-md: 8px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

.dark {
  --bg-primary: #0f111a;
  --bg-surface: #1a1d29;
  --bg-elevated: #232736;
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --border-color: #2d3348;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #a1a1a1;
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

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

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(37, 99, 235, 0);
  }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

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

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

.animate-fade-in-up {
  animation: fadeInUp 0.5s ease-out forwards;
}

.animate-fade-in {
  animation: fadeIn 0.3s ease-out forwards;
}

.animate-slide-in-right {
  animation: slideInRight 0.3s ease-out forwards;
}

.animate-scale-in {
  animation: scaleIn 0.2s ease-out forwards;
}

.animate-pulse-glow {
  animation: pulse-glow 2s infinite;
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Stagger delay utilities */
.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.1s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.2s; }
.stagger-5 { animation-delay: 0.25s; }
.stagger-6 { animation-delay: 0.3s; }
.stagger-7 { animation-delay: 0.35s; }
.stagger-8 { animation-delay: 0.4s; }

/* Initial hidden state for scroll animations */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Public Navbar */
.public-navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  z-index: 50;
  transition: all 0.2s ease;
}

.dark .public-navbar {
  background: rgba(15, 17, 26, 0.9);
}

.nav-link {
  position: relative;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-link:hover {
  color: var(--accent-primary);
  background: var(--accent-primary-light);
}

.nav-link.active {
  color: var(--accent-primary);
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0.75rem;
  right: 0.75rem;
  height: 2px;
  background: var(--accent-primary);
  border-radius: 1px;
}

/* Mobile menu */
.mobile-menu {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
}
.mobile-menu.open {
  display: block;
}
.mobile-menu-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}
.mobile-menu-panel {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 280px;
  background: var(--bg-surface);
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}
.mobile-menu.open .mobile-menu-panel {
  transform: translateX(0);
}

/* Cards */
.mc-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.3s ease, transform 0.2s ease;
}

.mc-card:hover {
  box-shadow: var(--shadow-md);
}

/* Buttons */
.mc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  line-height: 1.25;
}

.mc-btn:active {
  transform: scale(0.98);
}

.mc-btn-primary {
  background: var(--accent-primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

.mc-btn-primary:hover {
  opacity: 0.9;
  box-shadow: var(--shadow-md);
}

.mc-btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.mc-btn-secondary:hover {
  background: var(--bg-primary);
}

.mc-btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.mc-btn-ghost:hover {
  background: var(--bg-primary);
}

.mc-btn-danger {
  background: var(--accent-danger);
  color: white;
}

.mc-btn-danger:hover {
  opacity: 0.9;
}

.mc-btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.mc-btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

/* Form inputs */
.mc-input {
  width: 100%;
  height: 2.75rem;
  padding: 0 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  transition: all 0.2s ease;
  outline: none;
}

.mc-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.mc-input::placeholder {
  color: var(--text-muted);
}

select.mc-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M4.646 5.646a.5.5 0 0 1 .708 0L8 8.293l2.646-2.647a.5.5 0 0 1 .708.708l-3 3a.5.5 0 0 1-.708 0l-3-3a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
}

textarea.mc-input {
  height: auto;
  min-height: 6rem;
  padding: 0.75rem;
  resize: vertical;
}

/* Badges */
.mc-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.mc-badge-success {
  background: #d1fae5;
  color: #065f46;
}

.mc-badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.mc-badge-danger {
  background: #fee2e2;
  color: #991b1b;
}

.mc-badge-info {
  background: #dbeafe;
  color: #1e40af;
}

.mc-badge-neutral {
  background: #f3f4f6;
  color: #374151;
}

.dark .mc-badge-success { background: #064e3b; color: #6ee7b7; }
.dark .mc-badge-warning { background: #78350f; color: #fcd34d; }
.dark .mc-badge-danger { background: #7f1d1d; color: #fca5a5; }
.dark .mc-badge-info { background: #1e3a5f; color: #93c5fd; }
.dark .mc-badge-neutral { background: #374151; color: #d1d5db; }

/* Department icon circles */
.dept-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: all 0.2s ease;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  min-width: 320px;
  max-width: 420px;
  animation: slideInRight 0.3s ease-out;
}

.toast.toast-exit {
  animation: fadeIn 0.3s ease-out reverse forwards;
}

/* Tables */
.mc-table {
  width: 100%;
  border-collapse: collapse;
}

.mc-table thead th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 10;
}

.mc-table tbody td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.mc-table tbody tr {
  transition: background 0.15s ease;
}

.mc-table tbody tr:hover {
  background: rgba(0, 0, 0, 0.02);
}

.dark .mc-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

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

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.pagination button {
  min-width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pagination button:hover:not(:disabled) {
  background: var(--bg-primary);
}

.pagination button.active {
  background: var(--accent-primary);
  color: white;
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.toggle-switch input {
  display: none;
}

.toggle-switch .toggle-track {
  width: 44px;
  height: 24px;
  background: #d1d5db;
  border-radius: 12px;
  position: relative;
  transition: background 0.2s ease;
}

.toggle-switch input:checked + .toggle-track {
  background: var(--accent-primary);
}

.toggle-switch .toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.toggle-switch input:checked + .toggle-track .toggle-thumb {
  transform: translateX(20px);
}

/* Admin Sidebar - FLEXBOX LAYOUT (not fixed) */
.admin-sidebar {
  position: relative;
  width: 16rem;
  min-width: 16rem;
  max-width: 16rem;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 10;
  transition: none;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Sidebar menu items */
.sidebar-menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  margin: 0.125rem 0.5rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
  position: relative;
}

.sidebar-menu-item:hover {
  background: var(--accent-primary-light);
  color: var(--accent-primary);
}

.sidebar-menu-item.active {
  background: var(--accent-primary-light);
  color: var(--accent-primary);
}

.sidebar-menu-item.active::before {
  content: '';
  position: absolute;
  left: -0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent-primary);
  border-radius: 0 2px 2px 0;
}

/* Stats cards */
.stat-card {
  position: relative;
  overflow: hidden;
}

.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.stat-card .stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
}

.stat-card .stat-trend.up {
  background: #d1fae5;
  color: #065f46;
}

.stat-card .stat-trend.down {
  background: #fee2e2;
  color: #991b1b;
}

.dark .stat-card .stat-trend.up { background: #064e3b; }
.dark .stat-card .stat-trend.down { background: #7f1d1d; }

/* Hero gradient text */
.gradient-text {
  background: linear-gradient(135deg, #2563eb 0%, #06b6d4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Horizontal scroll container */
.horizontal-scroll {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 0.5rem;
}

.horizontal-scroll::-webkit-scrollbar {
  display: none;
}

.horizontal-scroll > * {
  scroll-snap-align: start;
  flex-shrink: 0;
}

/* Command palette */
.command-palette {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
}

.command-palette-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.2s ease-out;
}

.command-palette-content {
  position: relative;
  width: 100%;
  max-width: 640px;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.2s ease-out;
  overflow: hidden;
}

.command-palette-input {
  width: 100%;
  padding: 1rem 1.25rem;
  padding-left: 3rem;
  border: none;
  border-bottom: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-primary);
  font-size: 1rem;
  outline: none;
}

.command-palette-input::placeholder {
  color: var(--text-muted);
}

/* Sheet/Drawer */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 50;
  animation: fadeIn 0.2s ease-out;
}

.sheet-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  z-index: 51;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}

.sheet-panel.open {
  transform: translateX(0);
}

/* Dropdown */
.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  padding: 0.5rem;
  z-index: 40;
  animation: scaleIn 0.15s ease-out;
  transform-origin: top right;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.dropdown-item:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--bg-primary) 25%, var(--bg-surface) 50%, var(--bg-primary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s ease;
}

.breadcrumb a:hover {
  color: var(--accent-primary);
}

/* ========== RESPONSIVE STYLES ========== */

/* Mobile sidebar - ONLY fixed position on mobile */
@media (max-width: 1023px) {
  .admin-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 16rem;
    min-width: 16rem;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 60;
    box-shadow: none;
  }
  .admin-sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  }
  #sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 55;
  }
  #sidebar-overlay:not(.hidden) {
    display: block;
  }
}

/* Mobile phones (below 768px) */
@media (max-width: 767px) {
  /* Public nav */
  .public-navbar {
    padding: 0 0.5rem;
    height: auto;
    min-height: var(--header-height);
  }
  .public-navbar .max-w-7xl {
    padding-left: 0.25rem;
    padding-right: 0.25rem;
    height: auto;
    min-height: var(--header-height);
  }

  /* Mobile menu improvements */
  .mobile-menu-panel {
    width: 280px;
    max-width: 85vw;
  }

  /* Tables - horizontal scroll */
  .overflow-x-auto {
    -webkit-overflow-scrolling: touch;
  }
  .mc-table {
    min-width: 640px;
  }
  .mc-table thead th {
    white-space: nowrap;
    font-size: 0.6875rem;
    padding: 0.5rem 0.75rem;
  }
  .mc-table tbody td {
    padding: 0.625rem 0.75rem;
    font-size: 0.8125rem;
  }

  /* Form inputs */
  .mc-input {
    min-height: 44px; /* iOS touch friendly */
    font-size: 16px; /* Prevent iOS zoom */
  }

  /* Buttons - larger touch targets */
  .mc-btn {
    min-height: 40px;
    padding: 0.5rem 1rem;
  }
  .mc-btn-sm {
    min-height: 36px;
    padding: 0.375rem 0.75rem;
  }
  .mc-btn-lg {
    min-height: 48px;
    padding: 0.625rem 1.25rem;
    font-size: 1rem;
  }

  /* Cards */
  .mc-card {
    border-radius: 12px;
  }

  /* Stats grid */
  .stat-card .text-2xl {
    font-size: 1.25rem;
  }
  .stat-icon {
    width: 40px;
    height: 40px;
  }

  /* Breadcrumb hidden on small screens */
  .breadcrumb {
    display: none;
  }

  /* Reduce hero padding */
  section:first-of-type {
    padding-top: 6rem;
  }
}

/* Small phones (below 480px) */
@media (max-width: 479px) {
  .mobile-menu-panel {
    width: 85vw;
  }

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

  /* Single column grids */
  .sm\\:grid-cols-2 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
  }

  /* Full width buttons */
  .mc-btn {
    width: 100%;
    justify-content: center;
  }

  /* Page title smaller */
  h1 {
    font-size: 1.5rem !important;
  }
}

@media (max-width: 639px) {
  .toast-container {
    left: 1rem;
    right: 1rem;
  }
  .toast {
    min-width: 0;
    max-width: none;
  }
}

/* Print styles */
@media print {
  .public-navbar,
  .admin-sidebar,
  .no-print {
    display: none !important;
  }
  .admin-main {
    margin-left: 0 !important;
  }
}
