* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-feature-settings: "liga" 1, "calt" 1;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Ensure emojis render properly */
.emoji,
[class*="emoji"],
.nav-icon,
h1, h2, h3, h4, h5, h6 {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji', 'Android Emoji', 'EmojiOne Color', 'EmojiOne Mozilla', 'Twemoji Mozilla', 'Noto Emoji';
  font-variant-emoji: emoji;
  -webkit-font-feature-settings: "liga", "kern";
  font-feature-settings: "liga", "kern";
}

:root {
  --primary: #1877f2;
  --primary-dark: #0d5bb8;
  --secondary: #42b72a;
  --danger: #e74c3c;
  --warning: #f39c12;
  --success: #27ae60;
  --bg: #f0f2f5;
  --card-bg: #ffffff;
  --text: #1c1e21;
  --text-secondary: #65676b;
  --border: #dadde1;
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji', 'Android Emoji', 'EmojiOne Color', 'EmojiOne Mozilla', 'Twemoji Mozilla', 'Noto Emoji';
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  display: flex;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: linear-gradient(180deg, #1877f2 0%, #0d5bb8 100%);
  color: white;
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 12px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, width 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 70px;
}

.sidebar-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  background: linear-gradient(135deg, #ffffff 0%, #e0f0ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-toggle {
  display: none;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  font-size: 1.5rem;
  padding: 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s;
  border-left: 3px solid transparent;
  margin: 0 0.75rem;
  border-radius: 8px;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border-left-color: rgba(255, 255, 255, 0.5);
}

.nav-link.active {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border-left-color: white;
  font-weight: 600;
}

.nav-icon {
  font-size: 1.25rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji', 'Android Emoji', 'EmojiOne Color', 'EmojiOne Mozilla', 'Twemoji Mozilla', 'Noto Emoji', sans-serif;
  display: inline-block;
  vertical-align: middle;
}

.nav-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: auto;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  color: rgba(255, 255, 255, 0.9);
}

.user-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.user-badge {
  background: rgba(255, 215, 0, 0.2);
  color: #ffd700;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.logout-btn {
  display: block;
  width: 100%;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  text-align: center;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
  transition: background 0.2s;
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Main Wrapper */
.main-wrapper {
  flex: 1;
  margin-left: 260px;
  min-height: 100vh;
  transition: margin-left 0.3s ease;
  position: relative;
}

.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 1001;
  background: linear-gradient(135deg, #1877f2 0%, #0d5bb8 100%);
  color: white;
  border: none;
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(24, 119, 242, 0.3);
  transition: all 0.2s;
}

.mobile-menu-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(24, 119, 242, 0.4);
}

.main-content {
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* Responsive Sidebar */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
  }

  .sidebar.collapsed {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: block;
  }

  .mobile-menu-btn {
    display: block;
  }

  .main-wrapper {
    margin-left: 0;
  }

  .sidebar-overlay {
    display: block;
  }

  .main-content {
    padding: 1.5rem 1rem;
    padding-top: 4rem;
  }
}

/* Cards/Sections */
section {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}

section:hover {
  box-shadow: var(--shadow-lg);
}

section h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

section h2::before {
  content: '';
  width: 4px;
  height: 24px;
  background: var(--primary);
  border-radius: 2px;
}

/* Forms */
.form-group {
  margin-bottom: 1.5rem;
}

label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text);
  font-size: 0.95rem;
}

input[type="text"],
input[type="url"],
input[type="datetime-local"],
textarea,
select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: white;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.1);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

/* File Upload */
.file-upload {
  position: relative;
  display: inline-block;
  width: 100%;
}

.file-upload input[type="file"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.file-upload-label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  border: 2px dashed var(--border);
  border-radius: 8px;
  background: #fafbfc;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.file-upload-label:hover {
  border-color: var(--primary);
  background: #f0f7ff;
}

