/**
 * ENNU Face Chart - iPad-Optimized Styling
 * Professional medical aesthetics face charting interface
 *
 * @package ENNU_Life_Assessments
 */

/* Import Josefin Sans font */
@import url("https://fonts.googleapis.com/css2?family=Josefin+Sans:wght@400;500;600;700&display=swap");

/* ==========================================================================
   CRITICAL: Force scrolling to always be enabled
   ========================================================================== */
/* Override any attempts to block scrolling - must be at top for highest priority */
html,
body {
  position: relative !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  height: auto !important;
  min-height: 100% !important;
  -webkit-overflow-scrolling: touch !important;
}

/* Ensure face chart container doesn't block scrolling */
.ennu-face-chart-container {
  position: relative !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  height: auto !important;
  min-height: 100vh !important;
}

/* ==========================================================================
   Theme Tokens - Dark Minimal Design System
   ========================================================================== */

/* Light Theme Variables */
:root {
  /* Background colors */
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --panel: #ffffff;
  --elev: #f1f5f9;

  /* Text colors */
  --text: #1e293b;
  --text-soft: #475569;
  --muted: #64748b;

  /* Accent colors */
  --accent: #16a34a;
  --accent-2: #2563eb;
  --danger: #dc2626;
  --border: #e2e8f0;
  --timer: #16a34a;
  --focus: #3b82f6;

  /* Typography */
  --font-family: "Josefin Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-family-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, sans-serif;

  /* Spacing & Effects */
  --radius: 2px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-soft: 0 1px 3px rgba(0, 0, 0, 0.08);
  --transition: all 150ms ease;
  --transition-slow: all 180ms ease;

  /* Focus and accessibility */
  --focus-ring: 0 0 0 2px var(--focus);
  --focus-ring-inset: inset 0 0 0 2px var(--focus);
}

/* Dark Theme Variables */
.theme-dark {
  /* Background colors */
  --bg: #0f1216;
  --bg-soft: #151a20;
  --panel: #161b22;
  --elev: #1d2430;

  /* Text colors */
  --text: #e6edf3;
  --text-soft: #c2c9d1;
  --muted: #94a3b8;

  /* Accent colors */
  --accent: #27ae60;
  --accent-2: #3b82f6;
  --danger: #ef4444;
  --border: #263041;
  --timer: #27ae60;
  --focus: #60a5fa;

  /* Typography */
  --font-family: "Josefin Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-family-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, sans-serif;

  /* Spacing & Effects */
  --radius: 2px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-soft: 0 1px 3px rgba(0, 0, 0, 0.3);
  --transition: all 150ms ease;
  --transition-slow: all 180ms ease;

  /* Focus and accessibility */
  --focus-ring: 0 0 0 2px var(--focus);
  --focus-ring-inset: inset 0 0 0 2px var(--focus);
}

/* ==========================================================================
   Container & Layout
   ========================================================================== */

.ennu-face-chart-container {
  width: 100%;
  min-height: 600px; /* Reasonable minimum height instead of full viewport */
  max-height: 80vh; /* Limit height to prevent page overflow */
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-family-body);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  margin: 20px 0; /* Add margin to separate from page content */
}

/* Full screen on desktop */
@media (min-width: 1024px) {
  .ennu-face-chart-container {
    width: 100vw;
    min-height: 100vh;
    height: auto;
    max-height: none;
    margin: 0;
    border-radius: 0;
    position: relative; /* Changed from fixed to allow scrolling */
    top: 0;
    left: 0;
    z-index: 9999;
    overflow-x: hidden;
    overflow-y: auto; /* Allow vertical scrolling */
  }

  .face-chart-content.mode-face-chart {
    min-height: calc(100vh - 60px); /* Full viewport minus header */
    height: auto; /* Allow content to expand */
  }
}

/* Responsive adjustments for page template compatibility */
@media (max-width: 768px) {
  .ennu-face-chart-container {
    min-height: 500px;
    max-height: 70vh;
    margin: 15px 0;
    border-radius: 6px;
  }
}

@media (max-width: 480px) {
  .ennu-face-chart-container {
    min-height: 400px;
    max-height: 60vh;
    margin: 10px 0;
    border-radius: 4px;
  }
}

/* Header */
.face-chart-header {
  background: var(--panel);
  box-shadow: var(--shadow);
  flex-shrink: 0;
  z-index: 100;
  contain: layout style;
}

.face-chart-header.two-row {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  min-height: auto;
}

.header-row:last-child {
  border-bottom: none;
}

.header-row-1 {
  gap: 30px;
}

.header-row-2 {
  gap: 20px;
  background: var(--bg-soft);
}

.header-row-3 {
  gap: 8px;
  background: var(--panel);
  padding: 6px 16px;
  border-top: 1px solid var(--border);
  min-height: auto;
}

.header-voice-recorder-compact {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  max-width: 300px;
}

/* Compact voice recorder button in header row 2 */
.header-voice-button-compact {
  display: flex;
  align-items: center;
  margin-right: 8px;
}

.header-voice-button-compact .ennu-voice-recorder {
  margin: 0;
}

.header-voice-button-compact .voice-recorder-card {
  padding: 6px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: none;
  min-height: auto;
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: var(--transition);
}

.header-voice-button-compact .voice-recorder-card:hover {
  border-color: var(--accent);
  background: var(--bg-soft);
}

.header-voice-button-compact .recorder-icon-wrapper {
  width: 24px;
  height: 24px;
  margin-right: 6px;
  position: relative;
}

.header-voice-button-compact .pulse-ring,
.header-voice-button-compact .pulse-ring-2 {
  width: 32px;
  height: 32px;
  position: absolute;
  top: -4px;
  left: -4px;
}

.header-voice-button-compact .btn-start-recording {
  width: 24px;
  height: 24px;
  padding: 4px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-voice-button-compact .microphone-icon {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.header-voice-button-compact .recorder-title {
  font-size: 12px;
  margin: 0;
  font-weight: 500;
  color: var(--text);
}

.header-voice-button-compact .recorder-subtitle {
  display: none; /* Hide subtitle in compact mode */
}

/* Hide all other states in compact mode */
.header-voice-button-compact .recording-interface,
.header-voice-button-compact .transcription-result,
.header-voice-button-compact .processing-overlay-modern {
  display: none !important;
}

/* Compact voice recorder styling */
.header-voice-recorder-compact .ennu-voice-recorder {
  width: 100%;
  max-width: 280px;
}

.header-voice-recorder-compact .voice-recorder-card {
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: none;
  min-height: auto;
}

.header-voice-recorder-compact .recorder-icon-wrapper {
  width: 32px;
  height: 32px;
}

.header-voice-recorder-compact .pulse-ring,
.header-voice-recorder-compact .pulse-ring-2 {
  width: 40px;
  height: 40px;
}

.header-voice-recorder-compact .btn-start-recording {
  width: 32px;
  height: 32px;
  padding: 6px;
}

.header-voice-recorder-compact .microphone-icon {
  width: 20px;
  height: 20px;
}

.header-voice-recorder-compact .recorder-title {
  font-size: 14px;
  margin: 4px 0;
}

.header-voice-recorder-compact .recorder-subtitle {
  font-size: 12px;
  margin: 0;
  color: var(--text-soft);
}

.header-voice-recorder-compact .voice-recorder-button:hover,
.header-voice-button:hover {
  background: var(--bg-soft);
  border-color: var(--accent-2);
}

.header-voice-button {
  padding: 8px 16px !important;
  border-radius: var(--radius) !important;
  border: 1px solid var(--border) !important;
  background: var(--panel) !important;
  color: var(--text) !important;
  font-size: 14px !important;
  transition: var(--transition) !important;
}

.header-provider-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 1 auto;
}

.provider-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}

.provider-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.provider-name {
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
}

.header-time-info {
  flex: 0 1 auto;
  text-align: right;
}

.current-time-display,
.session-timer-display {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}

