/* PageForge Styles - Modern, Clean Design */

/* CSS Custom Properties */
:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-active: #1e40af;
  --secondary-color: #64748b;
  --accent-color: #f59e0b;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Monaco', 'Cascadia Code', monospace;
  --transition-fast: 150ms ease-in-out;
  --transition-normal: 200ms ease-in-out;
}

/* Global Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  line-height: 1.5;
}

body {
  font-family: var(--font-family);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Header Styles */
header {
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

#doc-title {
  margin-left: 1.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  min-width: 200px;
}

#doc-title:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

.header-buttons {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Button Base Styles */
button, select, input[type="color"] {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
}

button:hover, select:hover, input[type="color"]:hover {
  border-color: var(--border-hover);
  background-color: var(--bg-tertiary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

button:active, select:active, input[type="color"]:active {
  transform: translateY(0);
  box-shadow: none;
}

button:focus, select:focus, input[type="color"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

/* Primary Button Variant */
button[id$="-btn"] {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

button[id$="-btn"]:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
}

button[id$="-btn"]:active {
  background-color: var(--primary-active);
  border-color: var(--primary-active);
}

/* Toolbar Styles */
#toolbar {
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

/* Toolbar Button Specific Styles */
#toolbar button {
  min-width: 2rem;
  height: 2rem;
  padding: 0;
  font-weight: 600;
  font-size: 0.875rem;
}

#toolbar button.active {
  background-color: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

#toolbar button.active:hover {
  background-color: #d97706;
  border-color: #d97706;
}

#font-size-select {
  padding: 0.25rem 0.5rem;
  min-width: 4rem;
  height: 2rem;
}

#color-picker {
  border: 1px solid var(--border-color);
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: none;
}

/* Editor Styles */
#editor {
  flex: 1;
  padding: 2rem;
  background-color: var(--bg-primary);
  border: none;
  outline: none;
  font-family: var(--font-family);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-primary);
  overflow-y: auto;
  min-height: 60vh;
  max-width: 100%;
  margin: 0 auto;
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius-md);
  margin: 1rem;
}

#editor:focus {
  box-shadow: var(--shadow-md);
}

#editor p {
  margin-bottom: 1rem;
}

#editor p:last-child {
  margin-bottom: 0;
}

#editor h1, #editor h2, #editor h3, #editor h4, #editor h5, #editor h6 {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

#editor h1 { font-size: 2rem; }
#editor h2 { font-size: 1.5rem; }
#editor h3 { font-size: 1.25rem; }
#editor h4 { font-size: 1.125rem; }
#editor h5 { font-size: 1rem; }
#editor h6 { font-size: 0.875rem; }

#editor ul, #editor ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

#editor li {
  margin-bottom: 0.25rem;
}

#editor blockquote {
  border-left: 4px solid var(--border-color);
  padding-left: 1rem;
  margin: 1rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

#editor code {
  background-color: var(--bg-tertiary);
  padding: 0.125rem 0.25rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.875em;
  color: var(--text-primary);
}

#editor pre {
  background-color: var(--bg-tertiary);
  padding: 1rem;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 1rem 0;
  border: 1px solid var(--border-color);
}

#editor pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

/* Status Bar Styles */
footer {
  background-color: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
  box-shadow: 0 -1px 3px 0 rgb(0 0 0 / 0.1), 0 -1px 2px -1px rgb(0 0 0 / 0.1);
}

#status-bar span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Responsive Design */

/* Tablet Styles */
@media (max-width: 1024px) {
  #editor {
    padding: 1.5rem;
    margin: 0.5rem;
  }

  header {
    padding: 1rem;
  }

  #toolbar {
    padding: 0.5rem 1rem;
    gap: 0.375rem;
  }

  #toolbar button {
    min-width: 1.75rem;
    height: 1.75rem;
    font-size: 0.75rem;
  }

  #font-size-select {
    min-width: 3.5rem;
    height: 1.75rem;
    font-size: 0.75rem;
  }

  #color-picker {
    width: 1.75rem;
    height: 1.75rem;
  }
}

/* Mobile Styles */
@media (max-width: 768px) {
  header {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    padding: 1rem;
  }

  h1 {
    text-align: center;
    font-size: 1.25rem;
  }

  #doc-title {
    margin-left: 0;
    width: 100%;
    min-width: auto;
  }

  .header-buttons {
    justify-content: center;
    flex-wrap: wrap;
  }

  #toolbar {
    padding: 0.5rem;
    justify-content: center;
    gap: 0.25rem;
  }

  #toolbar button {
    min-width: 1.5rem;
    height: 1.5rem;
    font-size: 0.7rem;
    padding: 0;
  }

  #font-size-select {
    min-width: 3rem;
    height: 1.5rem;
    font-size: 0.7rem;
  }

  #color-picker {
    width: 1.5rem;
    height: 1.5rem;
  }

  #editor {
    padding: 1rem;
    margin: 0.25rem;
    font-size: 0.9rem;
    line-height: 1.6;
    min-height: 50vh;
  }

  footer {
    padding: 0.5rem 1rem;
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
    text-align: center;
  }

  #status-bar span {
    justify-content: center;
  }
}

/* Small Mobile Styles */
@media (max-width: 480px) {
  #editor {
    padding: 0.75rem;
    margin: 0.125rem;
    font-size: 0.85rem;
  }

  header {
    padding: 0.75rem;
  }

  #toolbar {
    padding: 0.375rem;
    gap: 0.125rem;
  }

  #toolbar button {
    min-width: 1.25rem;
    height: 1.25rem;
    font-size: 0.65rem;
  }

  #font-size-select {
    min-width: 2.5rem;
    height: 1.25rem;
    font-size: 0.65rem;
  }

  #color-picker {
    width: 1.25rem;
    height: 1.25rem;
  }

  footer {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
  }
}

/* Print Styles */
@media print {
  body {
    background: white;
  }

  header, #toolbar, footer {
    display: none;
  }

  #editor {
    box-shadow: none;
    margin: 0;
    padding: 0;
    font-size: 12pt;
    line-height: 1.4;
  }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  :root {
    --border-color: #000000;
    --border-hover: #000000;
    --bg-tertiary: #ffffff;
  }
}

/* Focus Visible for Keyboard Navigation */
button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}