/* ============================================================
   CMS Admin Panel — style.css
   Dark theme, clean & functional
   ============================================================ */

:root {
  --bg:        #0f0f13;
  --surface:   #17171f;
  --surface2:  #1e1e28;
  --surface3:  #252532;
  --border:    #2a2a38;
  --border2:   #353548;
  --accent:    #6366f1;
  --accent-h:  #4f52d6;
  --success:   #10b981;
  --danger:    #ef4444;
  --text:      #e2e8f0;
  --text-2:    #94a3b8;
  --text-3:    #64748b;
  --white:     #ffffff;
}

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

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
input, select, textarea, button { font-family: inherit; font-size: 13px; }

/* ---- SCREEN ---- */
.screen { min-height: 100vh; }

/* ---- LOGIN ---- */
.login-box {
  max-width: 380px; margin: 0 auto;
  padding: 48px 40px;
  min-height: 100vh;
  display: flex; flex-direction: column; justify-content: center;
  gap: 24px;
}
.login-logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 18px; font-weight: 600;
}
.login-box h1 { font-size: 24px; font-weight: 600; color: var(--white); }
.login-box form { display: flex; flex-direction: column; gap: 16px; }
.error-msg { color: var(--danger); font-size: 12px; padding: 8px 12px; background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.2); border-radius: 4px; }

/* ---- APP LAYOUT ---- */
#screen-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 16px; }
.app-logo { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--white); }
.header-right { display: flex; align-items: center; gap: 10px; }
.header-user { font-size: 12px; color: var(--text-3); }

.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.breadcrumb span { color: var(--text-2); cursor: pointer; }
.breadcrumb span:hover { color: var(--white); }
.breadcrumb .sep { color: var(--text-3); }

.app-body {
  display: flex; flex: 1; overflow: hidden;
}
.sidebar {
  width: 200px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 12px 0;
  overflow-y: auto;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 6px;
  font-size: 13px; color: var(--text-2);
  cursor: pointer; transition: all 0.1s;
}
.sidebar-nav a:hover { background: var(--surface2); color: var(--text); }
.sidebar-nav a.active { background: rgba(99,102,241,0.15); color: var(--accent); }
.sidebar-divider { height: 1px; background: var(--border); margin: 8px 0; }
.sidebar-section-label { padding: 8px 20px 4px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); }
.sidebar-site-name { padding: 6px 20px 10px; font-size: 12px; font-weight: 600; color: var(--white); border-bottom: 1px solid var(--border); margin-bottom: 6px; }

.app-content {
  flex: 1; overflow-y: auto;
  background: var(--bg);
}

/* ---- VIEW ---- */
.view { padding: 28px 32px; display: none; }
.view.active { display: block; }

.view-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.view-header h2 { font-size: 18px; font-weight: 600; color: var(--white); }

/* ---- CARDS (sites list) ---- */
.cards-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.site-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 20px;
  cursor: pointer; transition: all 0.15s;
}
.site-card:hover { border-color: var(--accent); background: var(--surface2); }
.site-card-name { font-size: 15px; font-weight: 600; color: var(--white); margin-bottom: 4px; }
.site-card-domain { font-size: 12px; color: var(--text-3); }
.site-card-meta { font-size: 11px; color: var(--text-3); margin-top: 12px; }
.site-card-actions { display: flex; gap: 6px; margin-top: 14px; }

/* ---- PAGES TABLE ---- */
.pages-table { display: flex; flex-direction: column; gap: 2px; }
.page-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer;
  transition: all 0.12s;
}
.page-row:hover { border-color: var(--border2); background: var(--surface2); }
.page-row-icon { width: 28px; height: 28px; border-radius: 4px; display: flex; align-items: center; justify-content: center; background: var(--surface3); color: var(--text-2); }
.page-row-info { flex: 1; }
.page-row-title { font-size: 13px; font-weight: 500; color: var(--white); }
.page-row-slug { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.page-row-badge { font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 10px; }
.badge-home { background: rgba(99,102,241,0.2); color: var(--accent); }
.badge-hidden { background: rgba(100,116,139,0.2); color: var(--text-3); }
.page-row-actions { display: flex; gap: 6px; opacity: 0; transition: opacity 0.1s; }
.page-row:hover .page-row-actions { opacity: 1; }

/* ---- EDITOR ---- */
.view.editor-layout {
  padding: 0; display: none;
  flex-direction: column;
  height: 100%;
}
.view.editor-layout.active { display: flex; }
.editor-toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  height: 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.editor-title { font-size: 13px; font-weight: 600; color: var(--white); flex: 1; }
.editor-toolbar-right { display: flex; gap: 8px; margin-left: auto; }

.editor-cols {
  display: flex; flex: 1; overflow: hidden;
}

/* Block library (left) */
.editor-library {
  width: 180px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px 8px;
}
.library-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-3); padding: 4px 8px 10px; }
.library-block {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border-radius: 6px;
  cursor: pointer; transition: all 0.1s;
  margin-bottom: 2px;
}
.library-block:hover { background: var(--surface2); }
.library-block-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.library-block-name { font-size: 12px; color: var(--text-2); font-weight: 500; }

