/* =====================================================
   ADMIN — Stylesheet (fixed blue theme, all 3 sites)
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700;800&display=swap');

:root {
  --primary:       #0a84d0;
  --primary-dark:  #0066aa;
  --primary-light: #38a8e8;
  --danger:        #e74c3c;
  --success:       #27ae60;
  --warning:       #f39c12;
  --bg:            #f0f2f5;
  --bg2:           #e4e8ee;
  --card:          #ffffff;
  --card-hover:    #fafbff;
  --text:          #1a1a1a;
  --text2:         #444;
  --text-muted:    #777;
  --border:        #dde1e7;
  --border-light:  #eef0f4;
  --shadow:        0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.13);
  --radius:        6px;
  --sidebar-bg:    #1a2336;
  --input-bg:      #ffffff;
  --tag-bg:        #e8f4fd;
  --tag-text:      #0a84d0;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html  { scroll-behavior: smooth; }
body  { font-family: 'Sarabun', sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6; }
a     { color: inherit; text-decoration: none; }
a:hover { color: var(--primary); }
img   { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
::-webkit-scrollbar       { width: 6px; }
::-webkit-scrollbar-track  { background: var(--bg); }
::-webkit-scrollbar-thumb  { background: #9ab; border-radius: 3px; }

/* =====================
   LAYOUT
   ===================== */
.admin-layout { display: flex; min-height: 100vh; }

/* =====================
   SIDEBAR
   ===================== */
.admin-sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.admin-logo-link { text-decoration: none; }
.admin-logo {
  padding: 18px 16px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.admin-logo-name { font-size: 15px; font-weight: 800; color: #fff; }
.admin-logo-sub  { font-size: 11px; color: rgba(255,255,255,0.45); font-weight: 400; }

.admin-menu { list-style: none; padding: 12px 0; flex: 1; }
.admin-menu li a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 20px; color: rgba(255,255,255,0.68);
  font-size: 14px; font-weight: 600; transition: all 0.2s;
}
.admin-menu li a:hover, .admin-menu li a.active {
  background: rgba(255,255,255,0.1); color: #fff; padding-left: 24px;
}
.admin-menu li a.active { border-left: 3px solid var(--primary); }
.admin-menu .mi { font-size: 18px; width: 24px; text-align: center; }

.sidebar-footer {
  padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: rgba(255,255,255,0.5);
}
.sidebar-footer a { color: rgba(255,255,255,0.5); }
.sidebar-footer a:hover { color: #fff; }

/* =====================
   MAIN AREA
   ===================== */
.admin-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.admin-topbar {
  background: var(--card); padding: 14px 28px;
  display: flex; justify-content: space-between; align-items: center;
  box-shadow: var(--shadow); position: sticky; top: 0; z-index: 100;
  border-bottom: 1px solid var(--border);
}
.admin-topbar h2 { font-size: 18px; font-weight: 800; color: var(--text); }
.admin-content   { padding: 24px 28px; flex: 1; }

/* =====================
   STATS
   ===================== */
.stat-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--card); border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 16px;
}
.stat-icon {
  width: 50px; height: 50px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0;
}
.stat-info h3 { font-size: 24px; font-weight: 800; color: var(--text); line-height: 1.2; }
.stat-info p  { font-size: 13px; color: var(--text-muted); }

/* =====================
   TABLE
   ===================== */
.admin-table-wrap { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.table-header h3 { font-size: 15px; font-weight: 700; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead { background: var(--bg); }
th { padding: 11px 14px; text-align: left; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); }
td { padding: 11px 14px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* =====================
   BUTTONS
   ===================== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); font-size: 14px; font-weight: 600; font-family: inherit; border: none; cursor: pointer; transition: all 0.2s; text-decoration: none; white-space: nowrap; }
