/* ========================================
   MY TOOLBOX - Geeky Dark Theme
   ======================================== */

:root {
  --bg: #0d0d0d;
  --bg-card: #141414;
  --bg-card-hover: #1a1a1a;
  --bg-input: #1a1a1a;
  --bg-surface: #111;
  --border: #222;
  --border-hover: #333;
  --text: #e0e0e0;
  --text-dim: #888;
  --text-muted: #555;
  --primary: #00ff88;
  --primary-dim: rgba(0, 255, 136, 0.15);
  --primary-glow: rgba(0, 255, 136, 0.3);
  --danger: #ff4444;
  --warning: #ffaa00;
  --info: #00aaff;
  --radius: 8px;
  --radius-sm: 4px;
  --font: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Cascadia Code', monospace;
  --transition: 0.2s ease;
  --max-width: 1200px;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Selection */
::selection { background: var(--primary-dim); color: var(--primary); }

/* App Container */
#app {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* ========================================
   Header
   ======================================== */
.site-header {
  padding: 60px 0 40px;
  text-align: center;
}

.ascii-logo {
  font-family: var(--font);
  font-size: 12px;
  line-height: 1.3;
  color: var(--primary);
  text-shadow: 0 0 20px var(--primary-glow);
  margin-bottom: 12px;
  user-select: none;
}

.tagline {
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 300;
}

.cursor {
  animation: blink 1s step-end infinite;
  color: var(--primary);
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ========================================
   Search
   ======================================== */
.search-container {
  max-width: 480px;
  margin: 0 auto 48px;
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
}

#search-input {
  width: 100%;
  padding: 12px 50px 12px 40px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

#search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim);
}

#search-input::placeholder {
  color: var(--text-muted);
}

.search-hint {
  position: absolute;
  right: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font);
  pointer-events: none;
}

/* ========================================
   Tool Grid
   ======================================== */
.category-section {
  margin-bottom: 48px;
}

.category-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding-left: 4px;
}

.category-title::before {
  content: '// ';
  color: var(--primary);
  opacity: 0.5;
}

.tools-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

/* ========================================
   Tool Card
   ======================================== */
.tool-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
}

.tool-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 255, 136, 0.03), transparent);
  transition: left 0.5s ease;
}

.tool-card:hover::before {
  left: 100%;
}

.tool-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  box-shadow: 0 0 20px rgba(0, 255, 136, 0.05);
  transform: translateY(-1px);
}

.tool-card:hover .tool-card-name {
  color: var(--primary);
}

.tool-card:hover .tool-card-arrow {
  opacity: 1;
  transform: translateX(0);
}

.tool-card-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-dim);
  border-radius: var(--radius-sm);
  font-size: 16px;
  flex-shrink: 0;
}

.tool-card-info {
  flex: 1;
  min-width: 0;
}

.tool-card-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: color var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-card-desc {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.tool-card-arrow {
  color: var(--text-muted);
  opacity: 0;
  transform: translateX(-4px);
  transition: all var(--transition);
  flex-shrink: 0;
  font-size: 12px;
}

/* ========================================
   Tool Page
   ======================================== */
.tool-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 0 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  border: 1px solid transparent;
  flex-shrink: 0;
}

.back-btn:hover {
  color: var(--primary);
  border-color: var(--border);
  background: var(--bg-card);
}

#tool-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

#tool-description {
  color: var(--text-dim);
  font-size: 12px;
  margin-bottom: 24px;
  padding-top: 8px;
}

#tool-content {
  padding-bottom: 60px;
}

/* ========================================
   Common Tool UI Components
   ======================================== */

/* Input Groups */
.tool-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tool-col {
  flex: 1;
  min-width: 200px;
}

/* Labels */
.tool-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

/* Text Inputs */
.tool-input, .tool-textarea, .tool-select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.tool-input:focus, .tool-textarea:focus, .tool-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-dim);
}

.tool-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
}

.tool-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* Color Input */
.tool-color-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-color-input {
  width: 40px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: none;
  padding: 2px;
}

.tool-color-input::-webkit-color-swatch-wrapper { padding: 0; }
.tool-color-input::-webkit-color-swatch { border: none; border-radius: 2px; }

/* Buttons */
.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.tool-btn:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.tool-btn-primary {
  background: var(--primary);
  color: var(--bg);
  border-color: var(--primary);
  font-weight: 600;
}

