/* Modern Google Material Design System (2026 Refinement) */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Google+Sans:wght@400;500;700&display=swap');

:root {
  /* Core Palette - Refreshingly Modern */
  --nx-brand-primary: #6366F1;
  /* Indigo/Purple Primary */
  --nx-brand-secondary: #e0e7ff;
  /* Indigo Tint */
  --nx-brand-accent: #4F46E5;

  --nx-success: #1e8e3e;
  --nx-success-bg: #e6f4ea;
  --nx-warning: #f9ab00;
  --nx-warning-bg: #fef7e0;
  --nx-error: #d93025;
  --nx-error-bg: #fce8e6;

  /* Surfaces & Neutrals - Glassmorphism Ready */
  --nx-bg: #f5f7fc;
  /* Soft, cool background pattern will be layered later */
  --nx-surface: rgba(255, 255, 255, 0.7);
  --nx-surface-alt: rgba(255, 255, 255, 0.5);
  --nx-glass-border: rgba(255, 255, 255, 0.5);

  /* Text */
  --nx-text: #1e1b4b;
  --nx-text-secondary: #4338ca;
  --nx-text-disabled: #9ca3af;

  /* Shapes & Shadows */
  --nx-radius-sm: 12px;
  --nx-radius-md: 16px;
  --nx-radius-lg: 24px;
  --nx-radius-pill: 999px;

  --nx-shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --nx-shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --nx-shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);

  /* Layout */
  --nx-header-h: 72px;
  --nx-sidebar-w: 90px;
}

[data-theme="dark"] {
  --nx-bg: #0f172a;
  --nx-surface: rgba(30, 41, 59, 0.7);
  --nx-surface-alt: rgba(30, 41, 59, 0.5);
  --nx-glass-border: rgba(255, 255, 255, 0.1);
  --nx-text: #f8fafc;
  --nx-text-secondary: #94a3b8;
  --nx-brand-primary: #818cf8;
  --nx-brand-secondary: rgba(129, 140, 248, 0.2);
}

/* === Global Reset & Typography === */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', 'Google Sans', -apple-system, sans-serif;
  background-color: var(--nx-bg);
  background-image:
    linear-gradient(rgba(245, 247, 252, 0.9), rgba(245, 247, 252, 0.95)),
    url('../img/clinic-bg.png');
  background-attachment: fixed;
  background-size: cover;
  background-position: center;
  color: var(--nx-text);
  line-height: 1.5;
  font-size: 14px;
}

[data-theme="dark"] body {
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0.95)),
    url('../img/clinic-bg.png');
}

a {
  color: inherit;
  text-decoration: none;
  transition: 0.2s;
}

h1,
h2,
h3,
h4,
h5 {
  margin: 0;
  font-weight: 600;
  color: var(--nx-text);
  letter-spacing: -0.5px;
}

/* === Layout === */
.nx-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.nx-content {
  flex: 1;
  padding: 20px;
  margin: 0 auto;
  width: 100%;
  max-width: 1400px;
}

@media(min-width: 1024px) {
  .nx-shell {
    flex-direction: row;
  }

  .nx-content {
    padding: 24px 32px;
  }
}

/* === Components === */

/* 1. Header */
.nx-topbar {
  height: var(--nx-header-h);
  background: var(--nx-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--nx-glass-border);
  box-shadow: var(--nx-shadow-sm);
}

.nx-brand {
  font-size: 22px;
  font-weight: 700;
  color: var(--nx-brand-primary);
  letter-spacing: -0.5px;
}

.nx-brand::first-letter {
  font-size: 24px;
}

/* 2. Sidebar (Compact & Modern & Glass) */
.nx-sidebar {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.8), rgba(139, 92, 246, 0.8));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  width: 100%;
  position: fixed;
  bottom: 0;
  z-index: 99;
  height: 72px;
  display: flex;
  overflow-x: auto;
  padding: 0 10px;
  align-items: center;
  box-shadow: 0 -8px 24px rgba(99, 102, 241, 0.15);
  gap: 8px;
}

@media(min-width: 1024px) {
  .nx-sidebar {
    position: sticky;
    top: var(--nx-header-h);
    bottom: auto;
    height: auto;
    min-height: calc(100vh - var(--nx-header-h));
    width: 90px;
    /* Condensed width */
    flex-direction: column;
    align-items: center;
    /* Center icons */
    padding: 20px 10px;
    border-top: none;
    border-right: none;
    overflow: visible;
    /* ALLOW TOOLTIPS TO OVERFLOW */
    box-shadow: 4px 0 12px rgba(99, 102, 241, 0.15);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
}

.nx-menu {
  display: flex;
  flex-direction: column;
  /* Stack icon and text for mobile, or centered for desktop */
  align-items: center;
  justify-content: center;
  padding: 10px 5px;
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.85);
  /* White with slight opacity */
  font-weight: 500;
  margin-bottom: 8px;
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 11px;
  /* Smaller font for labels if shown */
  transition: all 0.2s ease;
  width: 100%;
  position: relative;
  text-decoration: none;
}

