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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.6;
}

/* Layout */
.container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 240px;
  background: #1555a0;
  color: #fff;
  padding: 20px 0;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  transition: transform 0.18s ease;
}

.sidebar-header {
  padding: 0 20px 20px;
  border-bottom: 1px solid #2d2d44;
  margin-bottom: 20px;
  min-height: 58px;
  position: relative;
}

.sidebar-header h1 {
  font-size: 1.2rem;
  color: #e94560;
}

.sidebar-header span {
  font-size: 0.8rem;
  color: #888;
}

.sidebar-toggle {
  position: fixed;
  top: 22px;
  left: 240px;
  z-index: 101;
  width: 28px;
  height: 44px;
  border: 1px solid #124987;
  border-radius: 0 8px 8px 0;
  background: #1555a0;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 2px 6px #123a6326;
}
.sidebar-toggle:hover { background: #10427e; }
.sidebar-toggle:focus-visible { outline: 3px solid #f5b83d; outline-offset: 2px; }
.sidebar-header h1 { color: #fff; }
.sidebar-header span { color: #dbeafe; }
.sidebar-header { border-bottom-color: #ffffff30; }

.view-as-control {
  padding: 0 20px 16px;
  border-bottom: 1px solid #2d2d44;
  margin: -4px 0 14px;
}

.view-as-control label {
  display: block;
  color: #888;
  font-size: 0.72rem;
  font-weight: 700;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.view-as-control select {
  width: 100%;
  border: 1px solid #35354e;
  border-radius: 6px;
  background: #222238;
  color: #fff;
  padding: 8px 9px;
  font: inherit;
  outline: none;
}

.view-as-control select:focus {
  border-color: #e94560;
}

.nav-menu {
  list-style: none;
}

.nav-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: #e5efff;
  text-decoration: none;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
}

.nav-icon svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-menu a:hover,
.nav-menu a.active {
  background: #10427e;
  color: #fff;
  border-left: 3px solid #e94560;
}

.nav-menu a.active {
  background: #e94560;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 30px;
  transition: margin-left 0.18s ease;
}

html[data-admin-nav-collapsed="true"] .sidebar {
  transform: translateX(-100%);
  visibility: hidden;
  pointer-events: none;
}
html[data-admin-nav-collapsed="true"] .main-content { margin-left: 0; }
html[data-admin-nav-collapsed="true"] .sidebar-toggle { left: 0; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.page-header h2 {
  font-size: 1.8rem;
  color: #1a1a2e;
}

/* Cards */
.card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  padding: 20px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid #eee;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.stat-card h3 {
  font-size: 0.9rem;
  color: #888;
  margin-bottom: 10px;
}

.stat-card .value {
  font-size: 2rem;
  font-weight: 700;
  color: #1a1a2e;
}

.stat-card.primary { border-left: 4px solid #e94560; }
.stat-card.success { border-left: 4px solid #4caf50; }
.stat-card.warning { border-left: 4px solid #ff9800; }
.stat-card.info { border-left: 4px solid #2196f3; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
  transition: all 0.2s;
}

.btn-primary {
  background: #e94560;
  color: #fff;
}

.btn-primary:hover {
  background: #d63850;
}

.btn-secondary {
  background: #6c757d;
  color: #fff;
}

.btn-secondary:hover {
  background: #5a6268;
}

.btn-secondary.btn-sm {
  padding: 5px 10px;
}

.btn-success {
  background: #4caf50;
  color: #fff;
}

.btn-danger {
  background: #dc3545;
  color: #fff;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
}

/* Tables */
.table-responsive {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

th {
  background: #f8f9fa;
  font-weight: 600;
  color: #555;
}

tr:hover {
  background: #f8f9fa;
}

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

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  color: #555;
}

.form-control {
  width: 100%;
  padding: 10px 15px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 1rem;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: #e94560;
}

textarea.form-control {
  min-height: 120px;
  resize: vertical;
}

select.form-control {
  cursor: pointer;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: #fff;
  border-radius: 8px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.preview-modal-content {
  max-width: 900px;
}

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

.modal-header h3 {
  font-size: 1.2rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #888;
}

.modal-body {
  padding: 20px;
}

.preview-body h1 {
  margin-bottom: 10px;
  color: #1a1a2e;
}

.preview-body h2 {
  margin-bottom: 16px;
  color: #444;
  font-size: 1.2rem;
}

.preview-meta {
  color: #777;
  margin-bottom: 14px;
}

.preview-image {
  width: 100%;
  border-radius: 8px;
  margin: 10px 0 20px;
}

.preview-content {
  line-height: 1.7;
}

.preview-content iframe {
  width: 100%;
  max-width: 100%;
  min-height: 360px;
  border: 0;
}

.modal-footer {
  padding: 15px 20px;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Alerts */
.alert {
  padding: 15px 20px;
  border-radius: 5px;
  margin-bottom: 20px;
}

.alert-success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.alert-error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.alert-info {
  background: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: #888;
}

.spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #e94560;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #888;
}

.empty-state h3 {
  margin-bottom: 10px;
}

/* Badge */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }

/* Actions */
.actions {
  display: flex;
  gap: 5px;
}

.admin-auth-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 23, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
}

.admin-auth-card {
  width: min(90vw, 460px);
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.28);
}

.admin-auth-card h2 {
  margin-bottom: 10px;
  color: #1a1a2e;
}

.admin-auth-card p {
  color: #555;
  margin-bottom: 16px;
}

.admin-auth-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* On small screens the expanded menu overlays the page. */
@media (max-width: 768px) {
  .sidebar { width: min(240px, calc(100vw - 44px)); }
  .sidebar-toggle { left: min(240px, calc(100vw - 44px)); }
  .main-content { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar, .main-content { transition: none; }
}

/* Static page menus stay hidden until the shared authenticated menu is ready. */
.sidebar .nav-menu:not([data-ready="true"]) { visibility: hidden; }
