/* ─── RESET & BASE ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #080811;
  --bg2: #0c0c1a;
  --bg3: #0f0f1e;
  --bg4: #12121e;
  --border: #1a1a2e;
  --border2: #2a2a3e;
  --text: #e0e0f0;
  --text2: #888;
  --text3: #555;
  --accent: #ff6b35;
  --accent2: #f7931e;
  --green: #00d4aa;
  --purple: #7c6af7;
  --red: #ff6060;
  --sidebar-w: 220px;
  --sidebar-w-closed: 58px;
  --radius: 10px;
  --radius-sm: 7px;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 14px; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

.hidden { display: none !important; }

/* ─── LOGIN ─────────────────────────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 60% 40%, rgba(255,107,53,.08) 0%, transparent 60%), var(--bg);
}
.login-box {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 16px;
  padding: 40px; width: 100%; max-width: 380px;
}
.login-logo {
  width: 48px; height: 48px; background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 20px; margin: 0 auto 20px;
}
.login-title { font-size: 24px; font-weight: 800; text-align: center; letter-spacing: -.02em; margin-bottom: 6px; }
.login-sub { color: var(--text3); font-size: 13px; text-align: center; margin-bottom: 28px; }
.login-error { background: rgba(255,96,96,.1); border: 1px solid rgba(255,96,96,.3); color: var(--red); padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 13px; }
.login-hint { text-align: center; color: var(--text3); font-size: 12px; margin-top: 16px; }
.btn-full { width: 100%; justify-content: center; }

/* ─── APP LAYOUT ─────────────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

/* ─── SIDEBAR ─────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w-closed); background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0; transition: width .3s cubic-bezier(.4,0,.2,1);
  overflow: hidden; position: relative;
}
.sidebar.open { width: var(--sidebar-w); }

.sidebar-logo {
  padding: 20px 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10; min-height: 64px;
}
.logo-icon {
  width: 30px; height: 30px; background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 7px; display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.logo-text { font-weight: 800; font-size: 15px; white-space: nowrap; opacity: 0; transition: opacity .2s; }
.sidebar.open .logo-text { opacity: 1; }

.sidebar-nav { flex: 1; padding-top: 10px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  cursor: pointer; color: var(--text2); border-left: 2px solid transparent;
  transition: all .2s; white-space: nowrap; margin-bottom: 1px;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.03); }
.nav-item.active { color: #fff; background: rgba(255,107,53,.12); border-left-color: var(--accent); }
.nav-icon { font-size: 15px; flex-shrink: 0; width: 20px; text-align: center; }
.nav-label { font-size: 13px; opacity: 0; transition: opacity .2s; }
.sidebar.open .nav-label { opacity: 1; }

.sidebar-user {
  padding: 14px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10;
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; flex-shrink: 0;
}
.user-info { opacity: 0; transition: opacity .2s; white-space: nowrap; }
.sidebar.open .user-info { opacity: 1; }
.user-name { font-size: 12px; font-weight: 600; }
.user-role { font-size: 10px; color: var(--text3); }

.sidebar-toggle {
  background: transparent; border: none; border-top: 1px solid var(--border);
  padding: 12px; color: var(--text3); cursor: pointer; font-size: 13px;
  width: 100%; transition: color .2s;
}
.sidebar-toggle:hover { color: var(--text); }

/* ─── MAIN ─────────────────────────────────────────────────────────────────── */
.main { flex: 1; overflow: auto; padding: 28px; }