.current-time-label,
.session-timer-label {
  font-size: 12px;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.current-time-value,
.session-timer-value {
  font-family: "Monaco", "Courier New", monospace;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.5px;
}

.session-timer-value {
  color: var(--accent);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.header-logo {
  max-width: 300px;
  height: auto;
  display: block;
}

.header-left h1,
#chart-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-family);
  letter-spacing: 0.2px;
  line-height: 1.2;
}

.header-right {
  display: flex;
  gap: 15px;
  align-items: center;
}

/* Theme Switcher Button */
.btn-theme-switcher {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  z-index: 102;
}

.btn-theme-switcher:hover {
  background: var(--elev);
  border-color: var(--accent-2);
  transform: scale(1.05);
}

.btn-theme-switcher:focus {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

/* Theme switcher button icons */
#btn-theme-switcher svg,
.theme-btn svg {
  display: block !important;
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  transition: var(--transition);
}

#btn-theme-switcher.active .theme-icon-light,
.theme-btn.active .theme-icon-light {
  display: none !important;
}

#btn-theme-switcher.active .theme-icon-dark,
.theme-btn.active .theme-icon-dark {
  display: block !important;
}

#btn-theme-switcher:not(.active) .theme-icon-dark,
.theme-btn:not(.active) .theme-icon-dark {
  display: none !important;
}

#btn-theme-switcher:not(.active) .theme-icon-light,
.theme-btn:not(.active) .theme-icon-light {
  display: block !important;
}

/* Voice recorder button icon */
#btn-voice-toggle svg,
.voice-btn svg {
  display: block !important;
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
}

/* Buttons */
.btn-back,
.btn-save,
.btn-complete,
.btn-canvas-action,
.btn-primary,
.btn-secondary,
.btn-danger {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-back {
  background: transparent;
  color: var(--muted);
  padding: 8px 16px;
}

.btn-back:hover {
  background: #f8f9fa;
}

.btn-save {
  background: #3498db;
  color: white;
}

.btn-save:hover {
  background: #2980b9;
}

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

.btn-complete:hover {
  background: #229954;
}

.btn-primary {
  background: #3498db;
  color: white;
}

.btn-primary:hover {
  background: #2980b9;
}

.btn-secondary {
  background: #95a5a6;
  color: white;
}

.btn-secondary:hover {
  background: var(--text-soft);
}

.btn-danger {
  background: #e74c3c;
  color: white;
}

.btn-danger:hover {
  background: #c0392b;
}

.btn-block {
  width: 100%;
}

.btn-canvas-action {
  background: white;
  color: var(--text);
  border: 1px solid #dfe6e9;
  padding: 10px 16px;
  font-size: 14px;
}

.btn-canvas-action:hover {
  background: #f8f9fa;
  border-color: #b2bec3;
}

/* ==========================================================================
   Main Content Layout
   ========================================================================== */

.face-chart-content {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  gap: 0;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Other modes: Single column layout for full-width panels */
.face-chart-content.mode-treatment,
.face-chart-content.mode-notes,
.face-chart-content.mode-tip,
.face-chart-content.mode-refer {
  grid-template-columns: 1fr;
}

/* Hide canvas area and toolbar in non-Chart modes */
.face-chart-content.mode-treatment .face-chart-canvas-area,
.face-chart-content.mode-notes .face-chart-canvas-area,
.face-chart-content.mode-tip .face-chart-canvas-area,
.face-chart-content.mode-refer .face-chart-canvas-area {
  display: none;
}

.face-chart-content.mode-treatment .canvas-toolbar,
.face-chart-content.mode-notes .canvas-toolbar,
.face-chart-content.mode-tip .canvas-toolbar,
.face-chart-content.mode-refer .canvas-toolbar {
  display: none !important;
}

/* Sidebars in other modes: Normal grid positioning, not fixed */
.face-chart-content.mode-treatment .face-chart-sidebar,
.face-chart-content.mode-notes .face-chart-sidebar,
.face-chart-content.mode-tip .face-chart-sidebar,
.face-chart-content.mode-refer .face-chart-sidebar {
  display: none !important; /* Hide sidebars in non-chart modes */
  visibility: hidden !important;
  opacity: 0 !important;
}

/* Chart mode: Canvas always full width, sidebars overlay */
.face-chart-content.mode-face-chart {
  grid-template-columns: 1fr; /* Canvas always full width */
  position: relative; /* Container for absolute positioned sidebars */
}

/* Canvas area always full width in Chart mode */
.face-chart-content.mode-face-chart .face-chart-canvas-area {
  width: 100%;
  grid-column: 1;
  position: relative;
  z-index: 1;
}

/* Sidebars as overlays in Chart mode - contained within container */
.face-chart-content.mode-face-chart {
  position: relative; /* Container for absolute positioned sidebars */
  overflow: hidden; /* Prevent sidebars from going outside */
}

.face-chart-content.mode-face-chart .face-chart-sidebar {
  position: absolute; /* Changed from fixed to absolute to stay within container */
  top: 56px; /* Align with canvas start (after toolbar) - matches canvas-area padding-top */
  bottom: 0;
  z-index: 1000;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
  transition: transform 0.3s ease;
  background: var(--panel);
  overflow-y: auto;
  max-height: calc(
    100% - 56px
  ); /* Ensure it stays within container minus toolbar */
  padding: 0; /* Remove padding to be flush */
  border: none; /* Remove borders to be flush */
}

.face-chart-content.mode-face-chart .face-chart-sidebar.sidebar-left {
  left: 0; /* Flush with left edge of container */
  width: 280px;
  transform: translateX(0); /* Show by default */
  border-right: 1px solid var(--border); /* Only right border to separate from canvas */
}

.face-chart-content.mode-face-chart .face-chart-sidebar.sidebar-left.show {
  transform: translateX(0);
}

.face-chart-content.mode-face-chart .face-chart-sidebar.sidebar-left.hide {
  transform: translateX(-100%);
}

.face-chart-content.mode-face-chart .face-chart-sidebar.sidebar-right {
  right: 0; /* Flush with right edge of container */
  width: 320px;
  transform: translateX(0); /* Show by default */
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
  border-left: 1px solid var(--border); /* Only left border to separate from canvas */
}

.face-chart-content.mode-face-chart .face-chart-sidebar.sidebar-right.show {
  transform: translateX(0);
}

.face-chart-content.mode-face-chart .face-chart-sidebar.sidebar-right.hide {
  transform: translateX(100%);
}

/* Account for header height in container - calculate from container top */
.face-chart-content.mode-face-chart {
  position: relative;
  height: calc(100vh - 60px); /* Full viewport minus header */
  min-height: calc(100vh - 60px);
}

/* Sidebars align flush with canvas - match canvas-area padding-top */
.face-chart-content.mode-face-chart .face-chart-sidebar {
  top: 56px; /* Match canvas-area padding-top to align with canvas start */
  height: calc(100% - 56px); /* Full height minus toolbar */
  max-height: calc(100% - 56px); /* Ensure it doesn't overflow */
}

/* Responsive sidebar positioning to match canvas-area padding */
@media (max-width: 768px) {
  .face-chart-content.mode-face-chart .face-chart-sidebar {
    top: 60px; /* Match canvas-area padding-top on mobile */
    max-height: calc(100% - 60px);
  }
}

@media (max-width: 480px) {
  .face-chart-content.mode-face-chart .face-chart-sidebar {
    top: 58px; /* Match canvas-area padding-top on small mobile */
    max-height: calc(100% - 58px);
  }
}

@media (max-width: 782px) {
  .admin-bar .face-chart-content.mode-face-chart .face-chart-sidebar {
    top: 102px; /* Match canvas-area padding-top: 46px admin bar + 56px header */
    max-height: calc(100% - 102px);
  }

  body.admin-bar.admin-bar-with-menu
    .face-chart-content.mode-face-chart
    .face-chart-sidebar {
    top: 56px; /* Admin bar hidden, just header */
    max-height: calc(100% - 56px);
  }
}

@media (max-width: 768px) {
  body.admin-bar .face-chart-content.mode-face-chart .face-chart-sidebar {
    top: 106px; /* Match canvas-area padding-top: 46px admin bar + 60px header */
    max-height: calc(100% - 106px);
  }

  body.admin-bar.admin-bar-with-menu
    .face-chart-content.mode-face-chart
    .face-chart-sidebar {
    top: 60px; /* Admin bar hidden, just header */
    max-height: calc(100% - 60px);
  }
}

@media (max-width: 480px) {
  body.admin-bar .face-chart-content.mode-face-chart .face-chart-sidebar {
    top: 104px; /* Match canvas-area padding-top: 46px admin bar + 58px header */
    max-height: calc(100% - 104px);
  }

  body.admin-bar.admin-bar-with-menu
    .face-chart-content.mode-face-chart
    .face-chart-sidebar {
    top: 58px; /* Admin bar hidden, just header */
    max-height: calc(100% - 58px);
  }
}

/* Hide backdrop in non-Chart modes */
.face-chart-content.mode-treatment .sidebar-backdrop,
.face-chart-content.mode-notes .sidebar-backdrop,
.face-chart-content.mode-tip .sidebar-backdrop,
.face-chart-content.mode-refer .sidebar-backdrop {
  display: none !important;
}

/* Backdrop overlay when sidebar is open in Chart mode */
.face-chart-content.mode-face-chart .sidebar-backdrop {
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.face-chart-content.mode-face-chart .sidebar-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.admin-bar .face-chart-content.mode-face-chart .sidebar-backdrop {
  top: 92px;
}

@media (max-width: 782px) {
  .admin-bar .face-chart-content.mode-face-chart .sidebar-backdrop {
    top: 106px;
  }
}

/* Treatment/Billing Panel - Prevent Flicker */
.treatment-billing-panel {
  display: none !important; /* Hidden by default */
  grid-column: 1 / -1; /* Span all columns */
  overflow-y: auto;
  background: #f5f7fa;
  padding: 24px;
  min-height: 0;
  width: 100%;
}

.treatment-billing-panel.active,
.treatment-billing-panel[style*="display: grid"],
.treatment-billing-panel[style*="display: block"] {
  display: grid !important;
  grid-template-columns: 1fr;
  gap: 24px;
  grid-column: 1 / -1; /* Span all columns */
  width: 100%;
  min-height: 0;
  position: relative;
}

/* Billing Sections */
.billing-section {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.billing-section h2 {
  margin: 0 0 16px 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.order-summary-section {
  min-height: 200px;
}

.add-services-section {
  min-height: 150px;
}

.treatment-history-section {
  min-height: 150px;
}

/* Tip Panel */
#tip-panel {
  display: none !important;
  grid-column: 1 / -1; /* Span all columns */
  overflow-y: auto;
  background: #f5f7fa;
  padding: 24px;
  width: 100%;
  min-height: 0;
}

#tip-panel.active,
#tip-panel[style*="display: block"] {
  display: block !important;
  grid-column: 1 / -1; /* Span all columns */
  width: 100%;
  min-height: 0;
  position: relative;
}

/* Refer Panel */
#refer-panel {
  display: none !important;
  grid-column: 1 / -1; /* Span all columns */
  overflow-y: auto;
  background: #f5f7fa;
  padding: 24px;
  width: 100%;
  min-height: 0;
}

#refer-panel.active,
#refer-panel[style*="display: block"] {
  display: block !important;
  grid-column: 1 / -1; /* Span all columns */
  width: 100%;
  min-height: 0;
  position: relative;
}

/* Sidebars */
.face-chart-sidebar {
  background: white;
  padding: 24px;
  overflow-y: auto;
}

/* Chart mode sidebars - flush edge-to-edge with canvas */
.face-chart-content.mode-face-chart .face-chart-sidebar {
  padding: 24px; /* Keep internal padding for content */
}

/* Non-chart mode sidebars keep original borders */
.face-chart-content:not(.mode-face-chart) .face-chart-sidebar {
  border-right: 1px solid #e1e8ed;
}

.face-chart-content:not(.mode-face-chart) .sidebar-right {
  border-right: none;
  border-left: 1px solid #e1e8ed;
}

.tool-section {
  margin-bottom: 30px;
}

.tool-section h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
}

/* Tool Buttons */
.tool-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 10px;
}

.tool-btn {
  padding: 16px 12px;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  min-height: 80px;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}

.tool-btn:hover {
  border-color: var(--accent);
  background: var(--bg-soft);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.tool-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tool-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.tool-btn.active:hover {
  background: var(--accent);
  opacity: 0.9;
}

.tool-btn svg {
  width: 28px;
  height: 28px;
  stroke-width: 2;
  flex-shrink: 0;
  pointer-events: none;
}

.tool-btn.active svg {
  stroke: white;
  fill: none;
}

.tool-btn:not(.active) svg {
  stroke: var(--text);
  fill: none;
}

.tool-btn span {
  pointer-events: none;
}

/* Color Picker */
.color-picker input[type="color"] {
  width: 100%;
  height: 48px;
  border: 2px solid #dfe6e9;
  border-radius: 8px;
  cursor: pointer;
}

/* Form Elements */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 8px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="datetime-local"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #dfe6e9;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #3498db;
}

/* Multi-select styling */
.form-group select[multiple] {
  min-height: 120px;
  padding: 8px;
  background: #fff;
  border: 1px solid #dfe6e9;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.8;
}

.form-group select[multiple]:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-group select[multiple] option {
  padding: 6px 10px;
  cursor: pointer;
}

.form-group select[multiple] option:hover {
  background: #f0f0f0;
}

.form-group select[multiple] option:checked {
  background: #3498db;
  color: white;
}

.form-group .form-text {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

.form-group textarea {
  resize: vertical;
  font-family: inherit;
}

.input-group {
  display: flex;
  gap: 10px;
}

.input-group input {
  flex: 1;
}

.input-group select {
  width: 100px;
}

/* ==========================================================================
   Canvas Area
   ========================================================================== */

.face-chart-canvas-area {
  display: flex;
  flex-direction: column;
  background: white; /* Match paper color */
  padding: 0; /* Flush edge-to-edge */
  margin: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-top: 56px; /* Account for sticky header height - sidebars match this */
  box-sizing: border-box;
  pointer-events: auto; /* Ensure canvas area allows pointer events */
  position: relative; /* For absolute positioning of canvas */
}

/* Responsive padding adjustments for canvas area - base rules */
@media (max-width: 768px) {
  .face-chart-canvas-area {
    padding-top: 60px; /* Account for wrapped header on mobile (slightly taller) */
  }
}

@media (max-width: 480px) {
  .face-chart-canvas-area {
    padding-top: 58px; /* Slightly smaller header on small mobile */
  }
}

/* Account for admin bar + header when admin bar is present - must come after media queries for proper override */
body.admin-bar .face-chart-canvas-area {
  padding-top: 88px; /* 32px admin bar + 56px header */
}

@media (max-width: 782px) {
  body.admin-bar .face-chart-canvas-area {
    padding-top: 102px; /* 46px admin bar + 56px header on mobile */
  }

  body.admin-bar.admin-bar-with-menu .face-chart-canvas-area {
    padding-top: 56px; /* Admin bar hidden, just header */
  }
}

@media (max-width: 768px) {
  body.admin-bar .face-chart-canvas-area {
    padding-top: 106px; /* 46px admin bar + 60px header */
  }

  body.admin-bar.admin-bar-with-menu .face-chart-canvas-area {
    padding-top: 60px; /* Admin bar hidden, just header */
  }
}

@media (max-width: 480px) {
  body.admin-bar .face-chart-canvas-area {
    padding-top: 104px; /* 46px admin bar + 58px header */
  }

  body.admin-bar.admin-bar-with-menu .face-chart-canvas-area {
    padding-top: 58px; /* Admin bar hidden, just header */
  }
}

.canvas-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  margin-top: 12px; /* Add spacing from top of canvas area */
  flex-wrap: wrap;
  padding: 0 16px; /* Add horizontal padding */
  box-sizing: border-box;
}

/* ===== COMPACT HEADER DESIGN ===== */
.face-chart-header.compact-header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 99; /* Below admin bar (99999) but above content */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: top 0.3s ease;
  width: 100%;
  overflow: hidden; /* Prevent horizontal overflow */
  box-sizing: border-box;
}

