/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --bg-surface: #1a1d27;
  --bg-elevated: #232733;
  --border: #2e3347;
  --text: #e2e5f0;
  --text-muted: #8b90a5;
  --accent: #6c8cff;
  --accent-hover: #8aa4ff;
  --success: #4ade80;
  --error: #f87171;
  --warning: #fbbf24;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;
  --radius: 8px;
  --radius-lg: 12px;
}

html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* === Login === */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-container { width: 100%; max-width: 400px; padding: 1rem; }

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.login-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
  color: var(--text-muted);
}

.form-group input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
}

/* === Alerts === */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}

.alert-error {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--error);
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  background: var(--bg-elevated);
  color: var(--text);
}

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }

/* === Header === */
.app-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.5rem;
  height: 56px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left { flex-shrink: 0; }

.logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text) !important;
}

.header-nav {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}

.nav-link {
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: all 0.2s;
}

.nav-link:hover {
  background: var(--bg-elevated);
  color: var(--text);
}

.nav-link.active {
  background: var(--bg-elevated);
  color: var(--accent);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.user-badge {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: 0.25rem 0.625rem;
  border-radius: 99px;
}

/* === Main Content === */
.app-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* === Dashboard === */
.dashboard-hero {
  margin-bottom: 2rem;
}

.dashboard-hero h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.dashboard-hero p {
  color: var(--text-muted);
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.tool-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: all 0.2s;
  color: var(--text);
}

.tool-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.tool-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

.tool-card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
}

.tool-card p {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* === Converter Page === */
.converter-header {
  margin-bottom: 1.5rem;
}

.converter-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.converter-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.converter-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* === Panels === */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.panel-actions {
  display: flex;
  gap: 0.375rem;
}

/* === Markdown Input === */
.md-input {
  width: 100%;
  min-height: 350px;
  padding: 1rem;
  background: var(--bg);
  border: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.7;
  resize: vertical;
}

.md-input:focus {
  outline: none;
}

.md-input::placeholder {
  color: var(--text-muted);
  opacity: 0.5;
}

/* === Action Bar === */
.action-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* === Output Areas === */
.output-area {
  padding: 1rem;
  background: var(--bg);
  overflow-x: auto;
}

.output-area pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.output-area code {
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.7;
  color: var(--text);
}

.preview-area {
  padding: 1.5rem;
  background: #fff;
  color: #1a1a1a;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.7;
  min-height: 200px;
}

.preview-area h1 { font-size: 2rem; margin: 0 0 0.75rem; }
.preview-area h2 { font-size: 1.5rem; margin: 1.5rem 0 0.5rem; }
.preview-area h3 { font-size: 1.25rem; margin: 1.25rem 0 0.5rem; }
.preview-area h4 { font-size: 1.1rem; margin: 1rem 0 0.5rem; }
.preview-area p { margin: 0 0 0.75rem; }
.preview-area ul, .preview-area ol { margin: 0 0 0.75rem; padding-left: 1.5rem; }
.preview-area li { margin-bottom: 0.25rem; }
.preview-area blockquote {
  border-left: 3px solid #ddd;
  margin: 0 0 0.75rem;
  padding: 0.5rem 1rem;
  color: #555;
}
.preview-area code {
  background: #f4f4f4;
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  font-size: 0.9em;
  font-family: 'Courier New', monospace;
}
.preview-area pre {
  background: #f4f4f4;
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 0 0 0.75rem;
}
.preview-area pre code {
  background: none;
  padding: 0;
}
.preview-area table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 0 0.75rem;
}
.preview-area th, .preview-area td {
  border: 1px solid #ddd;
  padding: 0.5rem 0.75rem;
  text-align: left;
}
.preview-area th {
  background: #f4f4f4;
  font-weight: 600;
}
.preview-area img { max-width: 100%; height: auto; }
.preview-area hr {
  border: none;
  border-top: 1px solid #ddd;
  margin: 1.5rem 0;
}
.preview-area a { color: #0563C1; }

/* === Upload Button === */
.upload-btn { cursor: pointer; }

/* === Toast Notification === */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 1000;
  animation: toastIn 0.3s ease;
}

.toast-success {
  background: rgba(74, 222, 128, 0.15);
  border: 1px solid rgba(74, 222, 128, 0.3);
  color: var(--success);
}

.toast-error {
  background: rgba(248, 113, 113, 0.15);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--error);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === Loading State === */
.btn.loading {
  opacity: 0.7;
  pointer-events: none;
}

/* === Responsive === */
@media (max-width: 640px) {
  .app-header { padding: 0 1rem; gap: 0.75rem; }
  .app-main { padding: 1.25rem 1rem; }
  .login-card { padding: 1.5rem; }
  .action-bar { flex-direction: column; }
  .action-bar .btn { width: 100%; justify-content: center; }
}
