/* ==========================================================================
   EVYX POS — Blog + Markdown styles
   ========================================================================== */

.container-narrow { max-width: 800px; }
.breadcrumb { display: flex; gap: 8px; align-items: center; font-size: 0.85rem; color: var(--muted); margin-bottom: 24px; flex-wrap: wrap; }
.breadcrumb a { color: var(--brand); transition: .25s; }
.breadcrumb a:hover { color: var(--orange); }
.breadcrumb span { opacity: 0.5; }

/* Blog hero */
.blog-hero { background: var(--grad-hero); padding-bottom: 40px; }
.blog-hero .section-sub { max-width: 620px; }

/* Category chips */
.blog-cats { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 30px; }
.blog-cats a {
  padding: 8px 18px; border-radius: 999px; font-size: 0.9rem; font-weight: 600;
  background: #fff; border: 1px solid var(--line); color: var(--ink-2); transition: all .3s var(--ease);
}
.blog-cats a:hover { border-color: var(--brand); color: var(--brand); transform: translateY(-2px); }
.blog-cats a.active { background: var(--grad-brand); color: #fff; border-color: transparent; }

/* Articles grid */
.blog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 28px; }
.post-card {
  background: #fff; border-radius: var(--radius-lg); overflow: hidden;
  border: 1px solid var(--line); transition: all .45s var(--ease); display: flex; flex-direction: column;
}
.post-card:hover { transform: translateY(-8px); box-shadow: var(--shadow-lg); border-color: transparent; }
.post-thumb { position: relative; display: block; aspect-ratio: 16/9; overflow: hidden; background: var(--brand-soft); }
.post-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s var(--ease); }
.post-card:hover .post-thumb img { transform: scale(1.06); }
.post-thumb-fallback { width: 100%; height: 100%; background: var(--grad-brand); display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,0.4); font-weight: 900; font-size: 2rem; letter-spacing: 2px; }
.post-cat {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  background: rgba(255,255,255,0.95); color: var(--orange); font-size: 0.74rem; font-weight: 700;
  padding: 5px 12px; border-radius: 999px; backdrop-filter: blur(8px);
}
.post-cat-inline { display: inline-block; background: var(--orange-soft); color: var(--orange); font-size: 0.82rem; font-weight: 700; padding: 6px 14px; border-radius: 999px; margin-bottom: 16px; }
.post-body { padding: 22px 24px 26px; display: flex; flex-direction: column; flex: 1; }
.post-meta { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; color: var(--muted); margin-bottom: 12px; }
.dot-sep { opacity: 0.5; }
.post-title { font-size: 1.22rem; font-weight: 800; color: var(--ink); line-height: 1.4; margin-bottom: 10px; }
.post-title a { transition: color .25s; }
.post-title a:hover { color: var(--brand); }
.post-excerpt { font-size: 0.92rem; color: var(--muted); line-height: 1.7; margin-bottom: 18px; flex: 1; }
.post-readmore { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 0.9rem; color: var(--orange); transition: gap .3s; }
.post-readmore svg { width: 16px; }
.post-readmore:hover { gap: 12px; }

/* Empty state */
.empty-state { text-align: center; padding: 80px 20px; }
.empty-icon { font-size: 3.5rem; margin-bottom: 16px; }
.empty-state h3 { font-size: 1.4rem; font-weight: 800; color: var(--ink); margin-bottom: 8px; }
.empty-state p { color: var(--muted); margin-bottom: 24px; }

/* ===== Single Article ===== */
.article-header { background: var(--grad-hero); padding-bottom: 40px; }
.article-title { font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 900; line-height: 1.3; color: var(--ink); margin: 10px 0 18px; letter-spacing: -0.5px; }
.article-lead { font-size: 1.15rem; color: var(--ink-2); line-height: 1.85; }

