:root {
  --primary-color: #4660F6;
  --primary-hover: #3549d1;
  --bg-color: #F1F4F9;
  --card-bg: #ffffff;
  --sidebar-bg: #FFFFFF;
  --text-main: #1E293B;
  --text-muted: #64748B;
  --text-light: #94A3B8;
  --border-color: #E2E8F0;
  --success-color: #10B981;
  --error-color: #EF4444;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --sidebar-width: 200px;
}

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

body {
  font-family: 'Inter', 'Lato', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Layout */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  z-index: 1000;
  /* Increased z-index */
}

.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  width: calc(100% - var(--sidebar-width));
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Sidebar Elements */
.logo-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 1.75rem;
}

.logo-icon {
  width: 34px;
  height: 34px;
  background: #f0f3ff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.logo-text {
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-main);
}

.nav-menu {
  list-style: none;
  flex: 1;
}

.nav-item {
  margin-bottom: 0.5rem;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 0.55rem 0.75rem;
  border-radius: 0.5rem;
  color: var(--text-main);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.82rem;
  transition: all 0.2s;
  gap: 0.5rem;
}

.nav-link:hover,
.nav-link.active {
  background: #F8FAFC;
  color: var(--primary-color);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
}

.status-badge {
  background: #DCFCE7;
  color: #166534;
  padding: 0.4rem 0.8rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-block;
  margin-bottom: 1rem;
}

/* Header */
.app-header {
  background: white;
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 90;
}

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

.back-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-main);
  font-size: 1.2rem;
}

/* Main Grid */
.editor-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 2rem;
  padding: 2.5rem;
  max-width: 1300px;
  margin: 0;
  /* Align to the left to respect margin-left better */
  width: 100%;
}

@media (max-width: 1100px) {
  .editor-grid {
    grid-template-columns: 1fr;
    padding: 1.5rem;
  }
}

.content-main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.settings-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Cards & Components */
.card-editor {
  background: white;
  border-radius: 1.25rem;
  padding: 2.5rem;
  border: 1px solid var(--border-color);
}

.card-settings {
  background: white;
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid var(--border-color);
}

/* Typography Inputs */
.input-label-caps {
  text-transform: uppercase;
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--text-light);
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
  display: block;
}

.title-input {
  border: none;
  padding: 0;
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--text-main);
  width: 100%;
  margin-bottom: 2rem;
}

.title-input:focus {
  outline: none;
}

.title-input::placeholder {
  color: #CBD5E1;
}

/* Upload Area */
.upload-container {
  display: block;
  /* Ensure it takes full width */
  width: 100%;
  border: 2px dashed #CBD5E1;
  border-radius: 1.25rem;
  padding: 4rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  background: #F8FAFC;
  margin-bottom: 2rem;
  overflow: hidden;
}

.upload-container:hover {
  border-color: var(--primary-color);
  background: #f5f8ff;
  transform: translateY(-2px);
}

.upload-icon {
  font-size: 2.5rem;
  color: #94A3B8;
  margin-bottom: 1.25rem;
  display: block;
}

.upload-text {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

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

.image-preview-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 1rem;
  object-fit: cover;
}

/* Toolbar */
.rich-toolbar {
  display: flex;
  gap: 1.5rem;
  padding: 0.75rem 0;
  margin: 1.5rem 0;
  border-top: 1px solid #F1F5F9;
  border-bottom: 1px solid #F1F5F9;
  color: var(--text-main);
}

.toolbar-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  transition: all 0.2s;
}

.toolbar-btn:hover {
  background: #F1F5F9;
  color: var(--primary-color);
}

.toolbar-separator {
  width: 1px;
  height: 20px;
  background: #E2E8F0;
  align-self: center;
  margin: 0 0.25rem;
}

#btn-image:hover {
  color: #10B981;
}

#btn-video:hover {
  color: #F59E0B;
}

#btn-audio:hover {
  color: #8B5CF6;
}

.content-textarea {
  border: none;
  width: 100%;
  min-height: 400px;
  font-size: 1.1rem;
  color: var(--text-main);
  resize: none;
  line-height: 1.6;
}

.content-textarea:focus {
  outline: none;
}