/* ===== PROFESSIONAL CANVAS WITH PRECISION RULERS ===== */
.canvas-container {
  display: grid;
  grid-template-columns: 40px 1fr;
  grid-template-rows: 40px 1fr;
  gap: 0;
  background: white;
  border-radius: 0; /* Flush edge-to-edge */
  box-shadow: none; /* No shadow */
  position: relative;
  min-height: 0;
  max-width: 100%;
  padding: 0;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  margin: 0;
}

.ruler-corner-spacer {
  grid-column: 1;
  grid-row: 1;
  background: #f8f9fa;
  border: 2px solid #dee2e6;
  border-bottom: none;
  border-right: none;
}

.ruler-horizontal.ruler-top {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: center;
  background: #f8f9fa;
  border: 2px solid #dee2e6;
  border-bottom: none;
  border-left: none;
  position: relative;
}

.ruler-horizontal .ruler-canvas {
  flex: 1;
  height: 100%;
  display: block;
  background: linear-gradient(to right, #f8f9fa 0%, #e9ecef 100%);
}

.ruler-horizontal .ruler-info {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: #6c757d;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}

.ruler-vertical.ruler-left {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  background: #f8f9fa;
  border: 2px solid #dee2e6;
  border-top: none;
  border-right: none;
}

.ruler-vertical .ruler-canvas {
  flex: 1;
  width: 100%;
  display: block;
  background: linear-gradient(to bottom, #f8f9fa 0%, #e9ecef 100%);
}

.canvas-wrapper {
  grid-column: 2;
  grid-row: 2;
  position: relative;
  display: block; /* Changed from flex to block for flush positioning */
  background: white;
  border: none; /* Flush edge-to-edge */
  overflow: auto; /* Allow scrolling when zoomed */
  min-height: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  pointer-events: auto; /* Ensure wrapper allows pointer events through */
  /* Canvas positioned absolutely at (0,0) for flush edge-to-edge display */
}

.canvas-template-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  z-index: 1;
  margin: 0;
  padding: 0;
  display: none; /* Hidden - image is drawn on canvas instead */
  visibility: hidden; /* Double hidden to ensure it doesn't show */
}

.face-chart-canvas-element {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none !important;
  max-height: none !important;
  min-width: 0;
  min-height: 0;
  cursor: crosshair;
  display: block;
  z-index: 2;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  margin: 0;
  padding: 0;
  border: none;
  outline: none;
  pointer-events: auto !important; /* Ensure canvas receives mouse events */
  touch-action: none; /* Prevent default touch behaviors */
  /* Width and height are set dynamically by JavaScript based on zoom */
  /* Canvas displays exactly 8.5" × 11" Letter size at 150 DPI (1275×1650 internal) */
}

/* GUARANTEE: Absolute highest specificity to ensure canvas receives events */
#face-chart-canvas.face-chart-canvas-element,
canvas#face-chart-canvas,
.face-chart-canvas-area canvas#face-chart-canvas,
.canvas-wrapper canvas#face-chart-canvas {
  pointer-events: auto !important;
  touch-action: none !important;
  cursor: crosshair !important;
}

.canvas-annotations-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 3;
  margin: 0;
  padding: 0;
}