.file-upload-label.has-file {
  border-color: var(--success);
  background: #f0fdf4;
}

.file-preview {
  margin-top: 1rem;
  padding: 1rem;
  background: #f9fafb;
  border-radius: 8px;
  display: none;
}

.file-preview.active {
  display: block;
}

.file-preview img,
.file-preview video {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
}

/* Buttons */
button,
.btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

button:hover,
.btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

button:active,
.btn:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--secondary);
}

.btn-secondary:hover {
  background: #36a420;
}

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

.btn-danger:hover {
  background: #c0392b;
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* Checkboxes */
.checkboxes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  padding: 1rem;
  background: #f9fafb;
  border-radius: 8px;
  border: 2px solid var(--border);
}

.checkboxes label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 6px;
  transition: background 0.2s;
  margin: 0;
}

.checkboxes label:hover {
  background: white;
}

.checkboxes input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* Row layout */
.row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.row .form-group {
  flex: 1;
  min-width: 200px;
  margin-bottom: 0;
}

/* Status badges */
.status-badge {
  display: inline-block;
  padding: 0.375rem 0.75rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-queued {
  background: #e3f2fd;
  color: #1976d2;
}

.status-running {
  background: #fff3e0;
  color: #f57c00;
}

.status-success {
  background: #e8f5e9;
  color: #388e3c;
}

.status-failed {
  background: #ffebee;
  color: #d32f2f;
}

.status-cancelled {
  background: #f5f5f5;
  color: #757575;
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

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

thead {
  background: #f9fafb;
}

th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text);
  border-bottom: 2px solid var(--border);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:hover {
  background: #f9fafb;
}

tbody tr:last-child td {
  border-bottom: none;
}

/* Pages list */
.pages {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 1rem;
}

.page-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: #f9fafb;
  border-radius: 8px;
  border: 2px solid var(--border);
  transition: all 0.2s;
}

.page-item:hover {
  border-color: var(--primary);
  background: white;
  box-shadow: var(--shadow);
}

.page-item img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}

.page-item span {
  font-weight: 500;
  flex: 1;
}

.page-item code {
  font-size: 0.875rem;
  color: var(--text-secondary);
  background: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

/* Empty states */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
}

.empty-state::before {
  content: '📭';
  font-size: 3rem;
  display: block;
  margin-bottom: 1rem;
}

/* Alerts/Info boxes */
.info-box {
  padding: 1rem 1.5rem;
  background: #e3f2fd;
  border-left: 4px solid var(--primary);
  border-radius: 6px;
  margin-bottom: 1.5rem;
}

.info-box.warning {
  background: #fff3e0;
  border-left-color: var(--warning);
}

.info-box.success {
  background: #e8f5e9;
  border-left-color: var(--success);
}

/* Code/pre blocks */
pre {
  background: #f9fafb;
  padding: 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  overflow-x: auto;
  border: 1px solid var(--border);
}

code {
  font-family: 'Courier New', monospace;
}

/* Responsive */
@media (max-width: 768px) {
  section {
    padding: 1.5rem;
  }

  .row {
    flex-direction: column;
  }

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

  .table-wrapper {
    font-size: 0.875rem;
  }

  th, td {
    padding: 0.75rem 0.5rem;
  }
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

section {
  animation: fadeIn 0.3s ease-out;
}

/* Loading states */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Media Preview */
.media-preview {
  text-align: center;
  margin: 1rem 0;
}

.media-preview img,
.media-preview video {
  max-width: 100%;
  max-height: 500px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  object-fit: contain;
}

.media-preview img {
  cursor: pointer;
  transition: transform 0.2s;
}

.media-preview img:hover {
  transform: scale(1.02);
}

.media-preview video {
  background: #000;
}

.media-error {
  padding: 1rem;
  background: #ffebee;
  border-radius: 8px;
  color: var(--danger);
  margin: 1rem 0;
}

/* Utility classes */
.text-center {
  text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
