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

:root {
  --primary: #0bb5f4;
  --primary-dark: #0990c5;
  --bg: #f4f6f9;
  --sidebar-bg: #1a1a2e;
  --card-bg: #ffffff;
  --text: #333333;
  --text-light: #666666;
  --border: #e0e0e0;
  --danger: #e74c3c;
  --success: #2ecc71;
  --radius: 8px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ===== LOGIN SCREEN ===== */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.login-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

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

.login-card .logo span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: var(--primary);
  border-radius: 50%;
  font-size: 28px;
  color: #fff;
  margin-bottom: 12px;
}

.login-card h1 {
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
}

.login-card .subtitle {
  text-align: center;
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.2s;
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
}

.form-group textarea {
  min-height: 90px;
}

/* ===== RICH TEXT EDITOR ===== */
.rich-editor-wrapper {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  transition: border-color 0.2s;
}

.rich-editor-wrapper:focus-within {
  border-color: var(--primary);
}

.rich-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  background: #f8f9fa;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.rich-toolbar button {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.85rem;
  width: 30px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}

.rich-toolbar button:hover {
  background: #e9ecef;
  border-color: var(--border);
}

.rich-toolbar button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-dark);
}

.rich-toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.rich-editor {
  width: 100%;
  min-height: 90px;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  outline: none;
  line-height: 1.5;
}

.rich-editor ul,
.rich-editor ol {
  padding-left: 24px;
}

.login-error {
  color: var(--danger);
  font-size: 0.85rem;
  text-align: center;
  margin-bottom: 16px;
  min-height: 20px;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
  justify-content: center;
  padding: 14px;
  font-size: 1rem;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: #eef7fd;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-secondary:hover {
  background: var(--primary);
  color: #fff;
}

.btn-danger {
  background: #fdf0ef;
  color: var(--danger);
  border: 2px solid var(--danger);
}

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

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover {
  background: #27ae60;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--danger);
  font-size: 1.1rem;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.btn-icon:hover {
  background: #fdf0ef;
}

/* ===== ADMIN LAYOUT ===== */
#admin-screen {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-header {
  padding: 28px 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 2px;
}

.sidebar-header p {
  font-size: 0.78rem;
  opacity: 0.5;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.2s, color 0.2s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(11, 181, 244, 0.15);
  color: var(--primary);
}

.sidebar-nav a i {
  width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-footer .btn {
  font-size: 0.85rem;
  padding: 9px 14px;
}

/* ===== MAIN CONTENT ===== */
.admin-main {
  margin-left: 260px;
  flex: 1;
  padding: 32px;
  min-height: 100vh;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.admin-topbar h1 {
  font-size: 1.6rem;
  font-weight: 700;
}

.admin-topbar .save-btn {
  display: flex;
  gap: 10px;
}

/* ===== SECTION PANELS ===== */
.panel {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
}

.panel-header h2 {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.panel-header h2 i {
  color: var(--primary);
}

.panel-body {
  padding: 24px;
}

/* ===== FORM GRID ===== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-grid .full-width {
  grid-column: 1 / -1;
}

/* ===== DYNAMIC LIST ITEMS ===== */
.list-item {
  background: #f9f9f9;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  position: relative;
}

.list-item .item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.list-item .item-header span {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-light);
}

.list-item .item-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.list-item .item-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.list-item .item-grid .full-width {
  grid-column: 1 / -1;
}

.add-btn {
  margin-top: 8px;
}

/* ===== STAR RATING ===== */
.star-rating {
  display: flex;
  gap: 6px;
  align-items: center;
}

.star-rating i {
  cursor: pointer;
  font-size: 1.3rem;
  color: #ddd;
  transition: color 0.15s;
}

.star-rating i.active {
  color: #f0c040;
}

/* ===== TOAST ===== */
#toast {
  position: fixed;
  bottom: 32px;
  right: 32px;
  background: #333;
  color: #fff;
  padding: 14px 24px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

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

#toast.success { background: var(--success); }
#toast.error   { background: var(--danger); }
#toast.info    { background: var(--primary); }

/* ===== RANGE INPUT ===== */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: #e0e0e0;
  outline: none;
  padding: 0;
  border: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
}

.range-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.range-wrapper input[type="range"] {
  flex: 1;
}

.range-value {
  min-width: 38px;
  text-align: right;
  font-weight: 600;
  color: var(--primary);
}

/* ===== AVATAR UPLOAD ===== */
.avatar-upload {
  display: flex;
  align-items: center;
  gap: 20px;
}

.avatar-preview-wrap {
  position: relative;
  width: 96px;
  height: 96px;
  flex-shrink: 0;
}

.avatar-upload img {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
}

.avatar-placeholder {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px dashed var(--border);
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #bbb;
  font-size: 2rem;
}

.avatar-upload-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.avatar-upload-controls input[type="file"] {
  display: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .admin-sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }

  .admin-main {
    margin-left: 0;
    padding: 16px;
  }

  #admin-screen {
    flex-direction: column;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .list-item .item-grid {
    grid-template-columns: 1fr;
  }

  .sidebar-nav {
    display: flex;
    flex-wrap: wrap;
    padding: 8px;
  }

  .sidebar-nav a {
    padding: 8px 12px;
    font-size: 0.8rem;
  }
}

/* ── GitHub Token Modal ─────────────────────────────────────────────────── */
#token-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.token-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.token-card .logo {
  text-align: center;
  margin-bottom: 24px;
}

.token-card .logo span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: var(--primary);
  border-radius: 50%;
  font-size: 24px;
  color: #fff;
  margin-bottom: 10px;
}

.token-card h2 {
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
}

/* ===== THEME SELECTOR ===== */
.theme-selector {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.theme-card {
  cursor: pointer;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  width: 220px;
  background: var(--card-bg);
  transition: border-color 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.theme-card input[type="radio"] {
  display: none;
}

.theme-card:has(input:checked) {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11, 181, 244, 0.2);
}

.theme-card:hover {
  border-color: #aaa;
}

.theme-preview {
  height: 90px;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  border: 1px solid #ddd;
}

.theme-preview .tp-left {
  width: 38%;
}

.theme-preview .tp-right {
  flex: 1;
}

/* Style 1 preview colors */
.theme-preview-style1 .tp-left  { background: #0bb5f4; }
.theme-preview-style1 .tp-right { background: #ffffff; }

/* Style 2 preview colors */
.theme-preview-style2 .tp-left  { background: #7b1a2e; }
.theme-preview-style2 .tp-right { background: #fdf6f0; }

.theme-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.theme-label strong {
  font-size: 0.9rem;
  color: var(--text);
}

.theme-label span {
  font-size: 0.78rem;
  color: var(--text-light);
}


