:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #64748b;
  --success: #10b981;
  --error: #ef4444;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-secondary: #64748b;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* Login Page */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-box {
  background: var(--surface);
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 400px;
}

.login-box h1 {
  margin-bottom: 2rem;
  text-align: center;
  color: var(--primary);
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text);
}

.form-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Buttons */
.btn-primary,
.btn-secondary {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

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

.btn-secondary:hover:not(:disabled) {
  background: #475569;
}

/* Navigation */
.admin-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
}

.nav-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-content h1 {
  font-size: 1.5rem;
  color: var(--primary);
}

.nav-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

/* Main Content */
.admin-main {
  padding: 2rem;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
}

.posts-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.posts-header h2 {
  font-size: 2rem;
}

.header-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.search-input {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  min-width: 250px;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Posts List */
.posts-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.post-item {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s;
}

.post-item:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.post-info h3 {
  margin-bottom: 0.5rem;
  color: var(--text);
}

.post-meta {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.btn-edit {
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-edit:hover {
  background: var(--primary);
  color: white;
}

/* Editor */
.editor-container {
  max-width: 100%;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.editor-workspace {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 1.5rem;
  height: calc(100vh - 250px);
}

.editor-panel,
.preview-panel {
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.editor-panel h3,
.preview-panel h3 {
  margin-bottom: 1rem;
  color: var(--text);
}

#content-editor {
  flex: 1;
  width: 100%;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.95rem;
  line-height: 1.6;
  resize: none;
}

#content-editor:focus {
  outline: none;
  border-color: var(--primary);
}

.preview-content {
  flex: 1;
  overflow-y: auto;
}

.fm-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.fm-item:last-child {
  border-bottom: none;
}

.fm-item strong {
  display: inline-block;
  min-width: 100px;
  color: var(--text);
}

/* Messages */
.error-message,
.success-message {
  padding: 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.error-message {
  background: #fee2e2;
  color: var(--error);
  border: 1px solid var(--error);
}

.success-message {
  background: #d1fae5;
  color: var(--success);
  border: 1px solid var(--success);
}

.loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
}

.no-posts {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
}

.preview-content .error {
  color: var(--error);
  font-style: italic;
}

/* Responsive */
@media (max-width: 1024px) {
  .editor-workspace {
    grid-template-columns: 1fr;
    height: auto;
  }

  .editor-panel {
    min-height: 500px;
  }
}

@media (max-width: 768px) {
  .admin-main {
    padding: 1rem;
  }

  .nav-content {
    padding: 0 1rem;
  }

  .posts-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    flex-direction: column;
  }

  .search-input {
    width: 100%;
  }
}
