/* Admin Panel Styles - Sidebar Layout */

:root {
  --admin-sidebar-width: 240px;
  --admin-sidebar-bg: #1f2937;
  --admin-sidebar-text: #9ca3af;
  --admin-sidebar-text-hover: #ffffff;
  --admin-sidebar-active-bg: #374151;
  --admin-accent: #f59e0b;
}

.admin-body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f9fafb;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

/* ===============================
   Sidebar Styles
   =============================== */

.admin-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--admin-sidebar-width);
  background: var(--admin-sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.admin-sidebar-header {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid #374151;
}

.admin-logo {
  color: white;
  font-weight: 600;
  font-size: 1.125rem;
  display: block;
}

.admin-logo-sub {
  color: var(--admin-accent);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.admin-nav-section {
  margin-bottom: 1.5rem;
}

.admin-nav-label {
  padding: 0.5rem 1rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #6b7280;
}

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  color: var(--admin-sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  transition: all 0.15s ease;
}

.admin-nav-item:hover {
  color: var(--admin-sidebar-text-hover);
  background: rgba(255, 255, 255, 0.05);
}

.admin-nav-item.active {
  color: var(--admin-sidebar-text-hover);
  background: var(--admin-sidebar-active-bg);
  border-left: 3px solid var(--admin-accent);
  padding-left: calc(1rem - 3px);
}

.admin-nav-icon {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}

.admin-sidebar-footer {
  padding: 1rem;
  border-top: 1px solid #374151;
}

.admin-user-info {
  margin-bottom: 0.75rem;
}

.admin-user-email {
  color: var(--admin-sidebar-text);
  font-size: 0.75rem;
  word-break: break-all;
}

.admin-exit-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  color: var(--admin-sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.15s ease;
}

.admin-exit-link:hover {
  color: var(--admin-sidebar-text-hover);
}

/* ===============================
   Mobile Header & Backdrop
   =============================== */

.admin-mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--admin-sidebar-bg);
  z-index: 90;
  align-items: center;
  padding: 0 1rem;
  gap: 1rem;
}

.admin-sidebar-toggle {
  background: none;
  border: none;
  color: white;
  padding: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-sidebar-toggle svg {
  width: 1.5rem;
  height: 1.5rem;
}

.admin-mobile-title {
  color: white;
  font-weight: 600;
}

.admin-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 95;
}

/* ===============================
   Main Content Area
   =============================== */

.admin-main {
  margin-left: var(--admin-sidebar-width);
  min-height: 100vh;
}

.admin-notice {
  background: #d1fae5;
  color: #065f46;
  padding: 1rem 2rem;
}

.admin-alert {
  background: #fee2e2;
  color: #991b1b;
  padding: 1rem 2rem;
}

.admin-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.admin-header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: #111;
}

.admin-container > h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #111;
  margin-bottom: 1.5rem;
}

/* ===============================
   Stats & Cards
   =============================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 600;
  color: #111;
}

.stat-label {
  font-size: 0.875rem;
  color: #6b7280;
  margin-top: 0.25rem;
}

.admin-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}

.admin-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
}

.admin-card-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.admin-card-body {
  padding: 1.25rem;
}

/* ===============================
   Sections
   =============================== */

.admin-sections {
  display: grid;
  gap: 2rem;
}

.admin-sections section {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1.5rem;
}

.admin-sections h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
  color: #111;
}

.view-all-link {
  display: block;
  margin-top: 1rem;
  color: #6b7280;
  text-decoration: none;
  font-size: 0.875rem;
}

.view-all-link:hover {
  color: #111;
}

/* ===============================
   Filters
   =============================== */

.admin-filters {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.admin-filters input[type="text"] {
  padding: 0.5rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  width: 300px;
  font-size: 0.875rem;
}

.admin-filters select {
  padding: 0.5rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.875rem;
  background: white;
}

.admin-filters input[type="submit"] {
  padding: 0.5rem 1rem;
  background: #374151;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  cursor: pointer;
}

.admin-filters input[type="submit"]:hover {
  background: #1f2937;
}

/* ===============================
   Tables
   =============================== */

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  font-size: 0.875rem;
}

.admin-table th,
.admin-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

.admin-table th {
  background: #f9fafb;
  font-weight: 500;
  color: #6b7280;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table tr:hover {
  background: #f9fafb;
}

.admin-table a {
  color: #2563eb;
  text-decoration: none;
}

.admin-table a:hover {
  text-decoration: underline;
}

.monospace {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
}

/* Table wrapper for horizontal scroll */
.admin-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -0.5rem;
  padding: 0 0.5rem;
}

/* ===============================
   Meta & Details
   =============================== */

.admin-meta {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.admin-meta dl {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 0.5rem 1rem;
  margin: 0;
}

.admin-meta dt {
  font-weight: 500;
  color: #6b7280;
  font-size: 0.875rem;
}

.admin-meta dd {
  margin: 0;
  font-size: 0.875rem;
}

.admin-section {
  margin-top: 2rem;
}

.admin-section h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #111;
}

/* ===============================
   Badges & Tags
   =============================== */

.phase-badge,
.status-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.phase-badge {
  background: #e5e7eb;
  color: #374151;
}