/* WYSIWYG editor (contenteditable) */
.wysiwyg-editor {
  cursor: text;
  padding: 0.25rem 0;
}

.wysiwyg-editor:empty::before {
  content: attr(data-placeholder);
  color: #94a3b8;
  pointer-events: none;
}

.wysiwyg-editor h2 { font-size: 1.5rem; font-weight: 700; margin: 1.2rem 0 0.5rem; }
.wysiwyg-editor h3 { font-size: 1.2rem; font-weight: 700; margin: 1rem 0 0.4rem; }
.wysiwyg-editor strong { font-weight: 700; }
.wysiwyg-editor em { font-style: italic; }
.wysiwyg-editor ul { padding-left: 1.5rem; margin: 0.5rem 0; }
.wysiwyg-editor li { margin: 0.25rem 0; }
.wysiwyg-editor a { color: var(--accent); text-decoration: underline; }
.wysiwyg-editor img { max-width: 100%; border-radius: 0.5rem; margin: 0.5rem 0; }
.wysiwyg-editor iframe { max-width: 100%; margin: 0.75rem 0; display: block; }
.wysiwyg-editor audio { width: 100%; margin: 0.75rem 0; }

/* Settings Form */
.section-title {
  font-size: 0.9rem;
  font-weight: 800;
  margin-bottom: 1rem;
  display: block;
}

.form-field {
  margin-bottom: 1.25rem;
}

.field-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.form-select,
.form-input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
  background: #F8FAFC;
  font-size: 0.9rem;
  font-weight: 500;
}

/* Tag System */
.tags-input-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.tag-badge {
  background: #EEF2FF;
  color: var(--primary-color);
  padding: 0.25rem 0.6rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tag-remove {
  cursor: pointer;
  font-size: 0.9rem;
}

/* Buttons */
.btn-primary {
  background: var(--primary-color);
  color: white;
  padding: 0.6rem 2rem;
  border-radius: 9999px;
  font-weight: 700;
  border: none;
  cursor: pointer;
}

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

.btn-outline {
  background: white;
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

/* Helpers */
/* List View Styles */
.list-container {
  padding: 2.5rem;
  max-width: 1300px;
  margin: 0;
  width: 100%;
}

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

.filter-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  background: white;
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.search-box {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-box i {
  position: absolute;
  left: 1rem;
  color: var(--text-light);
}

.search-box input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border-color);
  background: #F8FAFC;
  font-size: 0.9rem;
}

.filter-select {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border-color);
  background: #F8FAFC;
  font-size: 0.9rem;
  font-weight: 500;
  min-width: 180px;
}

.articles-stack {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.article-card {
  background: white;
  border-radius: 1.25rem;
  padding: 1.5rem 2rem;
  border: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.article-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--primary-color);
}

.article-info h3 {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.article-meta {
  display: flex;
  gap: 1.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.article-status {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Badges */
.badge {
  padding: 0.4rem 1rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: capitalize;
}

.badge-published {
  background: #DCFCE7;
  color: #166534;
}

.badge-draft {
  background: #FEF3C7;
  color: #92400E;
}

.badge-visibility {
  background: #F1F5F9;
  color: #475569;
  font-size: 0.7rem;
}

.badge-visibility.visible {
  color: #6366F1;
}

.arrow-link {
  color: #CBD5E1;
  font-size: 1.2rem;
  transition: color 0.2s;
}

.article-card:hover .arrow-link {
  color: var(--primary-color);
}

.hidden {
  display: none !important;
}

/* Helpers */
/* List View Styles */

/* Toast Success Override */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 1rem 1.5rem;
  border-radius: 1rem;
  background: white;
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  z-index: 2000;
  border-left: 4px solid var(--primary-color);
  transform: translateY(200%);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
  transform: translateY(0);
}

/* Content Media Styles */
.video-container {
  position: relative;
  padding-bottom: 56.25%;
  /* 16:9 */
  height: 0;
  overflow: hidden;
  max-width: 100%;
  background: #000;
  border-radius: 12px;
  margin: 1.5rem 0;
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

audio {
  width: 100%;
  margin: 1.5rem 0;
  border-radius: 99px;
}