
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,400;0,500;0,600;0,700;1,400;1,600&display=swap');

:root {
  /* ===== LIGHT THEME (Tailwind v3 OKLCH Components) ===== */
  --background: 99% .002 286;
  --foreground: 21% .006 286;
  --card: 100% 0 0;
  --card-foreground: 21% .006 286;
  --popover: 100% 0 0;
  --popover-foreground: 21% .006 286;
  --primary: 21% .006 286;
  --primary-foreground: 98.5% 0 0;
  --secondary: 95.5% .002 286;
  --secondary-foreground: 21% .006 286;
  --muted: 95.5% .002 286;
  --muted-foreground: 49% .012 286;
  --accent: 60% 0.18 215;
  --accent-foreground: 98.5% 0 0;
  --destructive: 57.7% .245 27.325;
  --destructive-foreground: 98.5% 0 0;
  --border: 90% .004 286;
  --input: 90% .004 286;
  --ring: 60% 0.18 215;
  --success: 72% .19 149;
  --warning: 77% .16 70;
  --caution: 64% .21 25;
  --code-bg: 96% .003 286;
  --code-panel-bg: 17.2% .004 286;
  --code-panel-header: 22.5% .006 286;
  
  --radius: 0.625rem;
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
  --radius-full: 9999px;
}

.dark {
  /* ===== DARK THEME ===== */
  --background: 14.8% .004 286;
  --foreground: 92% .004 286;
  --card: 18.5% .005 286;
  --card-foreground: 92% .004 286;
  --popover: 18.5% .005 286;
  --popover-foreground: 92% .004 286;
  --primary: 92% .004 286;
  --primary-foreground: 16.5% .005 286;
  --secondary: 22.5% .006 286;
  --secondary-foreground: 92% .004 286;
  --muted: 22.5% .006 286;
  --muted-foreground: 65% .012 286;
  --accent: 80% 0.16 215;
  --accent-foreground: 16.5% .005 286;
  --destructive: 63.7% .237 25.331;
  --destructive-foreground: 92% .004 286;
  --border: 26.8% .006 286;
  --input: 26.8% .006 286;
  --ring: 80% 0.16 215;
  --success: 72% .19 149;
  --warning: 77% .16 70;
  --caution: 64% .21 25;
  --code-bg: 17.2% .004 286;
}

/* Base resets from spec */
body {
  font-family: 'JetBrains Mono', monospace;
  background-color: oklch(var(--background));
  color: oklch(var(--foreground));
}
* {
  border-color: oklch(var(--border));
}

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400;1,600&display=swap');

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  letter-spacing: -0.012em;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.dark ::-webkit-scrollbar-thumb {
  background: #1e293b;
}

.dark ::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

pre,
code {
  font-family: 'JetBrains Mono', monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Split.js Resizer Gutter Styling (LeetCode Grab Handles & Accessible Separators) */
.gutter {
  position: relative;
  background-color: #e2e8f0;
  transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s;
  z-index: 20;
  flex-shrink: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.dark .gutter {
  background-color: #1e293b;
}

.gutter::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: #94a3b8;
  border-radius: 9999px;
  transition: background-color 0.2s, transform 0.2s;
}

.dark .gutter::after {
  background-color: #475569;
}

.gutter.gutter-horizontal {
  cursor: col-resize;
  width: 8px !important;
}

.gutter.gutter-horizontal::after {
  width: 3px;
  height: 28px;
}

.gutter.gutter-vertical {
  cursor: row-resize;
  height: 8px !important;
}

.gutter.gutter-vertical::after {
  width: 28px;
  height: 3px;
}

.gutter:hover,
.gutter:active {
  background-color: rgba(99, 102, 241, 0.25) !important;
}

.gutter:hover::after,
.gutter:active::after {
  background-color: #6366f1 !important;
  transform: translate(-50%, -50%) scale(1.25);
}

/* WAI-ARIA Focus Visible Indicators for Accessible Keyboard Resizing */
.gutter:focus {
  outline: none;
}

.gutter:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 1px;
  background-color: rgba(99, 102, 241, 0.35) !important;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.gutter:focus-visible::after {
  background-color: #4f46e5 !important;
  transform: translate(-50%, -50%) scale(1.35);
}

.dark .gutter:focus-visible {
  outline-color: #818cf8;
  background-color: rgba(129, 140, 248, 0.35) !important;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.25);
}