/* ─── CARDS ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg3); border: 1px solid #1e1e30;
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}

/* ─── BUTTONS ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm); border: none;
  cursor: pointer; font-size: 13px; font-weight: 600;
  font-family: inherit; transition: all .15s; white-space: nowrap;
}
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
.btn-primary:hover { opacity: .9; transform: translateY(-1px); }
.btn-secondary { background: var(--bg4); color: #c8c8e8; border: 1px solid var(--border2); }
.btn-secondary:hover { background: #1e1e30; }
.btn-danger { background: rgba(255,96,96,.12); color: var(--red); border: 1px solid rgba(255,96,96,.25); }
.btn-danger:hover { background: rgba(255,96,96,.2); }
.btn-success { background: rgba(0,212,170,.12); color: var(--green); border: 1px solid rgba(0,212,170,.25); }
.btn-success:hover { background: rgba(0,212,170,.2); }
.btn-sm { padding: 5px 11px; font-size: 12px; }

/* ─── FORMS ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.label { display: block; font-size: 11px; color: var(--text2); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .06em; }
.input {
  width: 100%; background: var(--bg4); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: 9px 13px; color: var(--text);
  font-size: 14px; font-family: inherit; outline: none; transition: border .15s;
}
.input:focus { border-color: var(--accent); }
select.input option { background: var(--bg4); }
textarea.input { resize: vertical; min-height: 80px; }

/* ─── TAGS ─────────────────────────────────────────────────────────────────── */
.tag {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 700; margin-right: 4px; margin-bottom: 4px;
}
.tag-green { background: rgba(0,212,170,.15); color: var(--green); border: 1px solid rgba(0,212,170,.3); }
.tag-purple { background: rgba(124,106,247,.15); color: var(--purple); border: 1px solid rgba(124,106,247,.3); }
.tag-orange { background: rgba(255,107,53,.15); color: var(--accent); border: 1px solid rgba(255,107,53,.3); }
.tag-gray { background: rgba(136,136,136,.12); color: var(--text2); border: 1px solid rgba(136,136,136,.2); }
.tag-default { background: rgba(124,106,247,.12); color: var(--purple); border: 1px solid rgba(124,106,247,.2); }

/* ─── PAGE HEADER ─────────────────────────────────────────────────────────────── */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.page-title { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.page-sub { color: var(--text3); font-size: 13px; margin-top: 4px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* ─── DASHBOARD ─────────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { text-align: center; }
.stat-value { font-size: 34px; font-weight: 800; letter-spacing: -.03em; }
.stat-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; margin-top: 4px; }

.dash-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; }
.section-title { font-weight: 700; margin-bottom: 16px; font-size: 15px; }

.article-row { display: flex; justify-content: space-between; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--border); }
.article-row:last-child { border-bottom: none; }
.article-row-title { font-weight: 600; font-size: 13px; margin-bottom: 3px; }
.article-row-meta { font-size: 11px; color: var(--text3); }

.quick-btn {
  display: flex; align-items: center; gap: 10; width: 100%;
  margin-bottom: 8px; padding: 11px 14px; text-align: left;
}
.quick-icon { color: var(--accent); }

/* ─── ARTICLES LIST ─────────────────────────────────────────────────────────── */
.filter-bar { display: flex; gap: 10; align-items: center; flex-wrap: wrap; }
.search-input { max-width: 260px; }