.article-byline { display: flex; align-items: center; gap: 14px; margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.byline-avatar, .author-avatar { width: 48px; height: 48px; border-radius: 14px; background: var(--grad-brand); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; flex-shrink: 0; }
.byline-name { font-weight: 800; color: var(--ink); font-size: 0.95rem; }
.byline-meta { font-size: 0.82rem; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.share-row { margin-inline-start: auto; display: flex; gap: 8px; }
.share-row a { width: 38px; height: 38px; border-radius: 11px; background: #fff; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; color: var(--ink-2); transition: all .3s; }
.share-row a svg { width: 18px; }
.share-row a:hover { background: var(--brand); color: #fff; border-color: var(--brand); transform: translateY(-3px); }

.article-cover { margin-top: 0; margin-bottom: 40px; border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-lg); }
.article-cover img { width: 100%; aspect-ratio: 16/8; object-fit: cover; }

/* Markdown body */
.article-content { font-size: 1.08rem; line-height: 2; color: var(--ink); }
.markdown-body { font-size: 1.08rem; line-height: 2; color: var(--ink); }
.markdown-body > *:first-child { margin-top: 0; }
.markdown-body h2 { font-size: 1.6rem; font-weight: 800; margin: 40px 0 16px; color: var(--ink); padding-inline-start: 14px; border-inline-start: 4px solid var(--orange); }
.markdown-body h3 { font-size: 1.3rem; font-weight: 800; margin: 32px 0 12px; color: var(--brand); }
.markdown-body p { margin: 0 0 20px; }
.markdown-body ul, .markdown-body ol { margin: 0 0 20px; padding-inline-start: 26px; }
.markdown-body ul { list-style: none; }
.markdown-body ul li { position: relative; margin-bottom: 10px; padding-inline-start: 6px; }
.markdown-body ul li::before { content: ''; position: absolute; right: -16px; top: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--orange); }
.markdown-body ol { list-style: decimal; }
.markdown-body ol li { margin-bottom: 10px; }
.markdown-body li::marker { color: var(--orange); font-weight: 700; }
.markdown-body a { color: var(--brand); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.markdown-body a:hover { color: var(--orange); }
.markdown-body blockquote { margin: 24px 0; padding: 18px 22px; background: var(--brand-softer); border-inline-start: 4px solid var(--brand); border-radius: 0 14px 14px 0; color: var(--ink-2); font-style: italic; }
.markdown-body blockquote p { margin: 0; }
.markdown-body img { max-width: 100%; height: auto; border-radius: 14px; margin: 24px 0; box-shadow: var(--shadow); }
.markdown-body code { background: var(--bg-2); color: var(--orange); padding: 3px 8px; border-radius: 6px; font-size: 0.9em; font-family: 'Courier New', monospace; }
.markdown-body pre { background: #1E3A6F; color: #e8eef9; padding: 20px; border-radius: 14px; overflow-x: auto; margin: 24px 0; }
.markdown-body pre code { background: none; color: inherit; padding: 0; }
.markdown-body table { width: 100%; border-collapse: collapse; margin: 24px 0; }
.markdown-body th, .markdown-body td { padding: 12px 16px; border: 1px solid var(--line); text-align: start; }
.markdown-body th { background: var(--brand-softer); font-weight: 800; color: var(--ink); }
.markdown-body hr { border: none; height: 1px; background: var(--line); margin: 36px 0; }

/* Tags */
.article-tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 40px 0; padding-top: 28px; border-top: 1px solid var(--line); }
.tag-chip { background: var(--brand-soft); color: var(--brand); font-size: 0.82rem; font-weight: 600; padding: 6px 14px; border-radius: 999px; }

/* Author box */
.author-box { display: flex; gap: 16px; align-items: center; padding: 24px; background: var(--bg); border-radius: var(--radius-lg); margin-bottom: 30px; border: 1px solid var(--line); }
.author-box .author-avatar { width: 60px; height: 60px; font-size: 1.1rem; }
.author-box h4 { font-size: 1.05rem; font-weight: 800; color: var(--ink); margin-bottom: 4px; }
.author-box p { font-size: 0.9rem; color: var(--muted); margin: 0; }

/* Article CTA */
.article-cta { background: var(--grad-brand); border-radius: var(--radius-xl); padding: 40px 30px; text-align: center; margin-bottom: 60px; }
.article-cta h3 { color: #fff; font-size: 1.5rem; font-weight: 800; margin-bottom: 8px; }
.article-cta p { color: rgba(255,255,255,0.85); margin-bottom: 22px; }

/* 404 */
.err-code { font-size: clamp(5rem, 18vw, 9rem); font-weight: 900; line-height: 1; background: linear-gradient(120deg, var(--brand), var(--orange)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 10px; }

/* Responsive blog */
@media (max-width: 768px) {
  .blog-grid { grid-template-columns: 1fr; }
  .article-content, .markdown-body { font-size: 1rem; line-height: 1.9; }
  .markdown-body h2 { font-size: 1.35rem; }
  .markdown-body h3 { font-size: 1.15rem; }
  .author-box { flex-direction: column; text-align: center; }
  .share-row { margin-inline-start: 0; width: 100%; justify-content: flex-start; }
}

/* ==========================================================================
   ADMIN PANEL STYLES
   ========================================================================== */
:root { --danger: #ef4444; --danger-soft: #fee2e2; --success: #16a34a; --success-soft: #dcfce7; }

.admin-body { background: #f1f4fa; }

/* Login */
.login-body { background: linear-gradient(160deg, #152A50, #0E1B36); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-wrap { width: 100%; max-width: 420px; }
.login-card { background: #fff; border-radius: var(--radius-xl); padding: 44px 36px; box-shadow: 0 30px 80px rgba(0,0,0,0.4); }
.login-brand { display: flex; justify-content: center; margin-bottom: 24px; }
.login-brand .logo-text { text-align: center; }
.login-card h1 { font-size: 1.5rem; font-weight: 800; color: var(--ink); text-align: center; margin-bottom: 6px; }
.login-sub { text-align: center; color: var(--muted); font-size: 0.95rem; margin-bottom: 28px; }
.login-error { background: var(--danger-soft); color: var(--danger); padding: 12px 16px; border-radius: 12px; font-size: 0.9rem; font-weight: 600; margin-bottom: 20px; text-align: center; }
.login-form .field { margin-bottom: 18px; }
.login-form label { display: block; font-size: 0.88rem; font-weight: 700; color: var(--ink-2); margin-bottom: 8px; }
.login-form input { width: 100%; padding: 13px 16px; font-size: 1rem; border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); transition: all .3s; }
.login-form input:focus { outline: none; border-color: var(--brand); background: #fff; box-shadow: 0 0 0 4px rgba(47,78,143,0.1); }
.login-back { display: block; text-align: center; margin-top: 24px; color: var(--muted); font-size: 0.88rem; transition: .25s; }
.login-back:hover { color: var(--brand); }

/* Admin topbar */
.admin-topbar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; box-shadow: 0 2px 12px rgba(30,58,111,0.05); }
.admin-topbar-inner { max-width: 1200px; margin: 0 auto; padding: 14px 22px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.admin-logo { display: flex; align-items: center; gap: 12px; }
.admin-tag { background: var(--orange-soft); color: var(--orange); font-size: 0.72rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.admin-topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }

/* Admin main */
.admin-main { padding: 36px 22px 60px; }
.admin-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 28px; gap: 16px; flex-wrap: wrap; }
.admin-head h1 { font-size: 1.7rem; font-weight: 800; color: var(--ink); }
.admin-sub { color: var(--muted); font-size: 0.95rem; margin-top: 4px; }

/* Stats */
.admin-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 22px; border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.stat-num { font-size: 2rem; font-weight: 900; color: var(--brand); line-height: 1; }
.stat-lbl { font-size: 0.88rem; color: var(--muted); margin-top: 6px; }

/* Table */
.admin-table-wrap { background: #fff; border-radius: var(--radius-lg); border: 1px solid var(--line); overflow: hidden; box-shadow: var(--shadow-sm); overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; min-width: 700px; }
.admin-table thead { background: var(--brand-softer); }
.admin-table th { text-align: start; padding: 14px 18px; font-size: 0.82rem; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.admin-table td { padding: 14px 18px; border-top: 1px solid var(--line); vertical-align: middle; }
.admin-table tr:hover td { background: var(--bg); }
.cell-post { display: flex; align-items: center; gap: 12px; }
.cell-post img, .cell-post-fallback { width: 50px; height: 50px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }
.cell-post-fallback { background: var(--grad-brand); color: rgba(255,255,255,0.5); display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 800; }
.cell-title { font-weight: 700; color: var(--ink); display: block; transition: .25s; }
.cell-title:hover { color: var(--brand); }
.cell-slug { font-size: 0.76rem; color: var(--muted); direction: ltr; display: inline-block; }
.cell-date { font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.badge { display: inline-block; background: var(--brand-soft); color: var(--brand); font-size: 0.78rem; font-weight: 600; padding: 4px 12px; border-radius: 999px; }
.status { font-size: 0.78rem; font-weight: 700; padding: 4px 12px; border-radius: 999px; }
.status.published { background: var(--success-soft); color: var(--success); }
.status.draft { background: #fef3c7; color: #d97706; }
.row-actions { display: flex; gap: 6px; }
.del-form { display: inline; }
.admin-empty { padding: 60px 20px; text-align: center; }

/* ===== Editor ===== */
.editor-main { max-width: 1200px; }
.editor-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.editor-head h1 { font-size: 1.5rem; font-weight: 800; color: var(--ink); }
.editor-actions { display: flex; align-items: center; gap: 14px; }
.publish-toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; font-size: 0.92rem; color: var(--ink-2); }
.publish-toggle input { width: 20px; height: 20px; accent-color: var(--success); cursor: pointer; }

.meta-fields, .editor-body { background: #fff; border-radius: var(--radius-lg); padding: 28px; border: 1px solid var(--line); box-shadow: var(--shadow-sm); margin-bottom: 20px; }
.field { margin-bottom: 18px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field label { display: block; font-size: 0.88rem; font-weight: 700; color: var(--ink-2); margin-bottom: 8px; }
.field .req { color: var(--orange); }
.field input[type="text"], .field input[type="url"], .field textarea {
  width: 100%; padding: 12px 16px; font-size: 0.97rem; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--ink); transition: all .3s; font-family: inherit;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--brand); background: #fff; box-shadow: 0 0 0 4px rgba(47,78,143,0.1); }
.field-hint { display: block; font-size: 0.76rem; color: var(--muted); margin-top: 6px; }

/* Cover upload */
.cover-upload { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.cover-preview { width: 240px; aspect-ratio: 16/9; border-radius: 14px; overflow: hidden; border: 2px dashed var(--line); background: var(--bg); flex-shrink: 0; }
.cover-preview img { width: 100%; height: 100%; object-fit: cover; }
.cover-placeholder { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.cover-placeholder svg { color: var(--brand-light); }
.cover-controls { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.upload-hint { font-size: 0.76rem; color: var(--muted); }

/* Editor toolbar */
.editor-toolbar { display: flex; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--bg); border-radius: 14px 14px 0 0; flex-wrap: wrap; align-items: center; }
.tb-group { display: flex; gap: 4px; align-items: center; }
.tb-group + .tb-group { margin-inline-start: auto; }
.editor-toolbar button { min-width: 38px; height: 36px; padding: 0 10px; border-radius: 8px; background: #fff; border: 1px solid var(--line); color: var(--ink-2); font-weight: 700; font-size: 0.85rem; transition: all .2s; display: inline-flex; align-items: center; gap: 5px; }
.editor-toolbar button:hover { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Panes */
.editor-panes { display: grid; grid-template-columns: 1fr 1fr; min-height: 500px; border: 1px solid var(--line); border-top: none; border-radius: 0 0 14px 14px; overflow: hidden; }
.pane { display: flex; flex-direction: column; }
.pane-write { border-inline-end: 1px solid var(--line); }
.pane-head { padding: 10px 16px; background: var(--brand-softer); font-size: 0.82rem; font-weight: 700; color: var(--ink-2); display: flex; justify-content: space-between; align-items: center; }
.pane-hint { font-weight: 400; color: var(--muted); font-size: 0.76rem; }
#bodyInput { flex: 1; width: 100%; border: none; padding: 20px; font-size: 1rem; line-height: 1.8; resize: none; outline: none; font-family: 'Tajawal', monospace; background: #fff; color: var(--ink); min-height: 440px; }
.preview-body { flex: 1; padding: 20px; overflow-y: auto; background: #fff; font-size: 0.95rem; }
.preview-body.markdown-body { font-size: 0.95rem; }
.preview-body.markdown-body h2 { font-size: 1.3rem; }
.preview-body.markdown-body h3 { font-size: 1.15rem; }

/* Admin responsive */
.btn.loading { pointer-events: none; opacity: 0.75; }
.btn.loading::after { content: ''; display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%; animation: admin-spin .7s linear infinite; margin-inline-start: 8px; }
@keyframes admin-spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .editor-panes { grid-template-columns: 1fr; }
  .pane-write { border-inline-end: none; border-bottom: 1px solid var(--line); }
  #bodyInput { min-height: 300px; }
}
@media (max-width: 640px) {
  .admin-stats { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .meta-fields, .editor-body { padding: 18px; }
  .cover-preview { width: 100%; }
  .admin-topbar-actions .btn-sm { padding: 7px 12px; font-size: 0.8rem; }
}