.canvas-precision-cursor {
  position: absolute;
  pointer-events: none;
  z-index: 4;
  top: 0;
  left: 0;
}

.cursor-crosshair {
  position: relative;
  width: 100vw;
  height: 100vh;
}

.cursor-crosshair .cursor-vertical,
.cursor-crosshair .cursor-horizontal {
  position: absolute;
  background: rgba(255, 0, 0, 0.8);
  pointer-events: none;
}

.cursor-crosshair .cursor-vertical {
  width: 1px;
  height: 100vh;
  left: 50%;
  top: 0;
}

.cursor-crosshair .cursor-horizontal {
  height: 1px;
  width: 100vw;
  top: 50%;
  left: 0;
}

.cursor-coordinates {
  position: absolute;
  top: -25px;
  left: 5px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-family: monospace;
  white-space: nowrap;
  pointer-events: none;
}

/* Account for WordPress admin bar */
.admin-bar .face-chart-header.compact-header {
  top: 32px; /* Admin bar height on desktop */
}

@media (max-width: 782px) {
  .admin-bar .face-chart-header.compact-header {
    top: 46px; /* Admin bar height on mobile when expanded */
  }

  /* When admin bar is collapsed on mobile */
  .admin-bar body.admin-bar-with-menu .face-chart-header.compact-header {
    top: 0; /* Admin bar is hidden, header can be at top */
  }
}

/* Ensure header doesn't interfere with admin bar functionality */
#wpadminbar {
  z-index: 99999; /* WordPress default */
}

/* Admin bar handling is managed through header positioning only */

.header-main-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 8px 16px;
  gap: 16px;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden; /* Prevent overflow */
  position: relative;
}

.header-section {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0; /* Allow flex items to shrink below content size */
  flex-shrink: 1; /* Allow sections to shrink if needed */
}

/* Left Section: Logo + Navigation */
.header-left-section {
  flex: 0 0 auto;
  min-width: 0;
}

.header-logo-mini {
  height: 28px;
  width: auto;
  flex-shrink: 0;
}

.btn-back-mini {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-back-mini:hover {
  background: var(--elev);
  border-color: var(--accent);
}

.title-compact {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Center Section: Mode Toggles */
.header-center-section {
  flex: 1 1 auto;
  justify-content: center;
  max-width: 600px;
}

.mode-toggle-bar {
  display: flex;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
  gap: 2px;
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  min-height: 36px; /* Ensure minimum touch target */
  touch-action: manipulation; /* Improve touch responsiveness */
  -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
  user-select: none; /* Prevent text selection on tap */
}

.mode-btn:hover {
  background: var(--elev);
  color: var(--text);
}

.mode-btn.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.mode-btn .dashicons {
  font-size: 16px;
  width: 16px;
  height: 16px;
}

.mode-label {
  display: inline;
}

/* Right Section: Info + Actions */
.header-right-section {
  flex: 0 0 auto;
  align-items: center;
}

.session-status {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: 16px;
  font-size: 13px;
  color: var(--text-soft);
}

.status-time,
.status-timer,
.status-provider {
  white-space: nowrap;
}

.status-time::before {
  content: "🕐 ";
}

.status-timer::before {
  content: "⏱️ ";
}

.status-provider {
  font-weight: 500;
  color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px; /* Ensure minimum touch target */
  min-height: 36px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  touch-action: manipulation; /* Improve touch responsiveness */
  -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

.action-btn:hover {
  background: var(--elev);
  border-color: var(--accent);
  color: var(--accent);
}

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

.complete-btn {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  padding: 0 16px;
  width: auto;
  min-width: 100px;
  font-weight: 600;
}

.complete-btn:hover {
  background: var(--accent-dark, #2563eb);
  border-color: var(--accent-dark, #2563eb);
}

/* Voice recorder modal removed - recording UI now inline in notes tab */

/* Responsive Design */
/* Tablet and below (1024px) */
@media (max-width: 1024px) {
  .face-chart-header.compact-header {
    position: sticky;
    top: 0;
  }

  .header-main-row {
    padding: 8px 12px;
    gap: 12px;
    flex-wrap: nowrap;
  }

  .header-left-section {
    flex: 0 0 auto;
    min-width: 0;
    gap: 8px;
  }

  .header-logo-mini {
    height: 24px;
    display: none; /* Hide logo on tablet to save space */
  }

  .btn-back-mini {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
  }

  .title-compact {
    font-size: 15px;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-center-section {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
  }

  .mode-toggle-bar {
    gap: 1px;
    padding: 1px;
  }

  .mode-btn {
    padding: 6px 8px;
    font-size: 13px;
    gap: 4px;
  }

  .mode-label {
    display: none; /* Hide labels, show only icons */
  }

  .mode-btn .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
  }

  .header-right-section {
    flex: 0 0 auto;
    gap: 6px;
  }

  .session-status {
    display: none; /* Hide session status on tablet */
  }

  .header-actions {
    gap: 6px;
  }

  .action-btn {
    width: 32px;
    height: 32px;
  }

  .complete-btn {
    min-width: 80px;
    padding: 0 12px;
    font-size: 13px;
  }

  /* Adjust rulers for tablets */
  .ruler-horizontal,
  .ruler-vertical {
    display: none; /* Hide rulers on tablets to save space */
  }

  .ruler-corner-spacer {
    display: none;
  }

  .canvas-container {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    padding: 0;
  }

  .canvas-container > * {
    display: none;
  }

  .canvas-wrapper {
    display: block !important;
    padding: 0;
    border: 2px solid #dee2e6;
  }

  .canvas-container .canvas-wrapper {
    grid-column: 1;
    grid-row: 1;
  }
}

/* Mobile (768px and below) */
@media (max-width: 768px) {
  .face-chart-header.compact-header {
    position: sticky;
    top: 0;
    z-index: 99;
  }

  .header-main-row {
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px 10px;
    min-height: auto;
  }

  /* Row 1: Left + Right */
  .header-left-section {
    flex: 1 1 auto;
    min-width: 0;
    order: 1;
    gap: 6px;
  }

  .header-logo-mini {
    display: none; /* Hide logo on mobile */
  }

  .btn-back-mini {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
  }

  .title-compact {
    font-size: 14px;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-right-section {
    flex: 0 0 auto;
    order: 2;
    margin-left: auto;
  }

  .session-status {
    display: none; /* Hide session status on mobile */
  }

  .header-actions {
    gap: 4px;
  }

  .action-btn {
    width: 32px;
    height: 32px;
    padding: 0;
  }

  .action-btn svg {
    width: 14px;
    height: 14px;
  }

  .complete-btn {
    min-width: 70px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 600;
  }

  /* Row 2: Mode Toggles (Full Width) */
  .header-center-section {
    order: 3;
    width: 100%;
    flex: 1 1 100%;
    max-width: 100%;
    margin-top: 4px;
  }

  .mode-toggle-bar {
    width: 100%;
    justify-content: stretch;
    gap: 2px;
    padding: 2px;
  }

  .mode-btn {
    flex: 1;
    justify-content: center;
    min-width: 0;
    padding: 8px 4px;
    font-size: 12px;
  }

  .mode-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
  }

  .mode-label {
    display: none; /* Hide labels on mobile, icons only */
  }

  /* Canvas improvements for mobile */
  .canvas-wrapper {
    padding: 8px;
  }

  .canvas-toolbar {
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
  }

  .btn-canvas-action {
    min-width: 36px;
    height: 36px;
    font-size: 14px;
  }

  /* Make canvas more touch-friendly */
  #face-chart-canvas {
    touch-action: none; /* Prevent default touch behaviors */
  }

  /* Adjust ruler visibility on small screens */
  .ruler-horizontal .ruler-label {
    display: none; /* Hide label to save space */
  }

  .ruler-horizontal {
    height: 30px;
  }

  .ruler-vertical {
    width: 30px;
  }
}

/* Small Mobile (480px and below) */
@media (max-width: 480px) {
  .face-chart-header.compact-header {
    position: sticky;
    top: 0;
  }

  .header-main-row {
    padding: 6px 8px;
    gap: 6px;
  }

  .header-left-section {
    gap: 4px;
  }

  .header-logo-mini {
    display: none; /* Hide logo on small mobile */
  }

  .btn-back-mini {
    width: 26px;
    height: 26px;
  }

  .title-compact {
    font-size: 13px;
    max-width: 100px;
  }

  .header-right-section {
    gap: 4px;
  }

  .header-actions {
    gap: 3px;
  }

  .action-btn {
    width: 30px;
    height: 30px;
  }

  .action-btn svg {
    width: 13px;
    height: 13px;
  }

  .complete-btn {
    min-width: 60px;
    padding: 0 8px;
    font-size: 11px;
  }

  .header-center-section {
    margin-top: 2px;
  }

  .mode-toggle-bar {
    gap: 1px;
    padding: 1px;
  }

  .mode-btn {
    padding: 6px 2px;
    font-size: 11px;
    min-width: 0;
  }

  .mode-btn .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
  }
}

/* iPad Portrait (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
  .header-main-row {
    padding: 8px 16px;
  }

  .header-logo-mini {
    display: block;
    height: 26px;
  }

  .title-compact {
    font-size: 16px;
    max-width: 180px;
  }

  .mode-btn {
    padding: 7px 10px;
  }

  .mode-label {
    display: inline; /* Show labels on iPad portrait */
  }

  .session-status {
    display: flex; /* Show session status on iPad */
    gap: 10px;
    font-size: 12px;
  }
}

/* iPad Landscape (1024px - 1366px) */
@media (min-width: 1024px) and (max-width: 1366px) and (orientation: landscape) {
  .header-main-row {
    padding: 8px 20px;
  }

  .mode-label {
    display: inline; /* Show labels on iPad landscape */
  }

  .session-status {
    display: flex; /* Show session status on iPad landscape */
  }
}

/* Large Desktop (1400px+) */
@media (min-width: 1400px) {
  .header-main-row {
    padding: 10px 24px;
    max-width: 1920px;
    margin: 0 auto;
  }

  .header-center-section {
    max-width: 700px;
  }

  .mode-btn {
    padding: 9px 14px;
    font-size: 15px;
  }
}

/* Unified Sidebar Toggles - Intelligent responsive behavior */
.btn-unified-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  min-height: 40px;
  z-index: 10;
  pointer-events: auto;
  user-select: none;
}