.article-card { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.article-card-info { flex: 1; min-width: 0; }
.article-card-title { font-weight: 700; font-size: 15px; margin-bottom: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.article-card-meta { font-size: 12px; color: var(--text3); margin-bottom: 6px; }
.article-card-actions { display: flex; gap: 8px; flex-shrink: 0; }

.empty-state { text-align: center; color: var(--text3); padding: 60px 20px; font-size: 15px; }

/* ─── EDITOR ─────────────────────────────────────────────────────────────────── */
.editor-layout { display: grid; grid-template-columns: 1fr 280px; gap: 16px; }

.rich-editor-wrap { border: 1px solid var(--border2); border-radius: var(--radius-sm); overflow: hidden; }
.rich-toolbar {
  display: flex; flex-wrap: wrap; gap: 2px; padding: 8px 10px;
  background: var(--bg4); border-bottom: 1px solid var(--border2);
}
.tool-btn {
  background: transparent; border: 1px solid var(--border2); color: #c8c8e8;
  border-radius: 4px; padding: 3px 8px; cursor: pointer; font-size: 12px;
  min-width: 28px; font-family: inherit; transition: background .1s;
}
.tool-btn:hover { background: #1e1e30; }
.rich-content {
  min-height: 220px; padding: 16px 18px; background: var(--bg);
  color: var(--text); outline: none; line-height: 1.7; font-size: 14px;
}
.rich-content h2 { font-size: 20px; margin: 12px 0 8px; }
.rich-content h3 { font-size: 16px; margin: 10px 0 6px; }
.rich-content p { margin-bottom: 10px; }
.rich-content ul, .rich-content ol { padding-left: 20px; margin-bottom: 10px; }

.tag-list { display: flex; flex-wrap: wrap; gap: 0; margin-top: 6px; }
.tag-item { cursor: pointer; }
.tag-add-row { display: flex; gap: 6px; }

.media-thumb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.media-thumb {
  border-radius: 6px; overflow: hidden; cursor: pointer;
  border: 2px solid transparent; transition: border .15s;
}
.media-thumb.selected { border-color: var(--accent); }
.media-thumb img { width: 100%; height: 60px; object-fit: cover; display: block; }

/* ─── MEDIA ─────────────────────────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--border2); border-radius: var(--radius); padding: 32px;
  text-align: center; cursor: pointer; transition: all .2s; margin-bottom: 20px;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: rgba(255,107,53,.04); }
.dropzone-icon { font-size: 28px; opacity: .3; margin-bottom: 8px; }
.dropzone-text { color: var(--text3); font-size: 13px; }
.dropzone-text span { color: var(--accent); font-weight: 600; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 14px; }
.media-item {
  background: var(--bg3); border: 1px solid #1e1e30; border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: border .15s;
}
.media-item.selected { border: 2px solid var(--accent); }
.media-item-img { width: 100%; height: 125px; object-fit: cover; display: block; position: relative; }
.media-item-img-wrap { position: relative; }
.media-check {
  position: absolute; top: 8px; right: 8px; width: 22px; height: 22px;
  background: var(--accent); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #fff; font-weight: 800;
}
.media-item-info { padding: 8px 12px; }
.media-item-name { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 2px; }
.media-item-meta { font-size: 11px; color: var(--text3); }

/* ─── USERS ─────────────────────────────────────────────────────────────────── */
.user-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.user-row:last-child { border-bottom: none; }
.user-row-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
}
.user-row-info { flex: 1; }
.user-row-name { font-weight: 700; margin-bottom: 2px; }
.user-row-email { font-size: 12px; color: var(--text3); }

/* ─── API VIEW ─────────────────────────────────────────────────────────────── */
.api-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.info-list { list-style: none; }
.info-list li { font-size: 13px; color: var(--text3); padding: 4px 0; line-height: 1.6; }
.info-list li strong { color: var(--accent); }

.schema-block { background: var(--bg4); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 10px; }
.schema-title { color: var(--accent); font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.schema-field { font-size: 12px; color: var(--text3); margin-bottom: 3px; }
.schema-field span { color: #c8c8e8; font-family: 'Fira Code', monospace; }

.code-block {
  background: #040409; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px; color: #c8c8e8; font-size: 12px; overflow-x: auto;
  font-family: 'Fira Code', monospace; line-height: 1.6; margin: 0;
  max-height: 380px; overflow-y: auto;
}
.code-block.json { color: var(--green); font-size: 11px; }

.tip-box {
  padding: 12px 14px; background: rgba(0,212,170,.07);
  border: 1px solid rgba(0,212,170,.2); border-radius: var(--radius-sm);
  color: var(--green); font-size: 12px; line-height: 1.6; margin-top: 14px;
}

.code-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.code-title { font-weight: 700; font-size: 14px; }

/* ─── NOTIFICATION ─────────────────────────────────────────────────────────── */
.notification {
  position: fixed; bottom: 24px; right: 24px;
  padding: 11px 20px; border-radius: 9px; font-weight: 600; font-size: 13px;
  z-index: 9999; color: #fff; box-shadow: 0 8px 28px rgba(0,0,0,.4);
  animation: slideUp .3s ease;
}
.notification.success { background: rgba(0,212,170,.95); }
.notification.error { background: rgba(255,96,96,.95); }
.notification.info { background: rgba(124,106,247,.95); }

@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .editor-layout { grid-template-columns: 1fr; }
  .api-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .main { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .page-header { flex-direction: column; gap: 12px; }
}
