/* services/scratchpad/style.css - Premium Scratchpad Web Application Stylesheet */

/* ==========================================
   1. Theme Variables & Fonts
   ========================================== */
:root {
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'Fira Code', monospace;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  
  --transition-fast: 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.12);
}

.theme-light {
  --bg-app: #f1f5f9; /* Slate 100 */
  --bg-pane: #ffffff;
  --bg-header: rgba(255, 255, 255, 0.8);
  --text-primary: #0f172a; /* Slate 900 */
  --text-secondary: #475569; /* Slate 600 */
  --text-muted: #94a3b8; /* Slate 400 */
  --border-color: #e2e8f0; /* Slate 200 */
  
  --accent-primary: #6366f1; /* Indigo 500 */
  --accent-primary-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.15);
  
  --btn-bg: #f8fafc;
  --btn-hover: #f1f5f9;
  --btn-active: #e2e8f0;
  --btn-text: #334155;
  
  --calc-screen-bg: #f8fafc;
  --calc-btn-num: #ffffff;
  --calc-btn-op: #eff6ff;
  --calc-btn-op-text: #2563eb;
  
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-glow: rgba(239, 68, 68, 0.15);
  
  --canvas-bg: #ffffff;
  --scroll-thumb: #cbd5e1;
}

.theme-dark {
  --bg-app: #030712; /* Gray 950 */
  --bg-pane: rgba(17, 24, 39, 0.7); /* Gray 900 with glass opacity */
  --bg-header: rgba(17, 24, 39, 0.8);
  --text-primary: #f9fafb; /* Gray 50 */
  --text-secondary: #9ca3af; /* Gray 400 */
  --text-muted: #6b7280; /* Gray 500 */
  --border-color: rgba(255, 255, 255, 0.06);
  
  --accent-primary: #818cf8; /* Indigo 400 */
  --accent-primary-hover: #6366f1;
  --accent-glow: rgba(129, 140, 248, 0.25);
  
  --btn-bg: rgba(255, 255, 255, 0.03);
  --btn-hover: rgba(255, 255, 255, 0.08);
  --btn-active: rgba(255, 255, 255, 0.15);
  --btn-text: #f3f4f6;
  
  --calc-screen-bg: #090d16;
  --calc-btn-num: rgba(255, 255, 255, 0.02);
  --calc-btn-op: rgba(99, 102, 241, 0.08);
  --calc-btn-op-text: #a5b4fc;
  
  --danger: #f87171;
  --danger-hover: #ef4444;
  --danger-glow: rgba(248, 113, 113, 0.25);
  
  --canvas-bg: #1e293b; /* Slate 800 for dark drawing board */
  --scroll-thumb: #374151;
}

/* ==========================================
   2. Reset & Layout Setup
   ========================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-body);
  height: 100vh;
  overflow: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
}

/* ==========================================
   3. Header Styling (Stopwatch & Theme)
   ========================================== */