.dark .gutter:focus-visible::after {
  background-color: #818cf8 !important;
}

/* =========================================================
   ACCESSIBLE RESIZABLE PANELS & QUESTION PANEL CONSTRAINTS
   ========================================================= */

/* Question Panel 70% Max Width & Overflow Scrolling */
@media (min-width: 768px) {
  #workspace-screen:not(.layout-stacked) #panel-left {
    max-width: 70% !important;
    min-width: 260px;
  }

  #workspace-screen:not(.layout-stacked) #panel-right {
    min-width: 30% !important;
  }
}

#panel-left {
  min-width: 0;
  overflow: hidden;
}

#left-panel-content {
  overflow-y: auto;
  overflow-x: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  min-width: 0;
  max-width: 100%;
}

#left-panel-content pre,
#left-panel-content code {
  max-width: 100%;
  overflow-x: auto;
}

#prob-desc,
#prob-constraints,
#prob-solution-body {
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Custom Scrollbar Helper */
.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}

.dark .custom-scrollbar::-webkit-scrollbar-thumb {
  background: #1e293b;
}

/* =========================================================
   ENHANCED UI STYLES (Dropdowns, Checkboxes, Cards)
   ========================================================= */

/* Custom Dropdown Styling */
.app-select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 0.65rem 2.5rem 0.65rem 0.875rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 500;
  color: #0f172a;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748B' stroke-width='2.2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  background-size: 1rem 1rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
}

.app-select:hover {
  border-color: #cbd5e1;
  background-color: #f8fafc;
}

.app-select:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.18);
}

.dark .app-select {
  background-color: #111726;
  border-color: #1e293b;
  color: #f1f5f9;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394A3B8' stroke-width='2.2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.2);
}

.dark .app-select:hover {
  border-color: #334155;
  background-color: #151d30;
}

.dark .app-select:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.28);
}

/* Custom Interactive Checkbox Card */
.pattern-checkbox-card {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.55rem 0.8rem;
  border-radius: 0.65rem;
  border: 1px solid #e2e8f0;
  background-color: #ffffff;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  user-select: none;
}

.pattern-checkbox-card:hover {
  border-color: #c7d2fe;
  background-color: #f8fafc;
  transform: translateY(-0.5px);
}

.dark .pattern-checkbox-card {
  border-color: #1e293b;
  background-color: #0d1322;
}

.dark .pattern-checkbox-card:hover {
  border-color: #3730a3;
  background-color: rgba(79, 70, 229, 0.08);
  transform: translateY(-0.5px);
}

.pattern-checkbox-card.is-selected {
  border-color: #4f46e5;
  background-color: #eef2ff;
  color: #3730a3;
  box-shadow: 0 1px 3px rgba(79, 70, 229, 0.12);
}

.dark .pattern-checkbox-card.is-selected {
  border-color: #6366f1;
  background-color: rgba(99, 102, 241, 0.16);
  color: #c7d2fe;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.pattern-checkbox-card input[type="checkbox"] {
  accent-color: #4f46e5;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 0.3rem;
  cursor: pointer;
}

/* =========================================================
   MOBILE RESPONSIVE ENHANCEMENTS (< 768px ONLY)
   Preserves desktop layout completely untouched.
   ========================================================= */