.btn-unified-toggle:hover {
  background: var(--elev);
  border-color: var(--accent);
  color: var(--accent);
}

/* Active state for open sidebars */
.btn-unified-toggle[aria-expanded="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-unified-toggle[aria-expanded="true"] svg {
  stroke: white;
}

.btn-unified-toggle:active,
.btn-unified-toggle.btn-clicked {
  transform: translateY(1px);
  transition: transform 0.1s ease;
}

.btn-unified-toggle:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--focus);
}

.btn-unified-toggle svg {
  flex-shrink: 0;
}

.btn-unified-toggle .btn-text {
  display: inline;
}

/* Hide button text on very small screens to save space */
@media (max-width: 480px) {
  .btn-unified-toggle .btn-text {
    display: none;
  }
  .btn-unified-toggle {
    padding: 8px;
    min-width: 40px;
    justify-content: center;
  }
}

/* On larger screens, make buttons more prominent in toolbar */
@media (min-width: 768px) {
  .btn-unified-toggle {
    padding: 10px 16px;
    font-size: 15px;
    min-height: 44px;
  }
}

/* Sidebar backdrop for iPad/mobile */
.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 140;
  opacity: 0;
  transition: opacity 0.3s ease;
}

@media (max-width: 1024px) {
  .sidebar-backdrop.active {
    display: block;
    opacity: 1;
  }
}

.zoom-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  background: white;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid #dfe6e9;
}

.zoom-controls button {
  width: 32px;
  height: 32px;
  border: none;
  background: #f8f9fa;
  border-radius: 4px;
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  color: var(--text);
}

.zoom-controls button:hover {
  background: #e9ecef;
}

#zoom-level {
  min-width: 50px;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
}

.canvas-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  padding: 20px;
  position: relative;
  overflow: auto;
  min-height: 0;
  max-width: 100%;
}

/* Canvas rulers for letter-sized paper reference */
.canvas-rulers {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
}

.ruler-horizontal {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 40px; /* Leave space for vertical ruler */
  height: 40px;
  background: #f8f9fa;
  border-top: 2px solid #dee2e6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ruler-horizontal .ruler-marks {
  width: 100%;
  height: 20px;
  position: relative;
  border-top: 1px solid #adb5bd;
}

.ruler-horizontal .ruler-label {
  font-size: 11px;
  color: #6c757d;
  font-weight: 500;
  margin-top: 2px;
  text-align: center;
}

.ruler-vertical {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 40px; /* Leave space for horizontal ruler */
  width: 40px;
  background: #f8f9fa;
  border-left: 2px solid #dee2e6;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ruler-vertical .ruler-marks {
  height: 100%;
  width: 20px;
  position: relative;
  border-left: 1px solid #adb5bd;
}

/* Ruler marks styling */
.ruler-marks::before,
.ruler-marks::after {
  content: "";
  position: absolute;
  background: #6c757d;
}

.ruler-horizontal .ruler-marks::before {
  left: 0;
  top: 0;
  width: 100%;
  height: 1px;
}

.ruler-horizontal .ruler-marks::after {
  left: 50%;
  top: 0;
  width: 1px;
  height: 8px;
}

.ruler-vertical .ruler-marks::before {
  top: 0;
  left: 0;
  height: 100%;
  width: 1px;
}

.ruler-vertical .ruler-marks::after {
  top: 50%;
  left: 0;
  height: 1px;
  width: 8px;
}

/* Ruler measurement marks */
.ruler-mark {
  position: absolute;
  font-size: 9px;
  color: #6c757d;
  pointer-events: none;
  user-select: none;
}

.ruler-mark.major {
  font-weight: 600;
  color: #495057;
}

.ruler-mark.minor {
  opacity: 0.7;
}

.ruler-horizontal .ruler-mark {
  top: -16px;
  transform: translateX(-50%);
}

.ruler-vertical .ruler-mark {
  left: -28px;
  transform: translateY(-50%);
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

#face-chart-canvas {
  /* Responsive canvas that maintains letter aspect ratio (8.5:11) */
  max-width: none;
  max-height: none;
  border: 1px solid #dfe6e9;
  cursor: crosshair;
  transition: transform 0.2s ease;
  transform-origin: center center;
  display: block;
  object-fit: contain;
  margin: auto;
  /* Size and aspect ratio (8.5:11) maintained by JavaScript resizeCanvas() */
  /* Zoom applied via transform: scale() in JavaScript */
}

.canvas-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.canvas-images-strip {
  margin-top: 16px;
  background: white;
  border-radius: 8px;
  padding: 12px;
}

.image-thumbnails {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.image-thumb {
  flex-shrink: 0;
  width: 100px;
  height: 100px;
  border: 3px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.image-thumb:hover {
  border-color: #3498db;
  transform: translateY(-2px);
}

.image-thumb.active {
  border-color: #3498db;
  box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

.image-thumb.primary::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  background: #f39c12;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 4px;
  font-size: 11px;
  text-align: center;
}

.thumb-delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(231, 76, 60, 0.9);
  color: white;
  border: none;
  border-radius: 4px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 10;
  padding: 0;
}

.image-thumb:hover .thumb-delete-btn {
  opacity: 1;
}

.thumb-delete-btn:hover {
  background: rgba(192, 57, 43, 1);
}

.thumb-delete-btn svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.5;
}

.thumb-primary-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: #f39c12;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  z-index: 5;
}

/* ==========================================================================
   Treatments List
   ========================================================================== */

.treatments-list {
  margin-top: 16px;
  max-height: 300px;
  overflow-y: auto;
}

.treatments-list .no-treatments {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-style: italic;
}

.treatment-item {
  padding: 12px;
  background: #f8f9fa;
  border-radius: 6px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  transition: background 0.2s ease;
}

.treatment-item:hover {
  background: #e9ecef;
}

.treatment-item-content {
  flex: 1;
}

