/* ZeroBin - Zero Knowledge Encrypted Paste */

:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --bg-input: #0d1117;
  --border: #30363d;
  --border-focus: #58a6ff;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --danger: #f85149;
  --success: #3fb950;
  --warning: #d29922;
  --radius: 6px;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --max-width: 960px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

header h1 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.lock-icon {
  font-size: 1rem;
}

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

.header-right {
  display: flex;
  gap: 8px;
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: var(--font-sans);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

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

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: #238636;
  border-color: rgba(240, 246, 252, 0.1);
  color: #fff;
}

.btn-primary:hover {
  background: #2ea043;
}

.btn-large {
  padding: 10px 24px;
  font-size: 1rem;
}

.btn-small {
  padding: 4px 10px;
  font-size: 0.78rem;
}

.btn-secondary {
  background: transparent;
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg-tertiary);
}

/* Main */

main {
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 20px 24px;
}

/* Toolbar */

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.optional {
  color: var(--text-muted);
  font-weight: 400;
}

select, input[type="text"], input[type="password"] {
  padding: 6px 10px;
  font-size: 0.85rem;
  font-family: var(--font-sans);
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s;
}

select:focus, input:focus {
  border-color: var(--border-focus);
}

select {
  cursor: pointer;
}

input[type="file"] {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

input[type="file"]::file-selector-button {
  padding: 4px 10px;
  margin-right: 8px;
  font-size: 0.78rem;
  font-family: var(--font-sans);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 6px 0;
}

.checkbox-field input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.file-field {
  flex: 1;
}

/* Textarea */

textarea {
  width: 100%;
  min-height: 350px;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.5;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
  outline: none;
  tab-size: 4;
  transition: border-color 0.15s;
}

textarea:focus {
  border-color: var(--border-focus);
}

textarea::placeholder {
  color: var(--text-muted);
}

/* Actions */

.actions {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

/* View mode */

.paste-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-danger {
  background: rgba(248, 81, 73, 0.15);
  color: var(--danger);
  border: 1px solid rgba(248, 81, 73, 0.3);
}

.paste-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

/* Content display */

#content-display {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
}

#content-display pre {
  padding: 16px;
  margin: 0;
  overflow-x: auto;
}

#content-display pre code {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.5;
}

#content-display .markdown-body {
  padding: 20px;
}

#content-display .plaintext-body {
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Markdown styles */

.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  margin-top: 1.2em;
  margin-bottom: 0.5em;
  font-weight: 600;
  line-height: 1.25;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3em;
}

.markdown-body h1 { font-size: 1.6rem; }
.markdown-body h2 { font-size: 1.3rem; }
.markdown-body h3 { font-size: 1.1rem; border-bottom: none; }

.markdown-body p {
  margin-bottom: 0.8em;
}

.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 2px 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
}

.markdown-body pre {
  padding: 12px;
  background: var(--bg-primary);
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 1em;
}

.markdown-body pre code {
  padding: 0;
  background: transparent;
}

.markdown-body blockquote {
  border-left: 3px solid var(--border);
  padding-left: 12px;
  color: var(--text-secondary);
  margin-bottom: 0.8em;
}

.markdown-body ul, .markdown-body ol {
  padding-left: 24px;
  margin-bottom: 0.8em;
}

.markdown-body table {
  border-collapse: collapse;
  margin-bottom: 1em;
  width: 100%;
}

.markdown-body th, .markdown-body td {
  padding: 6px 12px;
  border: 1px solid var(--border);
}

.markdown-body th {
  background: var(--bg-tertiary);
  font-weight: 600;
}

.markdown-body img {
  max-width: 100%;
  border-radius: var(--radius);
}

.markdown-body a {
  color: var(--accent);
  text-decoration: none;
}

.markdown-body a:hover {
  text-decoration: underline;
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5em 0;
}

/* Password prompt */

.password-box {
  max-width: 400px;
  margin: 40px auto;
  padding: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.password-box p {
  margin-bottom: 16px;
  color: var(--text-secondary);
}

.password-box input {
  width: 100%;
  margin-bottom: 12px;
  padding: 8px 12px;
}

.password-box .btn {
  width: 100%;
}

/* Attachment */

.attachment-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 12px;
  font-size: 0.85rem;
}

.attachment-icon {
  font-size: 1.1rem;
}

#attachment-name {
  font-weight: 500;
}

#attachment-size {
  color: var(--text-muted);
}

/* Discussion / Comments */

#discussion-section {
  margin-top: 24px;
}

#discussion-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.comment {
  padding: 12px 16px;
  margin-bottom: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.comment-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.comment-nickname {
  font-weight: 600;
  color: var(--text-secondary);
}

.comment-body {
  font-size: 0.88rem;
}

.comment-form {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comment-form textarea {
  min-height: 80px;
}

.comment-form input {
  max-width: 250px;
}

.comment-form .btn {
  align-self: flex-end;
}

/* Loading */

#loading {
  position: fixed;
  inset: 0;
  background: rgba(13, 17, 23, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 1000;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#loading p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Error bar */

#error-bar {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: rgba(248, 81, 73, 0.12);
  border: 1px solid rgba(248, 81, 73, 0.3);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 0.85rem;
  z-index: 200;
  max-width: 90%;
}

#error-close {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 4px;
}

/* QR Modal */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  position: relative;
  max-width: 320px;
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.3rem;
}

.modal-content h3 {
  margin-bottom: 16px;
  font-size: 1rem;
}

#qr-canvas {
  margin: 0 auto;
  display: block;
  border-radius: 4px;
}

.qr-note {
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Paste error */

.paste-error {
  text-align: center;
  padding: 48px 24px;
}

.paste-error-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.paste-error h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--warning);
}

.paste-error p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-bottom: 20px;
}

/* Hidden utility */

.hidden {
  display: none !important;
}

/* Footer */

footer {
  padding: 16px 24px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

footer strong {
  color: var(--text-secondary);
}

/* Responsive */

@media (max-width: 640px) {
  header {
    padding: 10px 16px;
  }

  .tagline {
    display: none;
  }

  main {
    padding: 12px 16px;
  }

  .toolbar-row {
    flex-direction: column;
    gap: 10px;
  }

  .field {
    width: 100%;
  }

  select, input[type="text"], input[type="password"] {
    width: 100%;
  }

  textarea {
    min-height: 250px;
  }

  .paste-actions {
    flex-wrap: wrap;
  }
}