@media (max-width: 767px) {
  /* Prevent iOS toolbar clipping and enforce true dynamic viewport height */
  body {
    height: 100dvh;
    min-height: 100dvh;
  }

  /* Workspace containers on mobile take remaining space dynamically, allowing header to wrap */
  #workspace-screen:not(.hidden),
  #pattern-workspace-view:not(.hidden) {
    flex: 1 1 0% !important;
    height: auto !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }

  /* Active panels flex properly inside mobile screen height */
  #workspace-screen:not(.hidden) > #panel-left:not(.hidden),
  #workspace-screen:not(.hidden) > #panel-right:not(.hidden),
  #pattern-workspace-view:not(.hidden) > #pattern-left-panel:not(.hidden),
  #pattern-workspace-view:not(.hidden) > #pattern-right-panel:not(.hidden) {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    max-height: 100% !important;
    width: 100% !important;
    height: 100% !important;
  }

  /* Active section inside #panel-right on mobile */
  #panel-right > #editor-top-section:not(.hidden),
  #panel-right > #console-drawer:not(.hidden) {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    max-height: 100% !important;
    width: 100% !important;
    height: 100% !important;
  }

  #monaco-container {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: 100% !important;
  }

  /* Smooth vertical touch scrolling for problem description, constraints, and solutions */
  #left-panel-content,
  #prob-desc,
  #pattern-left-panel > div.overflow-y-auto,
  #pattern-addtl-container,
  #tab-content-testcase,
  #tab-content-console {
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: contain !important;
    touch-action: pan-y !important;
  }

  /* Mobile tabs touch target sizing */
  #mob-tab-problem,
  #mob-tab-code,
  #mob-tab-console,
  #p-mob-tab-problem,
  #p-mob-tab-patterns {
    min-height: 38px;
    touch-action: manipulation;
  }

  /* Header compact adjustments */
  header {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
}
/* Markdown Callouts */
.prose-callout {
  --callout: oklch(var(--accent));
  margin: 1.5rem 0;
  padding: 0.75rem 1rem;
  border: 1px solid color-mix(in oklab, var(--callout) 40%, transparent);
  border-left: 4px solid var(--callout);
  border-radius: 0.5rem;
  background-color: oklch(var(--card));
  font-size: 0.875rem;
  line-height: 1.625;
}
.prose-callout .prose-callout-title {
  margin: 0 0 0.25rem;
  font-weight: 600;
  color: var(--callout);
}
.prose-callout-note,
.prose-callout-info,
.prose-callout-important { --callout: oklch(var(--accent)); }
.prose-callout-tip,
.prose-callout-success   { --callout: oklch(var(--success)); }
.prose-callout-warning   { --callout: oklch(var(--warning)); }
.prose-callout-caution   { --callout: oklch(var(--caution)); }

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

/* Creative Background Patterns */
.bg-grid-pattern {
  background-size: 30px 30px;
  background-image: linear-gradient(to right, oklch(var(--border) / 0.4) 1px, transparent 1px),
                    linear-gradient(to bottom, oklch(var(--border) / 0.4) 1px, transparent 1px);
}
.bg-dot-pattern {
  background-image: radial-gradient(oklch(var(--border) / 0.7) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* Small Grid & Wave Animations */
.bg-grid-small {
  background-size: 20px 20px;
  background-image: linear-gradient(to right, oklch(var(--border) / 0.5) 1px, transparent 1px),
                    linear-gradient(to bottom, oklch(var(--border) / 0.5) 1px, transparent 1px);
}
@keyframes wave-drift {
  0% { -webkit-mask-position: 0px center; mask-position: 0px center; }
  100% { -webkit-mask-position: -1200px center; mask-position: -1200px center; }
}
@keyframes wave-drift-reverse {
  0% { -webkit-mask-position: 0px center; mask-position: 0px center; }
  100% { -webkit-mask-position: 1000px center; mask-position: 1000px center; }
}
.animate-wave {
  animation: wave-drift 30s linear infinite;
}
.animate-wave-slow {
  animation: wave-drift-reverse 45s linear infinite;
}

.bg-grid-diagonal {
  background-image: repeating-linear-gradient(45deg, oklch(var(--border) / 0.5) 0, oklch(var(--border) / 0.5) 1px, transparent 1px, transparent 32px),
                    repeating-linear-gradient(-45deg, oklch(var(--border) / 0.5) 0, oklch(var(--border) / 0.5) 1px, transparent 1px, transparent 32px);
}
