/* ═══════════════════════════════════════════════════════════════
   DSWallah UI — Fixed CSS (No excessive !important)
   Dark theme for tools pages
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg-primary: #05050a;
  --bg-secondary: #0a0a12;
  --bg-card: #141420;
  --bg-hover: #1a1a28;
  --border-color: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --text-primary: #f0eefa;
  --text-secondary: #9896b8;
  --text-muted: #55536a;
  --accent: #f0a500;
  --accent-hover: #ffc857;
  --accent-glow: rgba(240, 165, 0, 0.18);
}

/* Base */
html {
  background: var(--bg-primary);
  color-scheme: dark;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--text-primary);
}

/* Header */
header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

header a {
  color: var(--text-secondary);
}

header a:hover {
  color: var(--text-primary);
}

/* Nav */
nav {
  background: transparent;
  border: none;
}

nav a {
  color: var(--text-secondary);
}

nav a:hover {
  color: var(--text-primary);
}

/* Main */
main {
  background: var(--bg-primary);
}

/* Cards */
.card,
[class*="card"],
[data-slot="card"] {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  transition: all 0.2s ease;
}

.card:hover,
[class*="card"]:hover {
  border-color: var(--border-hover);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

/* Inputs */
[data-slot="input"],
[data-slot="textarea"],
input,
select,
textarea {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.9rem;
  transition: all 0.15s ease;
}

[data-slot="input"]:focus,
[data-slot="textarea"]:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  outline: none;
}

[data-slot="input"]::placeholder,
[data-slot="textarea"]::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

/* Buttons */
.btn,
[data-slot="button"],
button {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn:hover,
[data-slot="button"]:hover,
button:hover {
  background: var(--bg-hover);
  border-color: rgba(240, 165, 0, 0.3);
}

/* Primary Buttons */
.btn-primary,
.nav-cta,
[class*="primary"]:not(input):not(textarea),
button[class*="bg-primary"],
button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover)) !important;
  color: #000 !important;
  border: none !important;
  font-weight: 600 !important;
}

.btn-primary:hover,
.nav-cta:hover,
button.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(240, 165, 0, 0.3);
}

/* Badges */
.badge,
[data-slot="badge"] {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Text Colors */
.text-muted,
.text-muted-foreground,
[class*="text-muted"],
p,
small,
span:not([class*="text-"]) {
  color: var(--text-secondary);
}

/* Sidebar */
[class*="sidebar"],
[role="complementary"],
[role="navigation"],
aside {
  background: var(--bg-secondary);
  border-color: var(--border-color);
}

[class*="sidebar"] a,
aside a {
  color: var(--text-secondary);
}

[class*="sidebar"] a:hover,
aside a:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

/* Sections */
article,
section {
  background: transparent;
}

/* Code Blocks */
pre,
code {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
}

pre {
  padding: 16px;
  overflow-x: auto;
}

code {
  padding: 2px 6px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Tool Page Specific */
.tool-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.tool-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-title svg {
  color: var(--accent);
}

.tool-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Editor */
.editor-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-primary);
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.editor-content {
  flex: 1;
  overflow: auto;
  padding: 16px;
}

/* Output */
.output-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.output-content {
  padding: 16px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
}

/* SEO Block */
.seo-block {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  padding: 40px 16px 48px;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.seo-block-inner {
  max-width: 880px;
  margin: 0 auto;
}

.seo-block h2 {
  color: var(--accent);
  font-size: 1.1rem;
  margin: 24px 0 12px;
}

.seo-block h3 {
  color: var(--text-primary);
  font-size: 1rem;
  margin: 16px 0 8px;
}

.seo-block p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.7;
  margin-bottom: 12px;
}

.seo-block ul,
.seo-block ol {
  padding-left: 20px;
  margin-bottom: 12px;
}

.seo-block li {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.7;
  margin-bottom: 4px;
}

.seo-block a {
  color: #5ec4ff;
}

.seo-block a:hover {
  color: var(--accent);
}

.seo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin: 16px 0;
}

.seo-related {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.seo-related span {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.seo-related a {
  color: var(--accent);
  font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 768px) {
  .seo-grid {
    grid-template-columns: 1fr;
  }
  
  .tool-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

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

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

/* Syntax Highlighting (CodeMirror) */
.cm-editor {
  background: var(--bg-card) !important;
  height: 100%;
}

.cm-editor .cm-content {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
}

.cm-editor .cm-gutters {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
}

.cm-editor .cm-activeLineGutter {
  background: rgba(240, 165, 0, 0.1);
}

.cm-editor .cm-activeLine {
  background: rgba(240, 165, 0, 0.05);
}

/* Dracula Theme Override */
.cm-s-dracula .cm-editor {
  background: var(--bg-card) !important;
}

.cm-s-dracula .cm-gutters {
  background: var(--bg-secondary) !important;
}

/* ═══════════════════════════════════════════════════════════════
   Back Arrow (Small, Fixed Position)
   ═══════════════════════════════════════════════════════════════ */
.dsw-back {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.dsw-back:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.dsw-back svg {
  width: 18px;
  height: 18px;
}

/* ═══════════════════════════════════════════════════════════════
   Copy Button for Code Blocks
   ═══════════════════════════════════════════════════════════════ */
.dsw-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: rgba(240, 165, 0, 0.1);
  border: 1px solid rgba(240, 165, 0, 0.3);
  border-radius: 6px;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  opacity: 0;
}

pre:hover .dsw-copy-btn {
  opacity: 1;
}

.dsw-copy-btn:hover {
  background: rgba(240, 165, 0, 0.2);
  border-color: var(--accent);
}

/* ═══════════════════════════════════════════════════════════════
   Toast Notification
   ═══════════════════════════════════════════════════════════════ */
.dsw-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  padding: 10px 20px;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.3s ease;
}

.dsw-toast.out {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to { opacity: 0; transform: translateX(-50%) translateY(10px); }
}

/* ═══════════════════════════════════════════════════════════════
   Code Area Sizing (Fix Small Inputs)
   ═══════════════════════════════════════════════════════════════ */
textarea,
input[type="text"],
input:not([type]) {
  min-height: 44px;
}

textarea {
  min-height: 200px !important;
}

/* Code Editors */
.CodeMirror,
.monaco-editor,
[class*="editor-body"],
[class*="code-area"],
[class*="code-editor"] {
  min-height: 300px !important;
  height: auto !important;
}

/* Specific tool fixes */
.plab-editor-body,
.plab-editor,
.sql-editor,
.code-container,
.editor-wrapper {
  min-height: 350px !important;
  flex: 1 !important;
}

/* Make sure code areas fill available space */
.flex-1 {
  flex: 1 !important;
  min-height: 0 !important;
}

/* Fix for tools with split views */
.plab-body,
.split-view,
.tool-body {
  display: flex;
  flex: 1;
  min-height: 400px;
}

/* Fix for output areas */
.plab-out,
.output,
.result-area,
.console-output {
  min-height: 150px;
  max-height: 400px;
  overflow: auto;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .dsw-back {
    bottom: 16px;
    left: 16px;
    width: 36px;
    height: 36px;
  }
  
  .dsw-back svg {
    width: 16px;
    height: 16px;
  }
  
  textarea {
    min-height: 150px !important;
  }
  
  .plab-body,
  .split-view,
  .tool-body {
    min-height: 300px;
  }
}
