/**
 * PHARMACY INVENTORY - STYLES (Part 1: Variables & Base)
 */

/* Local Fonts */
/* Inter (Latin) */
@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter-v20-latin/inter-v20-latin-regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter-v20-latin/inter-v20-latin-500.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter-v20-latin/inter-v20-latin-600.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* Cairo (Arabic & Latin) */
@font-face {
  font-family: 'Cairo';
  src: url('../fonts/cairo-v31-arabic_latin/cairo-v31-arabic_latin-regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Cairo';
  src: url('../fonts/cairo-v31-arabic_latin/cairo-v31-arabic_latin-600.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Cairo';
  src: url('../fonts/cairo-v31-arabic_latin/cairo-v31-arabic_latin-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --primary-dark: #1e40af;
  --secondary-color: #64748b;
  --success-color: #10b981;
  --success-light: #d1fae5;
  --warning-color: #f59e0b;
  --warning-light: #fef3c7;
  --danger-color: #ef4444;
  --danger-light: #fee2e2;
  --bg-color: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-full: 9999px;
  --font-family: 'Inter', 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition-fast: 150ms ease;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-color);
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.app-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1;
  padding: 1.5rem 0;
}

/* Header */
.header {
  background-color: var(--primary-color);
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
  padding: 1rem 0;
  box-shadow: var(--shadow-lg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  transition: background 0.2s ease;
}

.header-main:hover {
  background: rgba(255, 255, 255, 0.1);
}

.pharmacy-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.pharmacy-logo svg {
  width: 36px;
  height: 36px;
}

.pharmacy-name {
  font-size: 1.25rem;
  font-weight: 700;
}

.expand-icon {
  opacity: 0.7;
  transition: transform 0.3s ease;
}

.header.expanded .expand-icon {
  transform: rotate(180deg);
}

/* Collapsible Details */
.pharmacy-details {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  padding: 0 0.5rem;
  transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
}

.header.expanded .pharmacy-details {
  max-height: 100px;
  opacity: 1;
  padding: 1rem 0.5rem 0;
  margin-top: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.info-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  opacity: 0.9;
}

.info-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Card */
.card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.card-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-title svg {
  width: 24px;
  height: 24px;
  color: var(--primary-color);
}

.card-body {
  padding: 1.5rem;
}

/* Form */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-label.required::after {
  content: '*';
  color: var(--danger-color);
  margin-left: 0.25rem;
}

.form-input,
.form-select {
  width: 100%;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-input.error {
  border-color: var(--danger-color);
}

.form-error {
  font-size: 0.75rem;
  color: var(--danger-color);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  cursor: pointer;
  border: none;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border-color);
  border-color: var(--text-secondary);
}

.btn-success {
  background: var(--success-color);
  color: white;
}

.btn-success:hover:not(:disabled) {
  background-color: #059669;
}

.btn-warning {
  background: var(--warning-color);
  color: white;
  border: none;
}

.btn-warning:hover:not(:disabled) {
  background-color: #d97706;
  /* Darker amber */
}

/* Specific styling for Sync Button to handle badge alignment */
#sync-pending-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
}

#sync-pending-btn svg {
  flex-shrink: 0;
}



.btn-danger {
  background: var(--danger-color);
  color: white;
}

.btn-success {
  background: var(--success-color);
  color: white;
}

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.btn-icon {
  padding: 0.5rem;
}

/* Button Spinner (Optimistic UI) */
.btn-spinner {
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

/* Optimistic Row (saving indicator) */
tr.optimistic {
  opacity: 0.7;
  background: var(--warning-light) !important;
  position: relative;
}

tr.optimistic td:first-child::before {
  content: '⏳ ';
}

/* Row animations */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

tr.new-row {
  animation: slideUp 0.3s ease;
}

tr.removing {
  animation: fadeOut 0.3s ease forwards;
}

/* Filter Bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  /* Align bottom to match labels */
  gap: 1rem;
  padding: 1.5rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  margin-bottom: 2rem;
}

.search-wrapper {
  flex: 1;
  min-width: 250px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.filter-group label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.filter-actions {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  margin-left: auto;
}

.filter-actions .btn-secondary {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.filter-actions .btn-secondary:hover:not(:disabled) {
  background: var(--bg-color);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* Table */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th,
.table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.table th {
  background: var(--bg-tertiary);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 0.75rem;
}

.table th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 1.75rem;
  /* Space for icon */
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.table th.sortable:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.table th.sortable.sorted {
  background: var(--primary-light);
  color: var(--primary-color);
}

/* Sort Icon */
.table th.sortable::after {
  content: '↕';
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.3;
  font-size: 0.85rem;
}

.table th.sortable:hover::after {
  opacity: 0.7;
}

.table th.sortable.sorted::after {
  opacity: 1;
  content: '↓';
}

.table th.sortable.sorted.asc::after {
  content: '↑';
}

.table th.sortable.sorted.desc::after {
  content: '↓';
}

.table tbody tr:hover {
  background: var(--bg-tertiary);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* Medicine Type Badge */
.medicine-type {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  text-transform: capitalize;
}

.medicine-type.tablet {
  background: #dbeafe;
  color: #1d4ed8;
}

.medicine-type.syrup {
  background: #fce7f3;
  color: #be185d;
}

.medicine-type.injection {
  background: #fee2e2;
  color: #dc2626;
}

.medicine-type.cream {
  background: #fef3c7;
  color: #d97706;
}

.medicine-type.drops {
  background: #d1fae5;
  color: #059669;
}

.medicine-type.capsule {
  background: #e0e7ff;
  color: #4338ca;
}

.medicine-type.other {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

/* Expiry Status */
.expiry-status {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
}

.expiry-status.expired {
  background: var(--danger-light);
  color: var(--danger-color);
}

.expiry-status.expiring-soon {
  background: var(--warning-light);
  color: var(--warning-color);
}

.expiry-status.valid {
  background: var(--success-light);
  color: var(--success-color);
}

.quantity-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.quantity-value {
  font-weight: 600;
  min-width: 40px;
}

.quantity-low {
  color: var(--danger-color);
}

.table-actions {
  display: flex;
  gap: 0.25rem;
}

/* Progress Bar */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary-color), var(--primary-light), var(--primary-color));
  background-size: 200% 100%;
  z-index: 1000;
  width: 0;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.progress-bar.loading {
  opacity: 1;
  animation: progressAnimation 1.5s ease-in-out infinite, progressWidth 2s ease-out forwards;
}

.progress-bar.complete {
  width: 100% !important;
  opacity: 0;
  transition: opacity 0.5s ease 0.3s;
}

@keyframes progressAnimation {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

@keyframes progressWidth {
  0% {
    width: 0;
  }

  20% {
    width: 30%;
  }

  50% {
    width: 60%;
  }

  80% {
    width: 85%;
  }

  100% {
    width: 95%;
  }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.empty-state p {
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

/* Toast */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid;
  animation: slideIn 0.3s ease;
  max-width: 400px;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.success {
  border-left-color: var(--success-color);
}

.toast.error {
  border-left-color: var(--danger-color);
}

.toast.warning {
  border-left-color: var(--warning-color);
}

.toast-message {
  flex: 1;
  font-size: 0.875rem;
}

.toast-close {
  padding: 0.25rem;
  opacity: 0.5;
  cursor: pointer;
  background: none;
  border: none;
}

.toast-close:hover {
  opacity: 1;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 300;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-secondary);
  border-radius: 1rem;
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  transform: scale(0.95);
  transition: transform 0.25s;
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-close {
  padding: 0.5rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  background: none;
  border: none;
}

.modal-close:hover {
  background: var(--bg-tertiary);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  flex: 1;
  min-width: 0;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 24px;
  height: 24px;
}

.stat-icon.primary {
  background: var(--primary-light);
  color: var(--primary-color);
}

.stat-icon.success {
  background: var(--success-light);
  color: var(--success-color);
}

.stat-icon.warning {
  background: var(--warning-light);
  color: var(--warning-color);
}

.stat-icon.danger {
  background: var(--danger-light);
  color: var(--danger-color);
}

.stat-content h3 {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.stat-content p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Utilities */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.text-muted {
  color: var(--text-muted);
}

.mt-md {
  margin-top: 1rem;
}

.mb-md {
  margin-bottom: 1rem;
}

/* Responsive */
@media (min-width: 768px) {
  .header-content {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .pharmacy-name {
    font-size: 1.875rem;
  }

  .filter-bar {
    flex-wrap: nowrap;
  }

  .filter-group {
    flex: 0 1 auto;
  }
}

@media (max-width: 767px) {

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .stat-card {
    padding: 1rem;
  }

  .stat-icon {
    width: 40px;
    height: 40px;
  }

  .stat-content h3 {
    font-size: 1.25rem;
  }

  .stat-content p {
    font-size: 0.75rem;
  }

  .pharmacy-details {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .header.expanded .pharmacy-details {
    max-height: 150px;
  }

  .table th,
  .table td {
    padding: 0.5rem;
  }

  .table-actions {
    flex-direction: column;
  }

  .filter-actions {
    width: 100%;
    margin-left: 0;
    margin-top: 0.5rem;
  }

  .filter-actions .btn {
    flex: 1;
  }

  .toast-container {
    left: 1rem;
    right: 1rem;
  }

  .toast {
    max-width: none;
  }

  .table .hide-mobile {
    display: none;
  }

  .fab {
    bottom: 1.5rem;
    right: 1.5rem;
    width: 54px;
    height: 54px;
  }
}

@media print {
  .no-print {
    display: none !important;
  }

  .header {
    background: none !important;
    color: black !important;
  }

  body {
    background: white;
  }
}

/* ========================================
   FLOATING ACTION BUTTON (FAB)
   ======================================== */

.fab {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
  transition: all 0.3s ease;
  z-index: 100;
}

.fab:hover {
  background: var(--primary-hover);
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

.fab:active {
  transform: scale(0.95);
}

/* ========================================
   HEADER SETTINGS BUTTON
   ======================================== */

.btn-icon-header {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-icon-header:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: rotate(30deg);
}

/* ========================================
   SKELETON LOADING
   ======================================== */

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--bg-tertiary) !important;
}

.skeleton::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg,
      transparent,
      rgba(255, 255, 255, 0.3),
      transparent);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

.skeleton-text {
  height: 1rem;
  background: var(--border-color);
  border-radius: var(--radius-sm);
  width: 80%;
}

.skeleton-text.short {
  width: 40%;
}

.skeleton-row td {
  padding: 1rem;
}

.skeleton-row .skeleton-text {
  height: 0.875rem;
  margin: 0.25rem 0;
}

/* Stat card skeleton */
.stat-card.skeleton .stat-icon,
.stat-card.skeleton .stat-content h3,
.stat-card.skeleton .stat-content p {
  background: var(--border-color);
  border-radius: var(--radius-sm);
}

.stat-card.skeleton .stat-content h3 {
  width: 3rem;
  height: 2rem;
}

.stat-card.skeleton .stat-content p {
  width: 5rem;
  height: 1rem;
  margin-top: 0.5rem;
}



/* ========================================
   DARK MODE ADJUSTMENTS FOR NEW ELEMENTS
   ======================================== */

@media (prefers-color-scheme: dark) {
  .fab {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  }

  .skeleton::after {
    background: linear-gradient(90deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent);
  }
}

/* ========================================
   RESPONSIVE LAYOUT UPDATES
   ======================================== */

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ========================================
   HEADER TOGGLE SWITCH
   ======================================== */

.header-right-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-toggle-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
}

.toggle-switch-header {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch-header input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider-header {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.25);
  transition: .4s;
  border-radius: 24px;
}

.toggle-slider-header:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

.toggle-switch-header input:checked+.toggle-slider-header {
  background-color: rgba(255, 255, 255, 0.5);
}

.toggle-switch-header input:checked+.toggle-slider-header:before {
  transform: translateX(20px);
  background-color: white;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}

.toggle-switch-header input:focus+.toggle-slider-header {
  box-shadow: 0 0 1px white;
}

.toggle-label-header {
  color: white;
  font-size: 0.7rem;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1;
  opacity: 0.9;
}

.btn-icon-header {
  align-self: center;
}

/* ========================================
   MOBILE RESPONSIVE STYLES
   ======================================== */

@media (max-width: 640px) {

  /* Stack card header items vertically, left-aligned */
  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .header-actions {
    margin-top: 0.25rem;
    width: auto;
  }

  /* Improve Filter Layout on Mobile */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .search-wrapper {
    width: 100%;
    max-width: none;
  }

  .filter-group {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 0.75rem;
  }

  .filter-group select,
  .filter-group input {
    width: 100% !important;
    max-width: none !important;
  }

  /* Improve Filter Actions on Mobile */
  .filter-actions {
    width: 100%;
    margin-left: 0;
    margin-top: 0.5rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .filter-actions .btn {
    width: 100%;
    justify-content: center;
  }

  #export-pdf {
    grid-column: span 2;
  }

  /* Header content logic for better spacing */
  .header-content {
    flex-wrap: nowrap;
    gap: 0.5rem;
  }

  .pharmacy-logo svg {
    width: 28px;
    height: 28px;
  }

  .pharmacy-name {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
  }

  /* Right actions container */
  .header-right-actions {
    gap: 0.5rem;
    margin-left: auto;
    flex-shrink: 0;
  }

  /* Compact the toggle slightly on mobile */
  .toggle-switch-header {
    width: 38px;
    height: 20px;
  }

  .toggle-slider-header:before {
    width: 16px;
    height: 16px;
    left: 2px;
    bottom: 2px;
  }

  .toggle-switch-header input:checked+.toggle-slider-header:before {
    transform: translateX(18px);
  }

  .toggle-label-header {
    font-size: 0.65rem;
  }

  /* Settings button small check */
  .btn-icon-header {
    width: 32px;
    height: 32px;
  }
}