.nx-menu-icon {
  width: 24px;
  height: 24px;
  margin-bottom: 2px;
  display: block;
  line-height: 1;
}

.nx-menu-icon svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
  /* Inherits text color */
}

.nx-menu-label {
  display: none;
  /* Hidden by default in compact mode */
}

/* Desktop Hover Interaction - Tooltip Style */
@media(min-width: 1024px) {
  .nx-menu-label {
    position: absolute;
    left: 80px;
    /* Push to right of sidebar */
    background: #1e1b4b;
    /* Dark purple/black tooltip */
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    pointer-events: none;
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.2s ease;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  }

  .nx-menu:hover .nx-menu-label {
    display: block;
    opacity: 1;
    transform: translateX(0);
  }

  /* Submenu fix for compact mode */
  #admin-submenu {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 10px;
    padding-left: 0 !important;
    /* Override inline style */
  }

  #admin-submenu .nx-menu-icon {
    font-size: 16px;
    /* Slightly smaller sub-icons */
  }
}

.nx-menu:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  transform: translateY(-1px);
}

.nx-menu.active {
  background: rgba(255, 255, 255, 0.3);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.nx-sep {
  width: 80%;
  height: 1px;
  background: rgba(255, 255, 255, 0.2);
  margin: 10px auto;
}

.nx-caption {
  display: none;
}

/* Mobile Utilities & Drawer */
.mobile-only {
  display: none;
}

#sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

#sidebar-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

@media(max-width: 1023px) {
  .mobile-only {
    display: block !important;
  }

  /* Drawer Sidebar */
  .nx-sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 260px;
    height: 100vh;
    flex-direction: column;
    padding: 20px 15px;
    overflow-y: auto;
    overflow-x: hidden;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    align-items: stretch;
    bottom: auto;
    border-radius: 0;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.2);
    display: flex;
    background: linear-gradient(135deg, #6366F1, #8B5CF6);
  }

  .nx-sidebar.mobile-open {
    left: 0;
  }

  /* Items in Drawer */
  .nx-menu {
    flex-direction: row;
    justify-content: flex-start;
    padding: 12px 16px;
    min-width: 0;
    width: 100%;
    border-radius: 8px;
    font-size: 14px;
    gap: 12px;
    margin-bottom: 5px;
  }

  .nx-menu-icon,
  .nx-menu-icon svg {
    width: 20px;
    height: 20px;
    margin-bottom: 0;
  }

  .nx-menu-label {
    display: block !important;
    position: static;
    background: transparent;
    color: white;
    padding: 0;
    width: auto;
    transform: none;
    pointer-events: auto;
    box-shadow: none;
    font-weight: 500;
  }

  /* Reset Admin Submenu to Vertical Stack */
  #admin-submenu {
    position: static;
    width: 100%;
    padding-left: 15px !important;
    background: transparent;
    box-shadow: none;
    flex-direction: column;
    display: none;
    max-height: none;
    overflow: visible;
    border-radius: 0;
  }

  #admin-submenu .nx-menu {
    width: 100%;
    padding: 10px 12px;
    font-size: 13px;
  }

  /* Compact Cards */
  .nx-card {
    padding: 12px;
    height: auto !important;
  }

  /* Gridstack Mobile Overrides */
  .grid-stack-item {
    position: relative !important;
    width: 100% !important;
    left: auto !important;
    top: auto !important;
    height: auto !important;
    margin-bottom: 4px;
    padding: 0 !important;
  }

  .grid-stack-item-content {
    inset: auto !important;
    /* Remove absolute inset */
    position: relative !important;
    height: auto !important;
  }

  /* Charts Cap */
  canvas {
    max-height: 250px !important;
  }

  .chart-container-mobile {
    height: 250px !important;
  }

  /* Responsive Page Header */
  .page-header-flex {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 15px;
  }

  .page-header-flex>div:last-child {
    /* Buttons container */
    justify-content: space-between;
    width: 100%;
  }

  /* FullCalendar Mobile */
  .fc-header-toolbar {
    flex-direction: column;
    gap: 10px;
  }

  .fc-toolbar-chunk {
    display: flex;
    justify-content: center;
    width: 100%;
  }

  .fc-toolbar-title {
    font-size: 1.2em !important;
  }
}

/* 3. Cards (Glassmorphism) */
.nx-card {
  background: var(--nx-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--nx-radius-md);
  padding: 24px;
  border: 1px solid var(--nx-glass-border);
  box-shadow: var(--nx-shadow-md);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s;
  height: 100%;
}