.treatment-item strong {
  display: block;
  color: var(--text);
  margin-bottom: 4px;
}

.treatment-item p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.treatment-item .treatment-cost {
  margin-top: 4px;
  font-weight: 600;
  color: #27ae60;
}

.treatment-item-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.treatment-edit-btn,
.treatment-delete-btn {
  background: transparent;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.2s ease;
}

.treatment-edit-btn {
  color: #3498db;
  border-color: #3498db;
}

.treatment-edit-btn:hover {
  background: #3498db;
  color: white;
}

.treatment-delete-btn {
  color: #e74c3c;
  border-color: #e74c3c;
}

.treatment-delete-btn:hover {
  background: #e74c3c;
  color: white;
}

.treatment-edit-btn svg,
.treatment-delete-btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

/* ==========================================================================
   Modals
   ========================================================================== */

.ennu-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.ennu-modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 24px;
  border-bottom: 1px solid #e1e8ed;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  font-size: 32px;
  color: #95a5a6;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-soft);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.modal-footer {
  padding: 20px 24px;
  border-top: 1px solid #e1e8ed;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Upload Area */
.upload-area {
  border: 3px dashed #dfe6e9;
  border-radius: 12px;
  padding: 60px 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-bottom: 24px;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: #3498db;
  background: #f0f8ff;
}

.upload-area svg {
  margin-bottom: 16px;
  stroke: #95a5a6;
}

.upload-area p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

/* Template Grid */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.template-card {
  border: 2px solid #e1e8ed;
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.template-card:hover {
  border-color: #3498db;
  background: #f0f8ff;
  transform: translateY(-2px);
}

.template-card img {
  width: 100%;
  height: 150px;
  object-fit: contain;
  margin-bottom: 12px;
}

.template-card h4 {
  margin: 0;
  font-size: 14px;
  color: var(--text);
}

/* ==========================================================================
   Responsive - Desktop Large Screen (1920px+)
   ========================================================================== */

@media (min-width: 1920px) {
  .canvas-wrapper {
    max-width: 1400px;
    margin: 0 auto;
  }
}

/* ==========================================================================
   Responsive - iPad Landscape (1024×768)
   ========================================================================== */

@media (max-width: 1200px) and (min-width: 1025px) {
  .face-chart-content {
    grid-template-columns: 260px 1fr 300px;
  }
}

/* ==========================================================================
   Responsive - iPad Landscape & Portrait (≤1024px)
   ========================================================================== */

@media (max-width: 1024px) {
  .face-chart-content {
    grid-template-columns: 1fr;
  }

  /* Hide both sidebars by default, show as slide-ins */
  .face-chart-sidebar {
    position: fixed;
    top: 72px;
    bottom: 0;
    z-index: 150;
    transition: transform 0.3s ease;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
  }

  .face-chart-sidebar.sidebar-left {
    left: 0;
    width: 280px;
    transform: translateX(-100%);
  }

  .face-chart-sidebar.sidebar-left.open {
    transform: translateX(0);
  }

  .face-chart-sidebar.sidebar-right {
    right: 0;
    width: 320px;
    transform: translateX(100%);
  }

  .face-chart-sidebar.sidebar-right.open {
    transform: translateX(0);
  }

  .canvas-toolbar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .face-chart-canvas-area {
    padding: 12px;
  }
}

/* ==========================================================================
   Responsive - Mobile / Small Tablets (≤768px)
   ========================================================================== */

@media (max-width: 768px) {
  .face-chart-header {
    padding: 12px 16px;
    min-height: 60px;
  }

  .header-left h1 {
    font-size: 16px;
  }

  .btn-save,
  .btn-complete {
    padding: 8px 12px;
    font-size: 13px;
  }

  .tool-buttons {
    grid-template-columns: 1fr;
  }

  .canvas-wrapper {
    padding: 8px;
    min-height: 0;
  }

  .face-chart-canvas-area {
    padding: 8px;
  }

  #face-chart-canvas {
    /* Responsive on mobile while maintaining 8.5:11 ratio */
    max-width: 100%;
    max-height: 100%;
  }

  .modal-content {
    width: 95%;
    max-height: 90vh;
  }

  .template-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Adjust sidebar widths for mobile */
  .face-chart-sidebar.sidebar-left {
    width: 260px;
  }

  .face-chart-sidebar.sidebar-right {
    width: 280px;
  }
}

/* ==========================================================================
   Touch Optimization for iPad
   ========================================================================== */

@media (hover: none) and (pointer: coarse) {
  /* Increase touch targets */
  .tool-btn,
  .btn-canvas-action {
    min-height: 44px;
    min-width: 44px;
  }

  /* Remove hover effects on touch devices */
  .tool-btn:hover,
  .btn-canvas-action:hover {
    border-color: #dfe6e9;
    background: white;
  }

  .tool-btn.active:hover {
    background: #3498db;
    border-color: #3498db;
  }

  /* Canvas touch feedback */
  #face-chart-canvas {
    touch-action: none;
  }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

/* ==========================================================================
   Print Styles - Multi-Page PDF
   ========================================================================== */

/* Hide print layout on screen */
.print-only {
  display: none;
}

@media print {
  /* Hide screen UI */
  .face-chart-header,
  .face-chart-sidebar,
  .face-chart-content,
  .canvas-toolbar,
  .canvas-images-strip,
  .ennu-modal,
  .sidebar-backdrop {
    display: none !important;
  }

  /* Show print layout */
  .print-only {
    display: block !important;
  }

  /* Page setup */
  @page {
    size: letter portrait;
    margin: 0.5in;
  }

  body {
    margin: 0;
    padding: 0;
    background: white;
  }

  /* Print pages */
  .print-page {
    page-break-after: always;
    page-break-inside: avoid;
    width: 100%;
    min-height: 10in;
  }

  .print-page:last-child {
    page-break-after: auto;
  }

  /* Print header */
  .print-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #333;
  }

  .print-logo {
    max-width: 200px;
    height: auto;
    margin-bottom: 15px;
  }

  .print-header h1,
  .print-header h2 {
    margin: 10px 0;
    color: var(--text);
    font-size: 24px;
    font-weight: 600;
  }

  /* Print sections */
  .print-section {
    margin-bottom: 30px;
    page-break-inside: avoid;
  }

  .print-section h3 {
    font-size: 18px;
    color: var(--text);
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid #ddd;
    font-weight: 600;
  }

  /* Info tables */
  .print-info-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
  }

  .print-info-table tr {
    border-bottom: 1px solid #eee;
  }

  .print-info-table td {
    padding: 10px 5px;
    font-size: 14px;
  }

  .print-info-table td.label {
    font-weight: 600;
    width: 35%;
    color: #555;
  }

  .print-info-table td.value {
    color: var(--text);
  }

  /* Notes */
  .print-notes {
    padding: 15px;
    background: #f8f9fa;
    border-left: 4px solid #3498db;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
  }

  /* Annotations list */
  #print-annotations-list {
    font-size: 13px;
  }

  #print-annotations-list .annotation-item {
    margin-bottom: 12px;
    padding: 10px;
    background: #f8f9fa;
    border-left: 3px solid #3498db;
  }

  #print-annotations-list .annotation-type {
    font-weight: 600;
    color: var(--text);
    text-transform: capitalize;
  }

  #print-annotations-list .annotation-label {
    color: #555;
    margin-left: 10px;
  }

  /* Treatments list */
  #print-treatments-list {
    font-size: 14px;
  }

  #print-treatments-list .treatment-item {
    margin-bottom: 15px;
    padding: 15px;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
  }

  #print-treatments-list .treatment-name {
    font-weight: 600;
    font-size: 16px;
    color: var(--text);
    margin-bottom: 8px;
  }

  #print-treatments-list .treatment-details {
    color: #555;
    line-height: 1.5;
  }

  /* Canvas page */
  .print-page-canvas {
    text-align: center;
  }

  .print-canvas-container {
    margin: 20px auto;
    max-width: 7.5in;
  }

  #print-canvas {
    width: 7.5in !important;
    height: 9.7in !important;
    border: 1px solid #ddd;
  }

  /* Footer */
  .print-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 11px;
    color: #777;
    padding: 10px 0;
    border-top: 1px solid #ddd;
  }

  .print-footer p {
    margin: 0;
    line-height: 1.4;
  }
}

/* ==========================================================================
   Face Chart Page - Hide Header/Footer Elements
   ========================================================================== */

/* Removed global header hiding rules to prevent conflicts with page templates */

/* ==========================================================================
   Loading & Notification Styles
   ========================================================================== */

/* Global Loading Overlay */
.face-chart-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.face-chart-loading-content {
  text-align: center;
  padding: 40px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  max-width: 300px;
  width: 90%;
}