.app-header {
  height: 60px;
  background-color: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 10;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

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

.header-logo {
  width: 24px;
  height: 24px;
  color: var(--accent-primary);
}

.app-header h1 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.app-header h1 span {
  background: linear-gradient(135deg, var(--accent-primary) 0%, #06b6d4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Stopwatch Panel */
.stopwatch-container {
  display: flex;
  align-items: center;
  background: var(--calc-screen-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 4px 6px 4px 14px;
  gap: 8px;
  transition: all var(--transition-normal);
}

.stopwatch-display {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

.stopwatch-controls {
  display: flex;
  gap: 4px;
}

.btn-timer {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--btn-bg);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-timer:hover {
  background: var(--btn-hover);
  color: var(--text-primary);
}

.btn-timer-start {
  background: var(--accent-primary);
  color: white;
}

.btn-timer-start:hover {
  background: var(--accent-primary-hover);
  color: white;
}

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

.hidden {
  display: none !important;
}

/* Theme Toggle Button */
.btn-theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--btn-bg);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-theme-toggle:hover {
  background: var(--btn-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.btn-theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* ==========================================
   4. Main Workspace Split (Panes)
   ========================================== */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
  background-color: var(--bg-app);
}

.pane {
  background-color: var(--bg-pane);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background-color var(--transition-normal);
}

/* Divider styling */
.pane-divider {
  height: 1px;
  background-color: var(--border-color);
  flex-shrink: 0;
  transition: background-color var(--transition-normal);
}

/* ==========================================
   5. Paint Board Pane (Top Half)
   ========================================== */
.drawing-pane {
  height: 52%;
  min-height: 250px;
}

.pane-toolbar {
  height: 48px;
  background-color: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 16px;
  gap: 16px;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
  flex-shrink: 0;
}

.pane-toolbar::-webkit-scrollbar {
  display: none; /* Safari & Chrome */
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  border-right: 1px solid var(--border-color);
  padding-right: 16px;
}

.toolbar-group:last-child {
  border-right: none;
  padding-right: 0;
}

.group-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  user-select: none;
}

/* Colors list */
.color-picker-wrapper {
  display: flex;
  gap: 6px;
}

.color-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1), var(--shadow-sm);
}

.color-btn.active {
  transform: scale(1.15);
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

/* Line Weight Pickers */
.weight-picker-wrapper {
  display: flex;
  gap: 4px;
  background: var(--btn-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2px;
}

.weight-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.weight-btn:hover {
  background: var(--btn-hover);
}

.weight-btn.active {
  background: var(--bg-pane);
  color: var(--accent-primary);
  box-shadow: var(--shadow-sm);
}

.dot {
  background-color: currentColor;
  border-radius: 50%;
  display: block;
}

.dot-thin { width: 4px; height: 4px; }
.dot-medium { width: 8px; height: 8px; }
.dot-thick { width: 12px; height: 12px; }
.dot-vthick { width: 16px; height: 16px; }

/* Tool buttons */
.tool-picker-wrapper {
  display: flex;
  gap: 4px;
  background: var(--btn-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2px;
}

.tool-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.tool-btn:hover {
  background: var(--btn-hover);
}

.tool-btn.active {
  background: var(--bg-pane);
  color: var(--accent-primary);
  box-shadow: var(--shadow-sm);
}

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

/* Undo/Redo/Clear */
.actions-group {
  margin-left: auto;
}

.action-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--btn-bg);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.action-btn:hover:not(:disabled) {
  background: var(--btn-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

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

.danger-btn {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.15);
}

.danger-btn:hover:not(:disabled) {
  background: var(--danger-glow) !important;
  color: var(--danger-hover) !important;
  border-color: var(--danger) !important;
}

/* Canvas Area */
.canvas-container {
  flex: 1;
  position: relative;
  width: 100%;
  height: calc(100% - 48px);
  background-color: var(--canvas-bg);
  transition: background-color var(--transition-normal);
}

#paint-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  display: block;
}

/* ==========================================
   6. Calculator Pane (Bottom Half)
   ========================================== */
.calculator-pane {
  height: 48%;
  min-height: 250px;
}

.calc-inner-container {
  display: flex;
  flex: 1;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

/* Calculator Left Panel */
.calc-panel {
  flex: 1.2;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 12px;
  border-right: 1px solid var(--border-color);
  height: 100%;
  justify-content: space-between;
}

/* Calculator Screen */
.calc-display {
  background-color: var(--calc-screen-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  text-align: right;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 60px;
  flex-shrink: 0;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.calc-expr {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  min-height: 1.2em;
  word-wrap: break-word;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calc-value {
  font-family: var(--font-mono);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.1;
}

/* Calculator Grid */
.calc-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 6px;
  margin-top: 4px;
}

.calc-btn {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  outline: none;
}

.calc-btn svg {
  width: 18px;
  height: 18px;
}

.btn-num {
  background-color: var(--calc-btn-num);
  color: var(--text-primary);
}

.btn-num:hover {
  background-color: var(--btn-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-num:active {
  background-color: var(--btn-active);
  transform: translateY(0);
}

.btn-op {
  background-color: var(--calc-btn-op);
  color: var(--calc-btn-op-text);
}

.btn-op:hover {
  background-color: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--accent-glow);
}

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

.btn-func {
  background-color: var(--btn-bg);
  color: var(--text-secondary);
}

.btn-func:hover {
  background-color: var(--btn-hover);
  color: var(--text-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-func:active {
  background-color: var(--btn-active);
  transform: translateY(0);
}

/* Equal Button */
.btn-eq {
  background: linear-gradient(135deg, var(--accent-primary) 0%, #06b6d4 100%);
  color: white;
  border: none;
}

.btn-eq:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 15px var(--accent-glow);
}

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

/* Calculator Right Panel (History) */
.calc-history {
  flex: 0.8;
  display: flex;
  flex-direction: column;
  padding: 12px;
  background-color: rgba(0, 0, 0, 0.01);
  height: 100%;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.history-header h3 {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-clear-history {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.btn-clear-history:hover {
  color: var(--danger);
  background: var(--danger-glow);
}

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

.history-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

/* Custom Scrollbar */
.history-list::-webkit-scrollbar {
  width: 4px;
}

.history-list::-webkit-scrollbar-track {
  background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
  background-color: var(--scroll-thumb);
  border-radius: 10px;
}

/* Empty placeholder */
.history-list:empty::after {
  content: attr(data-placeholder);
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 32px;
  font-weight: 350;
}

/* History list items */
.history-item {
  background-color: var(--btn-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  cursor: pointer;
  text-align: right;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-item:hover {
  background-color: var(--btn-hover);
  border-color: var(--text-muted);
  transform: translateY(-1px);
}

.history-item-expr {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  word-wrap: break-word;
}

.history-item-result {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-primary);
}

/* ==========================================
   7. Responsive Layout / Adaptability
   ========================================== */
@media (max-width: 480px) {
  /* For very narrow screens (like < 480px), collapse calculator history or make it toggleable.
     But we can also stack calc-history below the grid, or just hide history list and toggle.
     Let's collapse history sidebar width to zero or hide it by default, and make it show on click,
     or simple layout: hide history. Since it's screen-split, 480px is narrow, we hide the history
     panel and make the calculator panel full-width. */
  .calc-history {
    display: none;
  }
  .calc-panel {
    border-right: none;
  }
}

@media (max-height: 600px) {
  /* Height critical adjustments */
  .app-header {
    height: 50px;
  }
  .app-main {
    height: calc(100vh - 50px);
  }
  .pane-toolbar {
    height: 40px;
  }
  .calc-value {
    font-size: 1.4rem;
  }
  .calc-btn {
    font-size: 1rem;
  }
}