.nx-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--nx-shadow-hover);
  border-color: rgba(255, 255, 255, 0.8);
}

/* 4. Buttons (Pills) */
.nx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 24px;
  /* Reduced */
  border-radius: var(--nx-radius-pill);
  /* Classic rounded rect */
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: 0.2s;
  border: none;
}

.nx-btn-primary {
  background: var(--nx-brand-primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.nx-btn-primary:hover {
  background: #1557b0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.nx-btn-outline {
  background: transparent;
  color: var(--nx-text-secondary);
  border: 1px solid #dadce0;
}

.nx-btn-outline:hover {
  background: var(--nx-bg);
  color: var(--nx-text);
  border-color: #bdc1c6;
}

.nx-btn-sm {
  padding: 4px 16px;
  font-size: 12px;
  height: 32px;
}

/* 5. Inputs (Glassy) */
.nx-input,
input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid var(--nx-glass-border);
  border-radius: var(--nx-radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--nx-text);
  margin-bottom: 16px;
  transition: all 0.2s ease;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.nx-input:focus,
input:focus,
select:focus {
  background: rgba(255, 255, 255, 0.9);
  border-color: var(--nx-brand-primary);
  box-shadow: 0 0 0 3px var(--nx-brand-secondary), inset 0 1px 2px rgba(0, 0, 0, 0.05);
  outline: none;
}

[data-theme="dark"] .nx-input,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  background: rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .nx-input:focus,
[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus {
  background: rgba(0, 0, 0, 0.4);
}

/* 6. Tables (Clean) */
.nx-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.nx-table th {
  text-align: left;
  padding: 16px;
  color: var(--nx-text-secondary);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--nx-surface-alt);
}

.nx-table td {
  padding: 16px;
  border-bottom: 1px solid var(--nx-surface-alt);
  vertical-align: middle;
}

.nx-table tr:last-child td {
  border-bottom: none;
}

.nx-table tr:hover td {
  background: var(--nx-surface-alt);
}

/* 7. Typography Utils */
.nx-page-title {
  font-size: 28px;
  margin-bottom: 24px;
  font-weight: 400;
  font-family: 'Google Sans', sans-serif;
}

.nx-section-title {
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 16px;
  color: var(--nx-text);
}

.nx-muted {
  color: var(--nx-text-secondary);
  font-size: 14px;
}

.nx-badge {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: var(--nx-surface-alt);
  color: var(--nx-text-secondary);
}

/* Grid System */
.nx-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

.nx-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media(max-width: 768px) {
  .nx-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* === FullCalendar Overrides === */
.fc .fc-button-primary {
  background-color: #818cf8 !important;
  /* Lighter Purple (Indigo 400) */
  border-color: #818cf8 !important;
  color: white !important;
  font-weight: 500;
  border: none;
  box-shadow: none;
}

.fc .fc-button-primary:hover,
.fc .fc-button-primary:active,
.fc .fc-button-primary.fc-button-active {
  background-color: var(--nx-brand-primary) !important;
  /* System Purple */
  border-color: var(--nx-brand-primary) !important;
  color: white !important;
  box-shadow: 0 2px 4px rgba(99, 102, 241, 0.2);
}

/* === Modern Calendar Skin (Google Style) === */
.fc {
  font-family: 'Inter', sans-serif;
}

/* Soften Grid Borders */
.fc-theme-standard td,
.fc-theme-standard th,
.fc-theme-standard .fc-scrollgrid {
  border-color: #eaeaea;
}

/* Header Cells (MON, TUE...) */
.fc-col-header-cell-cushion {
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 600;
  color: #5f6368;
  padding: 12px 0;
  text-decoration: none;
}

/* Day Numbers */
.fc-daygrid-day-number {
  font-size: 13px;
  font-weight: 500;
  color: var(--nx-text);
  padding: 8px;
  text-decoration: none;
}

/* Modernize "Today" Highlight */
.fc .fc-day-today {
  background-color: #f8fafc !important;
  /* Very subtle cool grey */
}

.fc-day-today .fc-daygrid-day-number {
  background: var(--nx-brand-primary);
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 4px;
}

/* Events Styling */
.fc-event {
  border: none;
  border-radius: 6px;
  /* Rounded events */
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  font-size: 12px;
  font-weight: 500;
  padding: 1px 2px;
}

.fc-h-event {
  background-color: var(--nx-brand-primary);
  /* Default Purple */
}

/* Month View Events */
.fc-daygrid-event-dot {
  border-color: var(--nx-brand-primary);
}

/* Time Layout */
.fc-timegrid-slot-label {
  font-size: 11px;
  color: #999;
  font-weight: 500;
}

.fc-timegrid-axis {
  font-size: 11px;
  color: #999;
}