/* ============================================================
   Admin Panel CSS — Buddies Employee Manual
   ============================================================ */

:root {
  --sidebar-bg:    #1e2a3a;
  --sidebar-hover: #263548;
  --sidebar-text:  #cbd5e1;
  --sidebar-muted: #64748b;
  --accent:        #3b82f6;
  --accent-hover:  #2563eb;
  --accent-light:  rgba(59,130,246,.12);
  --danger:        #ef4444;
  --danger-hover:  #dc2626;
  --success:       #22c55e;
  --warning:       #f59e0b;

  --bg:            #f1f5f9;
  --surface:       #ffffff;
  --border:        #e2e8f0;
  --text:          #1e293b;
  --text-muted:    #64748b;
  --heading:       #0f172a;

  --header-h:      52px;
  --sidebar-w:     280px;
  --radius:        8px;
  --radius-lg:     12px;
  --transition:    0.18s ease;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.08);
  --shadow-md:     0 4px 12px rgba(0,0,0,.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-size: 15px; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ══════════════════════════════
   LOGIN SCREEN
══════════════════════════════ */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--sidebar-bg);
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 380px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo span { font-size: 36px; display: block; margin-bottom: 8px; }
.login-logo h1 { font-size: 20px; font-weight: 700; color: var(--heading); margin-bottom: 4px; }
.login-logo p { font-size: 13px; color: var(--text-muted); }

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 18px;
}

/* ══════════════════════════════
   ADMIN APP LAYOUT
══════════════════════════════ */
.admin-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header */
.admin-header {
  height: var(--header-h);
  background: var(--sidebar-bg);
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
}

.admin-logo {
  font-size: 14px;
  font-weight: 600;
  color: #f1f5f9;
}

.admin-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Layout */
.admin-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ══════════════════════════════
   SECTION TREE (left sidebar)
══════════════════════════════ */
.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid rgba(255,255,255,.05);
}

.sidebar-actions {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reorder-controls {
  display: flex;
  gap: 8px;
}

.section-tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}

.tree-section {
  margin-bottom: 2px;
}

.tree-section-header,
.tree-sub-item {
  position: relative;
}

.tree-section.dragging {
  opacity: 0.55;
}

.tree-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--sidebar-text);
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 0;
  transition: background var(--transition);
  user-select: none;
}

.tree-section-header.reorder-enabled {
  cursor: grab;
}

.tree-section-header.reorder-enabled:active {
  cursor: grabbing;
}

.tree-section-header:hover { background: var(--sidebar-hover); }

.tree-section-toggle {
  width: 14px;
  height: 14px;
  color: var(--sidebar-muted);
  transition: transform var(--transition);
  flex-shrink: 0;
}

.tree-section.open .tree-section-toggle { transform: rotate(90deg); }

.tree-section-icon { font-size: 13px; }
.tree-section-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tree-section-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
  flex-shrink: 0;
}

.tree-section-header:hover .tree-section-actions { opacity: 1; }

.tree-action-btn {
  background: none;
  border: none;
  color: var(--sidebar-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 12px;
  transition: color var(--transition), background var(--transition);
}

.tree-action-btn:hover { color: #fff; background: rgba(255,255,255,.1); }
.tree-action-btn.danger:hover { color: var(--danger); }

.tree-subsections {
  list-style: none;
  display: none;
  padding-left: 0;
}

.tree-section.open .tree-subsections { display: block; }

.tree-sub-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 36px;
  font-size: 12.5px;
  color: var(--sidebar-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.tree-sub-item.dragging {
  opacity: 0.55;
}

.tree-sub-item.reorder-enabled {
  cursor: grab;
}

.tree-sub-item.reorder-enabled:active {
  cursor: grabbing;
}

.tree-sub-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }

.tree-sub-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 500;
}

.tree-sub-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tree-sub-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
  flex-shrink: 0;
}

.tree-sub-item:hover .tree-sub-actions { opacity: 1; }

.drag-handle {
  display: none;
  color: var(--sidebar-muted);
  font-size: 11px;
  letter-spacing: -1px;
  margin-right: 1px;
  flex-shrink: 0;
  user-select: none;
}

.section-tree.reorder-mode .drag-handle {
  display: inline-block;
}

.section-tree.reorder-mode .tree-section-actions,
.section-tree.reorder-mode .tree-sub-actions {
  display: none;
}

.section-tree.reorder-mode .tree-sub-item.active {
  background: transparent;
  color: var(--sidebar-text);
  font-weight: 400;
}

