/* ==================== CMS Layout ==================== */
.cms-body { display: flex; height: 100vh; overflow: hidden; }

.cms-sidebar {
  width: 260px; min-width: 260px; background: var(--bg-secondary);
  border-right: 1px solid var(--border-color); display: flex; flex-direction: column;
  height: 100vh; z-index: 100;
}

.cms-sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--border-color); min-height: 64px;
}

.cms-logo { display: flex; align-items: center; gap: var(--space-sm); text-decoration: none; }
.cms-badge {
  font-size: 0.65rem; background: var(--accent); color: white; padding: 2px 8px;
  border-radius: var(--radius-full); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
}

.cms-nav { flex: 1; padding: var(--space-md); display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }

.cms-nav-item {
  display: flex; align-items: center; gap: var(--space-sm); padding: 10px var(--space-md);
  border: none; background: none; color: var(--text-secondary); cursor: pointer;
  border-radius: var(--radius-sm); font-size: 0.88rem; font-family: var(--font-sans);
  transition: all var(--transition-fast); text-align: left; width: 100%;
}
.cms-nav-item:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.cms-nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.cms-sidebar-footer {
  padding: var(--space-md) var(--space-lg); border-top: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
}

/* ==================== Main Area ==================== */
.cms-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bg-primary); }

.cms-topbar {
  display: flex; align-items: center; gap: var(--space-md);
  padding: var(--space-md) var(--space-xl); border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary); min-height: 64px;
}
.cms-topbar .mobile-menu-btn { display: none; }

.cms-page-title { font-size: 1.2rem; font-weight: 700; }

.cms-content { flex: 1; overflow-y: auto; padding: var(--space-xl); }

/* ==================== Stats Grid ==================== */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-md); margin-bottom: var(--space-xl);
}

.stat-card {
  background: var(--bg-surface); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: var(--space-lg); text-align: center;
  transition: all var(--transition-fast);
}
.stat-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon { font-size: 2rem; margin-bottom: var(--space-sm); }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--text-primary); }
.stat-label { font-size: 0.78rem; color: var(--text-muted); margin-top: var(--space-xs); text-transform: uppercase; letter-spacing: 0.04em; }

/* ==================== CMS Forms ==================== */
.cms-form { max-width: 700px; }
.form-group { margin-bottom: var(--space-lg); }
.form-label {
  display: block; font-size: 0.85rem; font-weight: 600; color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}
.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: var(--space-xs); }

.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px var(--space-md); background: var(--bg-input);
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  color: var(--text-primary); font-family: var(--font-sans); font-size: 0.9rem;
  transition: all var(--transition-fast); outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-textarea { min-height: 100px; resize: vertical; }
.form-textarea.code { font-family: var(--font-mono); font-size: 0.85rem; min-height: 150px; }

.form-select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239898b0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

/* Toggle switch */
.toggle-wrapper { display: flex; align-items: center; gap: var(--space-sm); }
.toggle {
  width: 44px; height: 24px; background: var(--bg-tertiary); border-radius: var(--radius-full);
  position: relative; cursor: pointer; transition: background var(--transition-fast);
  border: 1px solid var(--border-color);
}
.toggle.active { background: var(--accent); border-color: var(--accent); }
.toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  background: white; border-radius: 50%; transition: transform var(--transition-fast);
}
.toggle.active::after { transform: translateX(20px); }

/* ==================== CMS Table ==================== */
.cms-table-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-md); gap: var(--space-md); flex-wrap: wrap;
}
.cms-search {
  padding: 8px var(--space-md); background: var(--bg-input); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); color: var(--text-primary); font-size: 0.88rem;
  outline: none; min-width: 220px; font-family: var(--font-sans);
}
.cms-search:focus { border-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; gap: var(--space-xs); padding: 8px var(--space-md);
  border: none; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.85rem;
  font-weight: 600; font-family: var(--font-sans); transition: all var(--transition-fast);
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.85; }
.btn-outline {
  background: none; border: 1px solid var(--border-color); color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }

.cms-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.cms-table th {
  background: var(--bg-tertiary); padding: 10px var(--space-md); text-align: left;
  font-weight: 600; color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase;
  letter-spacing: 0.05em; border-bottom: 1px solid var(--border-color); white-space: nowrap;
}
.cms-table td {
  padding: 10px var(--space-md); border-bottom: 1px solid var(--border-color); color: var(--text-primary);
}
.cms-table tr:hover td { background: var(--bg-surface-hover); }

.cms-table-wrapper {
  border: 1px solid var(--border-color); border-radius: var(--radius-md); overflow-x: auto; overflow-y: hidden;
}

.tag { display: inline-block; padding: 2px 8px; background: var(--accent-soft); color: var(--accent); border-radius: var(--radius-full); font-size: 0.75rem; font-weight: 500; margin: 1px; }
.status-active { color: var(--success); }
.status-inactive { color: var(--text-muted); }

/* ==================== Modal ==================== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}
.modal {
  background: var(--bg-surface); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); width: 90%; max-width: 600px; max-height: 90vh;
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-lg); border-bottom: 1px solid var(--border-color);
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.2rem; padding: 4px; }
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: var(--space-lg); overflow-y: auto; flex: 1; }
.modal-footer { padding: var(--space-md) var(--space-lg); border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: var(--space-sm); }

/* ==================== Charts in CMS ==================== */
.cms-chart-container {
  background: var(--bg-surface); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: var(--space-lg); margin-bottom: var(--space-xl);
  max-height: 300px;
}

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
  .cms-sidebar { position: fixed; transform: translateX(-100%); z-index: 300; }
  .cms-sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .cms-topbar .mobile-menu-btn { display: flex; background: none; border: none; color: var(--text-primary); cursor: pointer; }
  .cms-content { padding: var(--space-md); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  
  .cms-table-toolbar { flex-direction: column; align-items: stretch; }
  .cms-search { width: 100%; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .modal { width: 95%; max-height: 95vh; }
  .cms-topbar { padding: var(--space-md); }
  .cms-page-title { font-size: 1rem; }
}

/* ==================== Empty state ==================== */
.empty-state {
  text-align: center; padding: var(--space-2xl); color: var(--text-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: var(--space-md); opacity: 0.5; }
.empty-state-text { font-size: 0.95rem; }
