/**
 * HasteBloom - Styles
 * Modernes, minimalistisches Dark-UI
 */

/* ============================================
   CSS Variables & Reset
   ============================================ */
:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --border-color: #30363d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent-primary: #f778ba;
  --accent-secondary: #ff9ecd;
  --accent-glow: rgba(247, 120, 186, 0.15);
  --success: #3fb950;
  --error: #f85149;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --transition: 0.2s ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

/* ============================================
   App Layout (Fullscreen)
   ============================================ */
.app {
  height: 100vh;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ============================================
   Top Bar
   ============================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.topbar-left,
.topbar-right {
  flex: 1;
  display: flex;
  gap: 0.5rem;
}

.topbar-left {
  justify-content: flex-start;
}

/* Settings Dropdown */
.settings-dropdown {
  position: relative;
}

.btn-icon {
  padding: 0.5rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--accent-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.btn-icon:hover {
  color: var(--accent-secondary);
  border-color: var(--accent-primary);
}

.btn-icon.active {
  color: var(--accent-secondary);
  border-color: var(--accent-primary);
  background: var(--accent-glow);
}

.settings-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  min-width: 220px;
  box-shadow: var(--shadow);
  z-index: 100;
  display: none;
}

.settings-menu.show {
  display: block;
}

.settings-item {
  margin-bottom: 1rem;
}

.settings-item:last-child {
  margin-bottom: 0;
}

.settings-item label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.settings-input,
.settings-select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition);
}

.settings-input:focus,
.settings-select:focus {
  border-color: var(--accent-primary);
}

.settings-input::placeholder {
  color: var(--text-muted);
}

.settings-select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

.settings-select option {
  background: var(--bg-secondary);
}

/* Hide number input spinners */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.protected-badge {
  font-size: 0.75rem;
  color: var(--accent-primary);
  background: var(--accent-glow);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
}

/* Unlock Area */
.unlock-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.unlock-box {
  text-align: center;
  max-width: 400px;
}

.unlock-box h2 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.unlock-box p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.unlock-box form {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.unlock-input {
  width: 220px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition);
}

.unlock-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.unlock-input::placeholder {
  color: var(--text-muted);
}

.topbar-right {
  justify-content: flex-end;
}

/* ============================================
   Tabs Bar
   ============================================ */
.tabs-bar {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0 1rem;
  gap: 0.25rem;
  overflow-x: auto;
}

.tabs-list {
  display: flex;
  gap: 0.25rem;
}

.tab {
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  font-family: inherit;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  position: relative;
}

.tab:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.tab.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

.tab .tab-close {
  display: none;
  margin-left: 0.5rem;
  font-size: 0.75rem;
  opacity: 0.6;
}

.tab:hover .tab-close {
  display: inline;
}

.tab .tab-close:hover {
  opacity: 1;
  color: var(--error);
}

.tab-add {
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  background: transparent;
  border: none;
  color: var(--accent-primary);
  cursor: pointer;
  transition: all var(--transition);
  border-radius: var(--radius-sm);
}

.tab-add:hover {
  background: var(--accent-glow);
}

.tab-name-input {
  background: var(--bg-secondary);
  border: 1px solid var(--accent-primary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: inherit;
  padding: 0.4rem 0.5rem;
  width: auto;
  min-width: 60px;
  outline: none;
}

.tab-name-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.page-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.logo {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  white-space: nowrap;
}

.view-count {
  color: var(--accent-primary);
  font-size: 0.8rem;
  margin-left: 0.75rem;
  background: var(--accent-glow);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  line-height: 1;
}

.view-icon {
  font-size: 0.75rem;
  line-height: 1;
}

.paste-id {
  color: var(--accent-primary);
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  background: var(--accent-glow);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 0.2s;
}

.paste-id:hover {
  opacity: 0.8;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent-primary);
  color: #0d1117;
}

.btn-primary:hover {
  background: var(--accent-secondary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(247, 120, 186, 0.3);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--border-color);
  border-color: var(--text-muted);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ============================================
   Editor Area (Fullscreen)
   ============================================ */
.editor-area {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.editor-fullscreen {
  flex: 1;
  width: 100%;
  height: 0;
  min-height: 0;
  padding: 1.5rem 2rem;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Fira Code', monospace;
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: none;
  outline: none;
  resize: none;
  tab-size: 2;
  white-space: pre;
  overflow: scroll;
}

.editor-fullscreen::placeholder {
  color: var(--text-muted);
}

.status-bar {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 2rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

/* Viewer Fullscreen (same style as editor) */
.viewer-fullscreen {
  flex: 1 1 0;
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 1.5rem 2rem;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Fira Code', monospace;
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: none;
  overflow: scroll;
  white-space: pre;
}

.viewer-fullscreen code {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  background: transparent !important;
  display: block;
}

/* ============================================
   Code Viewer
   ============================================ */
.code-viewer {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.code-viewer pre {
  margin: 0;
  padding: 1.25rem;
  overflow-x: auto;
  min-height: 400px;
}

.code-viewer code {
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Fira Code', monospace;
  font-size: 0.9rem;
  line-height: 1.65;
  background: transparent !important;
}

/* Highlight.js Override */
.hljs {
  background: transparent !important;
  padding: 0 !important;
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 0.85rem 1.5rem;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 1000;
  box-shadow: var(--shadow);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
}

.toast.success {
  border-color: var(--success);
  background: rgba(63, 185, 80, 0.1);
}

.toast.error {
  border-color: var(--error);
  background: rgba(248, 81, 73, 0.1);
}

/* ============================================
   Loading State
   ============================================ */
.btn.loading {
  position: relative;
  color: transparent !important;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.btn-primary.loading::after {
  border-top-color: #0d1117;
}

.btn-secondary.loading::after {
  border-top-color: var(--text-primary);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 600px) {
  .container {
    padding: 1.25rem 1rem;
  }

  .logo {
    font-size: 1.75rem;
  }

  .toolbar {
    justify-content: center;
  }

  .btn {
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
  }

  .editor {
    min-height: 350px;
    font-size: 0.85rem;
  }
}

/* ============================================
   Scrollbar Styling
   ============================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================
   Selection
   ============================================ */
::selection {
  background: var(--accent-primary);
  color: #0d1117;
}

/* ============================================
   Error Page
   ============================================ */
.error-page {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.error-content {
  text-align: center;
  max-width: 400px;
}

.error-emoji {
  font-size: 6rem;
  line-height: 1;
  margin-bottom: 1.5rem;
}

.error-title {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 1rem 0;
}

.error-message {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.6;
  margin: 0 0 2rem 0;
}