.face-chart-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #007cba;
  border-radius: 50%;
  animation: face-chart-spin 1s linear infinite;
  margin: 0 auto 20px;
}

@keyframes face-chart-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.face-chart-loading-text {
  color: #333;
  font-size: 16px;
  font-weight: 500;
  margin: 0;
}

/* Enhanced Notifications */
.ennu-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  min-width: 300px;
  max-width: 500px;
  padding: 16px 20px;
  margin-bottom: 10px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  animation: slideInRight 0.3s ease-out;
  backdrop-filter: blur(10px);
}

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

.ennu-notification.success {
  background: linear-gradient(135deg, #d4edda, #c3e6cb);
  border-left: 4px solid #28a745;
  color: #155724;
}

.ennu-notification.error {
  background: linear-gradient(135deg, #f8d7da, #f5c6cb);
  border-left: 4px solid #dc3545;
  color: #721c24;
}

.ennu-notification.warning {
  background: linear-gradient(135deg, #fff3cd, #ffeaa7);
  border-left: 4px solid #ffc107;
  color: #856404;
}

.ennu-notification.info {
  background: linear-gradient(135deg, #d1ecf1, #bee5eb);
  border-left: 4px solid #17a2b8;
  color: #0c5460;
}

.notification-icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 2px;
}

.notification-content {
  flex: 1;
  font-weight: 500;
}

.notification-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  margin-left: 8px;
  color: inherit;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  flex-shrink: 0;
}

.notification-close:hover {
  opacity: 1;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .ennu-notification {
    left: 10px;
    right: 10px;
    min-width: auto;
    max-width: none;
  }

  .face-chart-loading-content {
    padding: 30px 20px;
    margin: 20px;
  }
}

/* ==========================================================================
   Enhanced Error Handling & Accessibility
   ========================================================================== */

/* Error States */
.ennu-modal .error {
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  color: #721c24;
  padding: 12px 16px;
  border-radius: 6px;
  margin: 10px 0;
  font-size: 14px;
}

/* Success States */
.ennu-modal .success {
  background: #d4edda;
  border: 1px solid #c3e6cb;
  color: #155724;
  padding: 12px 16px;
  border-radius: 6px;
  margin: 10px 0;
  font-size: 14px;
}

/* Loading States */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  border-top-color: transparent;
  animation: button-loading-spinner 1s ease-in-out infinite;
}

@keyframes button-loading-spinner {
  to {
    transform: rotate(360deg);
  }
}

/* Accessibility Improvements */
.ennu-modal[aria-hidden="true"] {
  display: none !important;
}

.ennu-modal[aria-hidden="false"] {
  display: flex !important;
}

/* Focus management */
.ennu-modal.active .modal-content {
  outline: none;
}

.ennu-modal.active .modal-content:focus {
  box-shadow: 0 0 0 3px rgba(0, 123, 186, 0.5);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .ennu-notification {
    border: 2px solid;
  }

  .face-chart-loading-overlay {
    background: white;
    backdrop-filter: none;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .face-chart-spinner,
  .notification-close,
  .face-chart-loading-overlay {
    animation: none;
  }

  .ennu-notification {
    animation: none;
  }
}

/* ==========================================================================
   Content Lock Overlay
   ========================================================================== */

.content-lock-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.5s ease;
}

.content-lock-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.lock-message {
  background: white;
  border-radius: 16px;
  padding: 40px;
  max-width: 500px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  border: 1px solid #e1e5e9;
}

.lock-icon {
  color: #0073aa;
  margin-bottom: 20px;
}

.lock-icon svg {
  stroke-width: 1.5;
}

.lock-message h3 {
  margin: 0 0 15px 0;
  color: #1e1e1e;
  font-size: 24px;
  font-weight: 600;
}

.lock-message p {
  margin: 0 0 20px 0;
  color: #666;
  font-size: 16px;
  line-height: 1.5;
}

.lock-tip {
  background: #f0f8ff;
  border: 1px solid #b8d4f0;
  border-radius: 8px;
  padding: 15px;
  margin-top: 20px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.lock-tip .dashicons {
  color: #0073aa;
  font-size: 18px;
  margin-top: 2px;
  flex-shrink: 0;
}

.lock-tip span:not(.dashicons) {
  color: #0073aa;
  font-weight: 500;
  font-size: 14px;
  line-height: 1.4;
  text-align: left;
}

.lock-actions {
  margin-top: 25px;
  text-align: center;
}

.lock-actions .btn {
  background: #0073aa;
  border: 2px solid #0073aa;
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.lock-actions .btn:hover {
  background: #005a87;
  border-color: #005a87;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
}

.lock-actions .btn:active {
  transform: translateY(0);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .lock-message {
    margin: 20px;
    padding: 30px 25px;
  }

  .lock-message h3 {
    font-size: 20px;
  }

  .lock-message p {
    font-size: 14px;
  }
}

/* Removed global footer hiding rules to prevent conflicts with page templates */

/* Fix admin bar overlap issues on face chart page */
body.admin-bar .face-chart-page {
  margin-top: 32px;
}

/* Mode button compact styling */
.face-chart-header .btn-mode {
  position: relative;
  z-index: 101;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  transition: var(--transition);
  font-size: 11px;
  text-align: center;
  min-width: 65px;
  min-height: 50px;
}

/* Prevent admin bar from blocking face chart controls */
.face-chart-wrapper {
  position: relative;
  z-index: 50; /* Below admin bar but above other content */
}

/* ==========================================================================
   Responsive Design - Desktop, Tablet, Mobile
   ========================================================================== */

/* Tablet and smaller (≤1199px) */
@media (max-width: 1199px) {
  .header-row-1 {
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
  }

  .header-provider-info {
    order: 2;
    flex-basis: 100%;
    justify-content: center;
  }

  .header-time-info {
    order: 1;
    margin-left: auto;
  }

  .header-left {
    order: 3;
    flex-basis: 100%;
  }

  .mode-toggle-container {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 8px !important;
    max-width: none !important;
  }

  .mode-toggle-container .btn-mode {
    padding: 8px !important;
    font-size: 12px !important;
    justify-content: center !important;
  }

  .session-timer-display {
    flex-direction: column;
    gap: 2px;
    align-items: center;
  }
}

/* Mobile (≤767px) */
@media (max-width: 767px) {
  .face-chart-header.two-row {
    gap: 12px;
  }

  .header-row {
    padding: 12px 16px;
  }

  .header-row-1 {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .header-left {
    order: 1;
    text-align: center;
  }

  .header-logo {
    max-width: 200px;
    margin: 0 auto;
  }

  .header-provider-info {
    order: 2;
    justify-content: center;
  }

  .header-time-info {
    order: 3;
    text-align: center;
    margin-left: 0;
  }

  .header-row-2 {
    gap: 12px;
  }

  .mode-toggle-container {
    flex: 1;
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 6px !important;
  }

  .mode-toggle-container .btn-mode {
    padding: 6px 4px !important;
    font-size: 11px !important;
    min-height: 44px !important; /* Touch target */
  }

  .mode-toggle-container .btn-mode span {
    display: none !important; /* Hide text, show icons only */
  }

  .session-timer-display {
    flex-direction: column;
    gap: 2px;
    align-items: center;
    min-width: 100px;
  }

  .session-timer-label {
    font-size: 10px;
  }

  .session-timer-value {
    font-size: 20px;
  }

  .header-right {
    gap: 8px;
  }

  .btn-complete,
  .btn-checkout {
    padding: 10px 12px !important;
    font-size: 13px !important;
    min-height: 44px !important;
  }

  .header-row-3 {
    padding: 8px 16px;
  }

  .header-voice-recorder-compact {
    gap: 8px;
  }

  .header-voice-button {
    padding: 6px 12px !important;
    font-size: 13px !important;
    min-height: 36px !important;
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  .header-row {
    padding: 8px 12px;
  }

  .header-left h1,
  #chart-title {
    font-size: 24px;
  }

  .current-time-value,
  .session-timer-value {
    font-size: 18px;
  }

  .mode-toggle-container .btn-mode {
    padding: 4px 2px !important;
    font-size: 10px !important;
  }

  .btn-complete,
  .btn-checkout {
    padding: 8px 10px !important;
    font-size: 12px !important;
  }
}

/* ==========================================================================
   Mobile Drawers - Slide-in Sidebars
   ========================================================================== */

.face-chart-sidebar.sidebar-left,
.face-chart-sidebar.sidebar-right {
  contain: layout style paint;
  will-change: transform;
  transition: transform var(--transition);
}

.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  z-index: 1000;
  transition: opacity var(--transition), visibility var(--transition);
}

.sidebar-backdrop.active {
  opacity: 1;
  visibility: visible;
}

/* Desktop sidebar positioning */
@media (min-width: 1025px) {
  .face-chart-sidebar.sidebar-left {
    position: relative;
    width: 280px;
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: none; /* Hidden by default, toggle to show */
  }

  .face-chart-sidebar.sidebar-right {
    position: relative;
    width: 320px;
    background: var(--panel);
    border-left: 1px solid var(--border);
    display: none; /* Hidden by default, toggle to show */
  }

  /* Show sidebars when explicitly toggled */
  .face-chart-sidebar.sidebar-left.show,
  .face-chart-sidebar.sidebar-right.show {
    display: block;
  }
}

/* Drawer toggle buttons - applies to all screen sizes */
.btn-drawer-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  z-index: 1002;
  margin: 8px;
}

.btn-drawer-toggle:hover {
  background: var(--elev);
  color: var(--text);
}

.btn-drawer-toggle:focus {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Mobile drawer styles */
@media (max-width: 767px) {
  .face-chart-sidebar.sidebar-left {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    z-index: 1001;
    transform: translateX(-100%);
    background: var(--panel);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow);
  }

  .face-chart-sidebar.sidebar-left.open {
    transform: translateX(0);
  }

  .face-chart-sidebar.sidebar-right {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    z-index: 1001;
    transform: translateX(100%);
    background: var(--panel);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow);
  }

  .face-chart-sidebar.sidebar-right.open {
    transform: translateX(0);
  }

  /* Mobile canvas area adjusts for toolbars */
  .face-chart-canvas-container {
    position: relative;
    width: 100%;
    height: 100%;
  }

  .face-chart-canvas-toolbar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
    display: flex;
    gap: 8px;
    box-shadow: var(--shadow-soft);
    z-index: 100;
  }

  .face-chart-canvas-toolbar.mobile-docked {
    position: fixed;
    bottom: 10px;
    left: 10px;
    right: 10px;
    transform: none;
    justify-content: space-around;
  }
}