.phase-awaiting_date { background: #fef3c7; color: #92400e; }
.phase-generating { background: #dbeafe; color: #1e40af; }
.phase-captain_review { background: #fce7f3; color: #9d174d; }
.phase-voting { background: #d1fae5; color: #065f46; }
.phase-decided { background: #10b981; color: white; }

.status-badge { background: #e5e7eb; color: #374151; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-approved { background: #d1fae5; color: #065f46; }
.status-rejected { background: #fee2e2; color: #991b1b; }

.tag {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  background: #f3f4f6;
  border-radius: 4px;
  font-size: 0.75rem;
  margin-right: 0.25rem;
}

/* ===============================
   Code Blocks & Details
   =============================== */

.code-block {
  background: #1f2937;
  color: #e5e7eb;
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.75rem;
  max-height: 400px;
  overflow-y: auto;
  margin-top: 0.5rem;
}

details {
  margin-bottom: 0.5rem;
}

details summary {
  cursor: pointer;
  font-size: 0.875rem;
  color: #6b7280;
  padding: 0.5rem 0;
}

details summary:hover {
  color: #111;
}

/* ===============================
   Utility Classes
   =============================== */

.empty-state {
  color: #9ca3af;
  font-style: italic;
  padding: 1rem 0;
}

.error-text {
  color: #dc2626;
}

/* ===============================
   Buttons
   =============================== */

.btn-small {
  padding: 0.375rem 0.75rem;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 0.75rem;
  text-decoration: none;
  color: #374151;
}

.btn-small:hover {
  background: #e5e7eb;
  text-decoration: none;
}

.btn-sm {
  display: inline-block;
  padding: 0.375rem 0.75rem;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 0.75rem;
  text-decoration: none;
  color: #374151;
  cursor: pointer;
  margin-right: 0.25rem;
}

.btn-sm:hover {
  background: #e5e7eb;
  text-decoration: none;
}

.btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
}

.btn-primary {
  background: #f59e0b;
  color: white;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}

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

.btn-danger {
  background: #dc2626;
  color: white;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
}

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

/* ===============================
   Danger Zone
   =============================== */

.danger-zone {
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 1.5rem;
  background: #fef2f2;
}

.danger-zone h2 {
  color: #dc2626;
  margin-top: 0;
}

/* ===============================
   Forms
   =============================== */

.admin-form {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.admin-errors {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
  color: #dc2626;
}

.admin-errors ul {
  margin: 0;
  padding-left: 1.25rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-weight: 500;
  color: #374151;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.form-control {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.875rem;
  box-sizing: border-box;
}

.form-control:focus {
  outline: none;
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

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

textarea.form-control.monospace {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.5;
}

.form-hint {
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 0.375rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* ===============================
   Links & Info Boxes
   =============================== */

.back-link {
  color: #6b7280;
  text-decoration: none;
  font-size: 0.875rem;
  display: block;
  margin-bottom: 0.5rem;
}

.back-link:hover {
  color: #374151;
}

.admin-info-box {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  color: #1e40af;
}

/* ===============================
   Preview
   =============================== */

.admin-preview {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1.5rem;
}

.admin-preview h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: #6b7280;
  margin: 0 0 1rem 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.preview-subject {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e5e7eb;
}

.preview-body {
  color: #374151;
  line-height: 1.6;
}

.admin-subtitle {
  color: #6b7280;
  margin-top: -1rem;
  margin-bottom: 1.5rem;
}

.text-muted {
  color: #9ca3af;
  font-size: 0.75rem;
}

.admin-actions {
  white-space: nowrap;
}

/* ===============================
   Mobile Responsive Styles
   =============================== */

@media (max-width: 1024px) {
  .admin-sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .admin-sidebar.open {
    transform: translateX(0);
  }

  .admin-sidebar-backdrop.open {
    display: block;
  }

  .admin-mobile-header {
    display: flex;
  }

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

@media (max-width: 768px) {
  /* Container */
  .admin-container {
    padding: 1rem;
  }

  /* Header */
  .admin-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .admin-header h1 {
    font-size: 1.25rem;
  }

  .admin-container > h1 {
    font-size: 1.25rem;
  }

  /* Stats Grid */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-card {
    padding: 1rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  /* Filters */
  .admin-filters {
    flex-direction: column;
    gap: 0.75rem;
  }

  .admin-filters input[type="text"] {
    width: 100%;
    box-sizing: border-box;
  }

  .admin-filters select {
    width: 100%;
  }

  .admin-filters input[type="submit"] {
    width: 100%;
  }

  /* Tables - Enable horizontal scroll */
  .admin-table {
    min-width: 600px;
  }

  .admin-table th,
  .admin-table td {
    padding: 0.5rem 0.75rem;
    white-space: nowrap;
  }

  /* Metadata Grid */
  .admin-meta dl {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .admin-meta dt {
    margin-top: 0.75rem;
  }

  .admin-meta dt:first-child {
    margin-top: 0;
  }

  .admin-meta {
    padding: 1rem;
  }

  /* Sections */
  .admin-sections section {
    padding: 1rem;
  }

  .admin-sections h2 {
    font-size: 1rem;
  }

  .admin-section h2 {
    font-size: 1rem;
  }

  /* Danger zone */
  .danger-zone {
    padding: 1rem;
  }

  .btn-danger {
    width: 100%;
  }

  /* Code blocks */
  .code-block {
    font-size: 0.65rem;
    padding: 0.75rem;
  }

  /* Flash messages */
  .admin-notice,
  .admin-alert {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-value {
    font-size: 1.25rem;
  }

  .admin-table {
    min-width: 500px;
  }

  .admin-table th,
  .admin-table td {
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
  }

  .phase-badge,
  .status-badge {
    padding: 0.125rem 0.5rem;
    font-size: 0.65rem;
  }

  .btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.65rem;
  }
}
