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

:root {
  --bg: #0a0a0a;
  --bg-card: #141414;
  --bg-input: #1a1a1a;
  --border: #2a2a2a;
  --text: #f5f5f5;
  --text-muted: #888;
  --accent: #4ade80;
  --accent-hover: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
}

html {
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

header {
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  margin-bottom: 2rem;
}

header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.logo span {
  color: var(--accent);
}

nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

nav a {
  color: var(--text-muted);
  font-size: 0.875rem;
  transition: color 0.2s;
}

nav a:hover,
nav a.active {
  color: var(--text);
  text-decoration: none;
}

.user-info {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.user-info strong {
  color: var(--text);
}

/* Login page */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
}

.login-card h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.login-card p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

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

label {
  display: block;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="url"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.625rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea {
  min-height: 120px;
  resize: vertical;
  white-space: pre;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  gap: 0.5rem;
}

.btn-primary {
  background: var(--accent);
  color: #0a0a0a;
}

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

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

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

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  border-color: var(--text-muted);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-block {
  width: 100%;
}

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

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.card h2 {
  font-size: 1.125rem;
  margin-bottom: 1rem;
}

.card h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

/* Grid */
.grid {
  display: grid;
  gap: 1rem;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

/* Stats */
.stat {
  text-align: center;
  padding: 1rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

th, td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Status badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: capitalize;
}

.badge-upcoming { background: #1e3a5f; color: #93c5fd; }
.badge-draft_due { background: #4a3728; color: #fbbf24; }
.badge-draft_submitted { background: #1e3a5f; color: #93c5fd; }
.badge-in_review { background: #3b1f6e; color: #c4b5fd; }
.badge-changes_requested { background: #4a2828; color: #fca5a5; }
.badge-approved { background: #14532d; color: #86efac; }
.badge-posted { background: #14532d; color: #4ade80; }
.badge-missed { background: #4a2828; color: #ef4444; }
.badge-submitted { background: #1e3a5f; color: #93c5fd; }

.badge-planning { background: #4a3728; color: #fbbf24; }
.badge-in_build { background: #1e3a5f; color: #93c5fd; }
.badge-live { background: #14532d; color: #4ade80; }

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: #2d1b1b;
  color: #fca5a5;
  border: 1px solid #4a2828;
}

.alert-success {
  background: #1b2d1b;
  color: #86efac;
  border: 1px solid #14532d;
}

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

.empty p {
  margin-top: 0.5rem;
  font-size: 0.875rem;
}

/* Loading */
.loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

/* Section headers */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.section-header h2 {
  margin-bottom: 0;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 {
  margin-bottom: 1rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  justify-content: flex-end;
}

/* Draft text preview */
.draft-preview {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  font-size: 0.875rem;
  white-space: pre-wrap;
  line-height: 1.7;
  margin: 1rem 0;
}

/* Clickable row */
.clickable {
  cursor: pointer;
}

.clickable:hover td {
  background: rgba(74, 222, 128, 0.05);
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  gap: 0;
}

.tab {
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
  transition: all 0.2s;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Inline actions */
.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Responsive */
@media (max-width: 768px) {
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }

  header .container {
    flex-direction: column;
    align-items: flex-start;
  }

  nav {
    width: 100%;
    overflow-x: auto;
  }

  .modal {
    max-width: 100%;
  }

  th, td {
    padding: 0.5rem;
    font-size: 0.8125rem;
  }

  .hide-mobile {
    display: none;
  }
}

/* Checkbox group for recurring */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  cursor: pointer;
  color: var(--text);
}

.checkbox-group input[type="checkbox"] {
  width: auto;
}

/* Admin notes */
.admin-notes {
  background: #2d1b1b;
  border: 1px solid #4a2828;
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
  font-size: 0.875rem;
  white-space: pre-wrap;
}

.admin-notes strong {
  color: #fca5a5;
  display: block;
  margin-bottom: 0.5rem;
}

/* Side-by-side revision layout (Fix 3) */
.revision-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 1rem;
}

.revision-context {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.revision-context .admin-notes {
  margin: 0;
}

.revision-context .draft-preview {
  margin: 0;
  flex: 1;
}

.revision-form {
  display: flex;
  flex-direction: column;
}

.revision-form textarea {
  flex: 1;
  min-height: 250px;
}

.revision-form .form-group {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.revision-form .form-group textarea {
  flex: 1;
}

/* Visual upload area */
.visual-upload {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.visual-upload label {
  font-size: 0.8125rem;
}

.visual-upload .file-preview {
  margin-top: 0.75rem;
  max-width: 200px;
}

.visual-upload .file-preview img {
  max-width: 100%;
  border-radius: 4px;
}

.badge-visual-needed {
  background: #4a3728;
  color: #fbbf24;
}

.visual-display {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.visual-display img {
  max-width: 100%;
  max-height: 400px;
  border-radius: 4px;
}

.visual-note {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Time input styling */
input[type="time"] {
  width: 100%;
  padding: 0.625rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.2s;
}

input[type="time"]:focus {
  outline: none;
  border-color: var(--accent);
}

/* Wider modal for revision layout */
.modal-wide {
  max-width: 900px;
}

@media (max-width: 768px) {
  .revision-layout {
    grid-template-columns: 1fr;
  }

  .modal-wide {
    max-width: 100%;
  }
}

/* View toggle */
.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.view-toggle button {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  background: transparent;
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}

.view-toggle button.active {
  background: var(--accent);
  color: #0a0a0a;
}

/* Calendar navigation */
.calendar-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.calendar-nav h3 {
  margin: 0;
  min-width: 160px;
  text-align: center;
}

.calendar-nav .btn {
  padding: 0.375rem 0.625rem;
}

/* Calendar grid */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.calendar-header-cell {
  background: var(--bg-card);
  padding: 0.5rem 0.25rem;
  text-align: center;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.calendar-cell {
  background: var(--bg);
  min-height: 90px;
  padding: 0.375rem;
  position: relative;
  vertical-align: top;
}

.calendar-cell.empty {
  background: var(--bg-card);
  opacity: 0.3;
}

.calendar-cell.today {
  background: rgba(74, 222, 128, 0.04);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.calendar-day-num {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  font-weight: 500;
}

.calendar-cell.today .calendar-day-num {
  color: var(--accent);
  font-weight: 700;
}

.calendar-slot {
  background: var(--bg-card);
  border-radius: 4px;
  padding: 0.25rem 0.375rem;
  margin-bottom: 2px;
  font-size: 0.625rem;
  cursor: pointer;
  border-left: 3px solid;
  line-height: 1.4;
  transition: opacity 0.15s;
}

.calendar-slot:hover {
  opacity: 0.75;
}

.calendar-slot .slot-poster {
  font-weight: 600;
  display: block;
}

.calendar-slot .slot-resource {
  color: var(--text-muted);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calendar-slot .slot-time {
  color: var(--text-muted);
  font-size: 0.5625rem;
}

.calendar-slot.status-upcoming { border-left-color: #64748b; }
.calendar-slot.status-draft_due { border-left-color: #fbbf24; }
.calendar-slot.status-draft_submitted { border-left-color: #93c5fd; }
.calendar-slot.status-in_review { border-left-color: #c4b5fd; }
.calendar-slot.status-changes_requested { border-left-color: #fca5a5; }
.calendar-slot.status-approved { border-left-color: #86efac; }
.calendar-slot.status-posted { border-left-color: #4ade80; }
.calendar-slot.status-missed { border-left-color: #ef4444; }

.calendar-slot.needs-action {
  animation: pulse-action 2s ease-in-out infinite;
}

@keyframes pulse-action {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.4); }
  50% { box-shadow: 0 0 0 3px rgba(251, 191, 36, 0); }
}

/* Mobile calendar: list fallback */
.calendar-list {
  display: none;
}

.calendar-list-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.calendar-list-item:hover {
  background: rgba(255, 255, 255, 0.02);
}

.calendar-list-date {
  min-width: 70px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.calendar-list-date.today {
  color: var(--accent);
  font-weight: 600;
}

.calendar-list-detail {
  flex: 1;
  font-size: 0.8125rem;
}

.calendar-list-detail .slot-poster {
  font-weight: 600;
}

@media (max-width: 768px) {
  .calendar-grid {
    display: none;
  }

  .calendar-list {
    display: block;
  }

  .calendar-cell {
    min-height: 60px;
  }
}