/* Prevent body scroll when drawers are open */
body.drawer-open {
  /* REMOVED: overflow: hidden and position: fixed to allow scrolling */
  /* Only prevent body scroll when drawer is open, but allow page scrolling */
  overflow-x: hidden;
  overflow-y: auto;
}

/* Ensure drawers are above content */
.face-chart-sidebar.sidebar-left.open,
.face-chart-sidebar.sidebar-right.open {
  z-index: 1001;
}

.sidebar-backdrop.active {
  z-index: 1000;
}

/* ==========================================================================
   Accessibility & Focus Management
   ========================================================================== */

/* Focus rings for keyboard navigation */
.face-chart-header .btn-mode:focus,
.face-chart-header .btn-complete:focus,
.face-chart-header .btn-checkout:focus,
.btn-drawer-toggle:focus,
.canvas-toolbar .btn-canvas-action:focus,
.sidebar-backdrop:focus {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --bg: #000000;
    --bg-soft: #111111;
    --panel: #222222;
    --elev: #333333;
    --text: #ffffff;
    --text-soft: #eeeeee;
    --muted: #cccccc;
    --border: #555555;
    --focus: #ffffff;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  :root {
    --transition: none;
    --transition-slow: none;
  }

  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Skip link for screen readers */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--accent);
  color: white;
  padding: 8px;
  text-decoration: none;
  border-radius: var(--radius);
  z-index: 10000;
  font-weight: 600;
}

.skip-link:focus {
  top: 6px;
}

/* Screen reader only text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   Responsive Canvas - Scaling & Toolbar Docking
   ========================================================================== */

.face-chart-canvas-area {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  contain: layout style paint;
}

.canvas-wrapper {
  position: relative;
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

#face-chart-canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

/* Canvas toolbar */
.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.canvas-toolbar .btn-canvas-action {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 12px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.canvas-toolbar .btn-canvas-action:hover {
  background: var(--elev);
  border-color: var(--accent-2);
}

.canvas-toolbar .btn-canvas-action:active,
.canvas-toolbar .btn-canvas-action.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Responsive canvas scaling */
@media (max-width: 1199px) {
  #face-chart-canvas {
    max-width: 95%;
    max-height: 90%;
  }

  .canvas-toolbar {
    padding: 10px;
    gap: 6px;
  }

  .canvas-toolbar .btn-canvas-action {
    padding: 6px 10px;
    font-size: 11px;
  }
}

@media (max-width: 991px) {
  #face-chart-canvas {
    max-width: 90%;
    max-height: 85%;
  }

  .canvas-toolbar {
    padding: 8px;
    gap: 4px;
    justify-content: flex-start;
  }

  .canvas-toolbar .btn-canvas-action {
    padding: 6px 8px;
    font-size: 10px;
    min-width: 36px;
    justify-content: center;
  }

  .canvas-toolbar .btn-canvas-action span {
    display: none; /* Hide text, show icons only */
  }
}

@media (max-width: 767px) {
  .face-chart-canvas-area {
    padding: 0;
  }

  #face-chart-canvas {
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    box-shadow: none;
  }

  /* Dock toolbar to bottom on mobile */
  .canvas-toolbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--panel);
    border-top: 1px solid var(--border);
    border-bottom: none;
    padding: 8px;
    gap: 4px;
    justify-content: space-around;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.4);
  }

  .canvas-toolbar .btn-canvas-action {
    flex: 1;
    min-width: 0;
    padding: 10px 6px;
    font-size: 11px;
    justify-content: center;
  }

  .canvas-toolbar .btn-canvas-action span {
    display: none; /* Hide text on mobile */
  }

  /* Adjust canvas wrapper for docked toolbar */
  .canvas-wrapper {
    padding-bottom: 60px; /* Space for docked toolbar */
  }
}

@media (max-width: 480px) {
  .canvas-toolbar .btn-canvas-action {
    padding: 8px 4px;
    font-size: 10px;
  }

  .canvas-wrapper {
    padding-bottom: 50px;
  }
}

/* Canvas overlay for loading states */
.canvas-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 18, 22, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  z-index: 50;
}

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

.canvas-overlay .loading-text {
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}

/* Canvas images strip */
.canvas-images-strip {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: var(--shadow-soft);
  z-index: 40;
  max-width: 90%;
  overflow-x: auto;
}

@media (max-width: 767px) {
  .canvas-images-strip {
    bottom: 80px; /* Above docked toolbar */
    max-width: 95%;
  }
}

/* Notes Panel Styling */
.notes-panel {
  padding: 24px;
  max-width: 800px;
  margin: 0 auto;
}

#notes-content {
  grid-column: 1 / -1; /* Span all columns */
  width: 100%;
}

#notes-content.active,
#notes-content[style*="display: block"] {
  grid-column: 1 / -1; /* Span all columns */
  width: 100%;
}

.notes-section h2 {
  color: var(--text);
  margin-bottom: 24px;
  font-size: 24px;
  font-weight: 600;
}

.notes-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.notes-card h3 {
  color: var(--text);
  margin: 0 0 8px 0;
  font-size: 18px;
  font-weight: 600;
}

.notes-description {
  color: var(--text-soft);
  margin: 0 0 16px 0;
  font-size: 14px;
  line-height: 1.4;
}

.notes-textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  min-height: 80px;
}

.notes-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.1);
}

.notes-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 20px;
}

.save-status {
  font-size: 14px;
  color: var(--text-soft);
}

.save-status.success {
  color: var(--accent);
}

.save-status.error {
  color: var(--danger);
}

/* Live transcription styling */
.live-transcription-card {
  border-left: 4px solid var(--accent);
}

.live-transcription-display {
  min-height: 120px;
  padding: 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 12px 0;
  position: relative;
}

.transcription-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-soft);
  font-style: italic;
  text-align: center;
  gap: 8px;
}

.transcription-placeholder .dashicons {
  font-size: 24px;
  width: 24px;
  height: 24px;
  color: var(--muted);
}

.live-transcription-text {
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--text);
  font-family: inherit;
  min-height: 80px;
}

.transcription-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.transcription-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 8px;
}

.transcription-status.recording {
  color: #dc3545;
}

.transcription-status.recording .recording-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background-color: #dc3545;
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

.transcription-status.processing {
  color: #ffc107;
}

/* Dark theme adjustments for notes */
.theme-dark .notes-card {
  background: var(--panel);
  border-color: var(--border);
}

.theme-dark .notes-textarea {
  background: var(--bg-soft);
  border-color: var(--border);
  color: var(--text);
}

.theme-dark .notes-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(39, 174, 96, 0.1);
}

.theme-dark .live-transcription-display {
  background: var(--elev);
  border-color: var(--border);
}

.theme-dark .transcription-placeholder {
  color: var(--muted);
}

.theme-dark .live-transcription-text {
  color: var(--text);
}