.section-tree.reorder-mode .tree-section.drop-before .tree-section-header::before,
.section-tree.reorder-mode .tree-section.drop-after .tree-section-header::after,
.section-tree.reorder-mode .tree-sub-item.drop-before::before,
.section-tree.reorder-mode .tree-sub-item.drop-after::after {
  content: '';
  position: absolute;
  left: 12px;
  right: 10px;
  height: 4px;
  background: #22d3ee;
  border-radius: 99px;
  box-shadow: 0 0 0 3px rgba(34,211,238,.25);
  pointer-events: none;
  z-index: 2;
}

.section-tree.reorder-mode .tree-section.drop-before .tree-section-header::before,
.section-tree.reorder-mode .tree-sub-item.drop-before::before {
  top: -2px;
}

.section-tree.reorder-mode .tree-section.drop-after .tree-section-header::after,
.section-tree.reorder-mode .tree-sub-item.drop-after::after {
  bottom: -2px;
}

.section-tree.reorder-mode .tree-sub-item.drop-before::before,
.section-tree.reorder-mode .tree-sub-item.drop-after::after {
  left: 36px;
}

.section-tree.reorder-mode .tree-section.drop-before .tree-section-header,
.section-tree.reorder-mode .tree-section.drop-after .tree-section-header,
.section-tree.reorder-mode .tree-sub-item.drop-before,
.section-tree.reorder-mode .tree-sub-item.drop-after {
  background: rgba(34,211,238,.14) !important;
}

/* ══════════════════════════════
   EDITOR AREA
══════════════════════════════ */
.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.editor-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}

.editor-empty-icon { font-size: 48px; margin-bottom: 8px; }
.editor-empty h2 { font-size: 18px; font-weight: 600; color: var(--text); }
.editor-empty p { font-size: 14px; }

.editor-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
}

/* Renamed to avoid conflict with EasyMDE's .editor-toolbar class */
.admin-editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.editor-breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
}

.editor-breadcrumb strong { color: var(--text); }

.editor-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.editor-form {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ══════════════════════════════
   FORM ELEMENTS
══════════════════════════════ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.label-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

input[type="text"],
input[type="password"],
input[type="email"],
textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  background: var(--surface);
}

.title-input {
  font-size: 17px;
  font-weight: 600;
  padding: 10px 14px;
}

/* Toast UI Editor overrides */
.toastui-editor-defaultUI {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 14px;
}

.toastui-editor-toolbar {
  background: #f8fafc !important;
  border-bottom: 1px solid var(--border) !important;
}

.toastui-editor-contents {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}

.toastui-editor-contents h1,
.toastui-editor-contents h2,
.toastui-editor-contents h3 {
  font-weight: 600;
  margin: 1em 0 0.4em;
}

.toastui-editor-contents img {
  max-width: 100%;
  height: auto;
}

.toastui-editor-contents table {
  border-collapse: collapse;
  width: 100%;
}

.toastui-editor-contents table td,
.toastui-editor-contents table th {
  border: 1px solid var(--border);
  padding: 6px 10px;
}

/* Emoji picker */
.emoji-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.emoji-input-row input {
  width: 80px;
  flex-shrink: 0;
  text-align: center;
  font-size: 20px;
  padding: 6px 8px;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 36px);
  gap: 4px;
  margin-top: 8px;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 180px;
  overflow-y: auto;
}

.emoji-grid button {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  line-height: 1;
  transition: background 0.12s;
}

.emoji-grid button:hover {
  background: var(--accent-light);
}

/* Settings modal error */
.settings-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
}

/* ══════════════════════════════
   BUTTONS
══════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}

.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--border);
}

.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-full { width: 100%; justify-content: center; }

.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ══════════════════════════════
   MODAL
══════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 15px; font-weight: 600; color: var(--heading); }

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  line-height: 1;
}

.modal-close:hover { background: var(--bg); }

.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: 24px;
  right: 24px;
  background: #1e293b;
  color: #f1f5f9;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 200;
  transform: translateY(80px);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  pointer-events: none;
}

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

.toast.success { background: #166534; }
.toast.error   { background: #991b1b; }

/* ══════════════════════════════
   SETTINGS MODAL TABS
══════════════════════════════ */
.settings-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.settings-tab {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.settings-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.settings-tab-panel.hidden { display: none; }

.settings-note {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0 0 14px;
  line-height: 1.5;
}

#ai-role-prompt {
  min-height: 110px;
  resize: vertical;
  line-height: 1.45;
}

.settings-error { color: #ef4444; font-size: 12.5px; min-height: 18px; margin-top: 4px; }