.tool-btn-primary:hover {
  background: #00e07a;
  border-color: #00e07a;
  box-shadow: 0 0 15px var(--primary-dim);
}

.tool-btn-sm {
  padding: 4px 10px;
  font-size: 11px;
}

.tool-btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Output / Code blocks */
.tool-output {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  position: relative;
  margin: 16px 0;
}

.tool-output .copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
}

/* Preview Panels */
.tool-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  margin: 16px 0;
}

/* Tabs */
.tool-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
}

.tool-tab {
  padding: 8px 16px;
  font-size: 12px;
  font-family: var(--font);
  color: var(--text-dim);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.tool-tab:hover {
  color: var(--text);
}

.tool-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tool-tab-content {
  display: none;
}

.tool-tab-content.active {
  display: block;
}

/* Cards / Sections */
.tool-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

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

/* Color Swatch */
.color-swatch {
  width: 100%;
  height: 48px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform var(--transition);
}

.color-swatch:hover {
  transform: scale(1.02);
}

/* Result badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 500;
}

.badge-pass {
  background: rgba(0, 255, 136, 0.1);
  color: var(--primary);
  border: 1px solid rgba(0, 255, 136, 0.2);
}

.badge-fail {
  background: rgba(255, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(255, 68, 68, 0.2);
}

.badge-warn {
  background: rgba(255, 170, 0, 0.1);
  color: var(--warning);
  border: 1px solid rgba(255, 170, 0, 0.2);
}

/* File Upload Area */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-card);
}

.upload-area:hover, .upload-area.drag-over {
  border-color: var(--primary);
  background: var(--primary-dim);
}

.upload-area input[type="file"] {
  display: none;
}

.upload-area p {
  color: var(--text-dim);
  font-size: 13px;
}

.upload-area .upload-icon {
  font-size: 28px;
  margin-bottom: 8px;
  display: block;
}

/* Slider / Range */
.tool-range {
  width: 100%;
  -webkit-appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}

.tool-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px var(--primary-glow);
}

/* Table */
.tool-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.tool-table th, .tool-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.tool-table th {
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 11px;
}

.tool-table tr:hover td {
  background: var(--bg-card);
}

/* Inline result display */
.result-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  margin: 16px 0;
}

.result-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Separator */
.tool-separator {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* Grid for results */
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.result-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}

/* Canvas container */
.canvas-container {
  background: repeating-conic-gradient(#222 0% 25%, #1a1a1a 0% 50%) 50% / 16px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  margin: 16px 0;
}

.canvas-container canvas, .canvas-container img {
  max-width: 100%;
  height: auto;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card);
  border: 1px solid var(--primary);
  color: var(--primary);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 12px;
  z-index: 9999;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  box-shadow: 0 0 20px var(--primary-dim);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Footer */
.site-footer {
  text-align: center;
  padding: 40px 0;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

.site-footer p {
  color: var(--text-muted);
  font-size: 11px;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
  #app { padding: 0 16px; }
  .site-header { padding: 40px 0 24px; }
  .ascii-logo { font-size: 9px; }
  .tools-row { grid-template-columns: 1fr; }
  .tool-row { flex-direction: column; }
  .tool-col { min-width: auto; }
  .tool-nav { flex-wrap: wrap; }
  #tool-title { font-size: 14px; }
  .result-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

@media (max-width: 480px) {
  html { font-size: 13px; }
  .ascii-logo { font-size: 7px; }
  .search-container { margin-bottom: 32px; }
}

/* ========================================
   Animations
   ======================================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.3s ease forwards;
}

/* Palette lock button */
.lock-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity var(--transition);
}

.lock-btn:hover { opacity: 1; }
.lock-btn.locked { opacity: 1; }

/* Calculator */
.calc-btn {
  padding: 12px;
  font-family: var(--font);
  font-size: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
}

.calc-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
}

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

.calc-btn.wide {
  grid-column: span 2;
}

/* Cheat sheet search */
.cheat-item {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cheat-item:hover {
  background: var(--bg-card);
}

.cheat-class {
  color: var(--primary);
}

.cheat-value {
  color: var(--text-dim);
}

/* Hidden */
.hidden { display: none !important; }

/* Number input hide arrows */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] { -moz-appearance: textfield; }