.btn-primary   { background: var(--primary);   color: #fff; }
.btn-primary:hover   { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: var(--bg2);       color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger    { background: var(--danger);    color: #fff; }
.btn-danger:hover    { background: #c0392b; }
.btn-success   { background: var(--success);   color: #fff; }
.btn-success:hover   { background: #219a52; }
.btn-sm  { padding: 5px 10px; font-size: 12px; }
.btn-icon{ padding: 6px; border-radius: 6px; }

/* =====================
   STATUS BADGES
   ===================== */
.status-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.status-badge.published { background: #d5f5e3; color: #1e8449; }
.status-badge.draft     { background: #fdebd0; color: #ca6f1e; }
.status-badge.scheduled { background: #d6eaf8; color: #1a5276; }

/* =====================
   FORMS
   ===================== */
.form-group  { margin-bottom: 18px; }
.form-label  { display: block; font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.required    { color: var(--danger); margin-left: 3px; }
.form-control {
  width: 100%; padding: 9px 13px; border: 1.5px solid var(--border);
  border-radius: var(--radius); background: var(--input-bg); color: var(--text);
  font-family: inherit; font-size: 14px; outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(10,132,208,0.1); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-card       { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.form-card-title { font-size: 15px; font-weight: 800; color: var(--text); margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.form-layout     { display: grid; grid-template-columns: 1fr 340px; gap: 20px; }
.form-row        { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* =====================
   UPLOAD
   ===================== */
.image-upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 28px; text-align: center; cursor: pointer;
  transition: all 0.2s; background: var(--bg); position: relative; display: block;
}
.image-upload-zone:hover { border-color: var(--primary); background: var(--bg2); }
.upload-icon { font-size: 36px; margin-bottom: 8px; }
.upload-text { font-size: 14px; color: var(--text-muted); }
.upload-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.image-upload-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.image-preview { position: relative; border-radius: var(--radius); overflow: hidden; }
.image-preview img { width: 100%; max-height: 240px; object-fit: cover; }
.image-preview-remove { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,0.7); color: #fff; border: none; border-radius: 50%; width: 28px; height: 28px; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; }

/* =====================
   EDITOR
   ===================== */
.editor-wrap         { border: 1.5px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: border-color 0.2s; }
.editor-wrap:focus-within { border-color: var(--primary); }
.editor-toolbar      { background: var(--bg2); border-bottom: 1px solid var(--border); padding: 6px 10px; display: flex; flex-wrap: wrap; gap: 3px; }
.tb-btn              { width: 32px; height: 32px; border: 1px solid var(--border); background: var(--card); color: var(--text); border-radius: 4px; font-size: 13px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.15s; font-family: inherit; }
.tb-btn:hover        { background: var(--primary); color: #fff; border-color: var(--primary); }
.tb-btn.active       { background: var(--primary); color: #fff; border-color: var(--primary); }
.tb-sep              { width: 1px; background: var(--border); margin: 3px 4px; align-self: stretch; }
.insert-img-btn      { position: relative; }
.insert-img-btn input{ position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.editor-content      { min-height: 280px; padding: 16px; outline: none; font-size: 15px; line-height: 1.8; color: var(--text); background: var(--input-bg); }
.editor-content:empty::before { content: attr(data-placeholder); color: var(--text-muted); }
.editor-content h2   { font-size: 20px; font-weight: 800; margin: 16px 0 8px; }
.editor-content h3   { font-size: 17px; font-weight: 700; margin: 12px 0 6px; }
.editor-content blockquote { border-left: 4px solid var(--primary); padding: 10px 16px; background: var(--bg); margin: 12px 0; border-radius: 0 4px 4px 0; font-style: italic; }
.editor-content img  { max-width: 100%; border-radius: 6px; margin: 8px 0; }
.editor-footer       { padding: 6px 16px; background: var(--bg2); border-top: 1px solid var(--border); display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); }

/* =====================
   TOGGLE
   ===================== */
.toggle-wrap  { display: flex; align-items: center; gap: 10px; }
.toggle       { position: relative; width: 44px; height: 24px; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--border); border-radius: 24px; transition: background 0.2s; }
.toggle-slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* =====================
   CATEGORIES
   ===================== */
.cat-list-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border-light); transition: background 0.2s; }
.cat-list-item:last-child { border-bottom: none; }
.cat-list-item:hover { background: var(--bg); }
.cat-list-item.inactive { opacity: 0.55; }
.cat-color-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.cat-info { flex: 1; }
.cat-info .cat-name { font-weight: 700; font-size: 14px; }
.cat-info .cat-slug { font-size: 12px; color: var(--text-muted); font-family: monospace; }
.cat-icon-preview { font-size: 20px; flex-shrink: 0; }
.icon-grid { display: flex; flex-wrap: wrap; gap: 5px; max-height: 110px; overflow-y: auto; padding: 4px; }
.icon-opt  { width: 36px; height: 36px; border: 2px solid var(--border); border-radius: 6px; font-size: 18px; cursor: pointer; background: var(--card); display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.icon-opt:hover { border-color: var(--primary); background: var(--bg2); transform: scale(1.1); }
.color-input-wrap { display: flex; align-items: center; gap: 10px; }
.color-picker { width: 44px; height: 36px; border: 1.5px solid var(--border); border-radius: var(--radius); cursor: pointer; padding: 2px; background: none; }

/* =====================
   FILTER BAR
   ===================== */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }

/* =====================
   BULK BAR
   ===================== */
.bulk-bar { display: none; align-items: center; gap: 10px; padding: 10px 16px; background: var(--bg2); border-bottom: 1px solid var(--border); }
.bulk-bar.show { display: flex; }

/* =====================
   PAGINATION
   ===================== */
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 20px; flex-wrap: wrap; }
.page-btn   { min-width: 36px; height: 36px; border: 1.5px solid var(--border); background: var(--card); color: var(--text); border-radius: var(--radius); font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; font-family: inherit; padding: 0 8px; text-decoration: none; }
.page-btn:hover, .page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn.wide { padding: 0 14px; }

/* =====================
   TOAST
   ===================== */
.toast { position: fixed; bottom: 24px; right: 24px; padding: 12px 20px; border-radius: var(--radius); background: var(--success); color: #fff; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); transform: translateY(100px); opacity: 0; transition: all 0.3s; z-index: 9999; display: flex; align-items: center; gap: 8px; }
.toast.show  { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--danger); }

/* =====================
   LOGIN PAGE
   ===================== */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #0a3d62 0%, #0a84d0 100%); }
.login-wrap { width: 100%; max-width: 420px; padding: 24px; }
.login-logo { text-align: center; margin-bottom: 32px; color: #fff; }
.login-logo h1 { font-size: 28px; font-weight: 800; margin: 12px 0 6px; }
.login-logo p  { font-size: 14px; opacity: 0.75; }
.login-card  { background: #fff; border-radius: 12px; padding: 32px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.login-error { background: #fde8e8; border-left: 4px solid var(--danger); padding: 10px 14px; border-radius: 4px; margin-bottom: 20px; font-size: 14px; }

/* =====================
   MISC UTILS
   ===================== */
.hidden  { display: none !important; }
.text-muted { color: var(--text-muted); }

/* =====================
   RESPONSIVE
   ===================== */
@media (max-width: 1200px) {
  .stat-grid   { grid-template-columns: repeat(2,1fr); }
  .form-layout { grid-template-columns: 1fr 300px; }
}
@media (max-width: 900px) {
  .admin-sidebar { display: none; }
  .form-layout   { grid-template-columns: 1fr; }
  .form-row      { grid-template-columns: 1fr; }
  .stat-grid     { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .stat-grid     { grid-template-columns: 1fr; }
  .admin-content { padding: 16px; }
}