/* Canvas (center) */
.editor-canvas {
  flex: 1; overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column;
  gap: 8px;
  background: var(--bg);
}
.canvas-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-3); padding: 4px 4px 8px; }
.canvas-empty { text-align: center; padding: 60px 20px; color: var(--text-3); line-height: 1.7; font-size: 13px; }

.block-list { display: flex; flex-direction: column; gap: 4px; }
.block-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer;
  transition: all 0.1s;
  user-select: none;
}
.block-item:hover { border-color: var(--border2); }
.block-item.selected { border-color: var(--accent); background: rgba(99,102,241,0.06); }
.block-drag { cursor: grab; color: var(--text-3); padding: 0 4px; }
.block-drag:active { cursor: grabbing; }
.block-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.block-name { font-size: 12px; color: var(--text); font-weight: 500; flex: 1; }
.block-type-label { font-size: 10px; color: var(--text-3); }
.sortable-ghost { opacity: 0.4; background: var(--surface3); }

/* Fields panel (right) */
.editor-fields {
  width: 300px; flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
}
.fields-empty { padding: 60px 20px; text-align: center; color: var(--text-3); font-size: 13px; line-height: 1.7; }
.fields-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--white);
}
#fields-body { padding: 12px 16px; display: flex; flex-direction: column; gap: 12px; }

/* ---- SETTINGS ---- */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.settings-col { display: flex; flex-direction: column; gap: 16px; }
.settings-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 20px;
}
.settings-section h3 { font-size: 13px; font-weight: 600; color: var(--white); margin-bottom: 16px; }
.settings-note { font-size: 12px; color: var(--text-3); margin-bottom: 14px; line-height: 1.6; }
.publish-box { }
.publish-box p { font-size: 12px; color: var(--text-3); margin-bottom: 16px; line-height: 1.6; }
.btn-publish {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 20px; background: var(--success); color: white;
  border: none; border-radius: 6px; font-weight: 600; cursor: pointer;
  transition: background 0.15s; font-size: 13px;
}
.btn-publish:hover { background: #0ea271; }
.btn-publish:disabled { opacity: 0.6; cursor: not-allowed; }
.publish-status {
  margin-top: 12px; font-size: 12px; line-height: 1.6;
  padding: 0;
}
.publish-status.ok { color: var(--success); }
.publish-status.err { color: var(--danger); }

/* ---- MEDIA ---- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.media-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; overflow: hidden; cursor: pointer;
  transition: border-color 0.1s;
}
.media-item:hover { border-color: var(--border2); }
.media-thumb { aspect-ratio: 1; overflow: hidden; background: var(--surface2); }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-name { padding: 8px; font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-copy { padding: 0 8px 8px; }
.media-copy button { font-size: 11px; padding: 3px 8px; }

/* ---- FORM FIELDS ---- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); }
.field input, .field select, .field textarea {
  padding: 8px 11px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: 5px;
  transition: border-color 0.15s;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent);
}
.field textarea { resize: vertical; min-height: 70px; }
.field input[type=checkbox] { width: auto; }

/* Fields in editor panel */
#fields-body .field label { color: var(--text-3); }
#fields-body .field input,
#fields-body .field select,
#fields-body .field textarea {
  background: var(--surface2); font-size: 12px;
}

/* ---- BUTTONS ---- */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; background: var(--accent); color: white;
  border: none; border-radius: 6px; font-weight: 500;
  cursor: pointer; transition: background 0.15s; white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-h); }

.btn-ghost-sm {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-2); border-radius: 5px;
  cursor: pointer; transition: all 0.1s; white-space: nowrap;
}
.btn-ghost-sm:hover { border-color: var(--border2); color: var(--text); }

.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-3); border-radius: 5px;
  cursor: pointer; transition: all 0.1s;
}
.btn-icon:hover { background: var(--surface2); color: var(--text); border-color: var(--border2); }
.btn-icon.danger:hover { background: rgba(239,68,68,0.1); color: var(--danger); border-color: rgba(239,68,68,0.3); }

.btn-danger-sm {
  display: inline-flex; align-items: center;
  padding: 5px 10px;
  background: transparent; border: 1px solid rgba(239,68,68,0.3);
  color: var(--danger); border-radius: 5px; font-size: 11px;
  cursor: pointer; transition: all 0.1s;
}
.btn-danger-sm:hover { background: rgba(239,68,68,0.1); }

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; width: 480px; max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 600; color: var(--white); }
.modal-close {
  background: none; border: none; color: var(--text-3);
  font-size: 20px; cursor: pointer; padding: 0 4px; line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ---- TOAST ---- */
.toast {
  position: fixed; bottom: 20px; right: 20px;
  padding: 12px 20px; border-radius: 6px;
  font-size: 13px; font-weight: 500;
  animation: slideIn 0.2s ease;
  z-index: 2000;
}
.toast.ok { background: var(--success); color: white; }
.toast.err { background: var(--danger); color: white; }
@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ---- MISC ---- */
.tag-home { background: rgba(99,102,241,0.15); color: var(--accent); padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
