/* Searchable Select Component */
.searchable-select {
  position: relative;
  width: 100%;
}

.searchable-select-input {
  width: 100%;
  padding: 8px 32px 8px 12px;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1.5;
  background-color: #fff;
  cursor: text;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.searchable-select-input:focus {
  border-color: #667eea;
  outline: none;
  box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

.searchable-select-arrow {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: #6c757d;
  transition: transform 0.2s ease;
}

.searchable-select-arrow.open {
  transform: translateY(-50%) rotate(180deg);
}

.searchable-select-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
}

.searchable-select-dropdown.hidden {
  display: none;
}

.searchable-select-option {
  padding: 10px 12px;
  cursor: pointer;
  transition: background-color 0.15s ease;
  border-bottom: 1px solid #f1f3f5;
}

.searchable-select-option:last-child {
  border-bottom: none;
}

.searchable-select-option:hover,
.searchable-select-option.highlighted {
  background-color: #f8f9fa;
}

.searchable-select-option.selected {
  background-color: #e7f1ff;
  font-weight: 500;
}

.searchable-select-option.selected:hover {
  background-color: #d0e2ff;
}

.searchable-select-option.hidden {
  display: none;
}

.searchable-select-option-type {
  display: inline-block;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  margin-right: 8px;
  font-weight: 600;
  text-transform: uppercase;
}

.searchable-select-option-type.post {
  background-color: #e3f2fd;
  color: #1976d2;
}

.searchable-select-option-type.legacy {
  background-color: #f3e5f5;
  color: #7b1fa2;
}

.searchable-select-option-title {
  color: #212529;
}

.no-results {
  padding: 16px;
  text-align: center;
  color: #6c757d;
  font-style: italic;
}

/* Scrollbar styling */
.searchable-select-dropdown::-webkit-scrollbar {
  width: 8px;
}

.searchable-select-dropdown::-webkit-scrollbar-track {
  background: #f1f3f5;
  border-radius: 4px;
}

.searchable-select-dropdown::-webkit-scrollbar-thumb {
  background: #dee2e6;
  border-radius: 4px;
}

.searchable-select-dropdown::-webkit-scrollbar-thumb:hover {
  background: #ced4da;
}

/* Admin Layout */
.admin-layout {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: #f5f5f5;
}

.admin-container {
  display: flex;
  min-height: 100vh;
}

/* Mobile Header */
.admin-header-mobile {
  display: flex;
  align-items: center;
  padding: 0.5rem 1rem;
  background-color: #2c3e50;
  color: white;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: 60px;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.75rem;
  margin-right: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

.sidebar-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.mobile-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

/* Sidebar Overlay */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 1100; /* Below sidebar but above main content */
  pointer-events: none;
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Sidebar - Mobile First */
.admin-sidebar {
  width: 250px;
  background-color: #2c3e50;
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  left: 0;
  top: 0;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  z-index: 1200; /* Above overlay */
}

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

.sidebar-header {
  padding: 1.5rem;
  background-color: #1a252f;
  border-bottom: 1px solid #34495e;
}

.sidebar-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: white;
  margin-bottom: 0.75rem;
}

.back-to-blog {
  display: inline-block;
  color: #95a5a6;
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.2s;
}

.back-to-blog:hover {
  color: #ecf0f1;
}

.sidebar-footer {
  margin-top: auto;
  padding: 1rem 1.5rem;
  border-top: 1px solid #34495e;
  background-color: #1a252f;
}

.user-info {
  font-size: 0.875rem;
  color: #bdc3c7;
  margin-bottom: 0.5rem;
}

.logout-link {
  color: #e74c3c;
  text-decoration: none;
  font-size: 0.875rem;
}

.logout-link:hover {
  color: #c0392b;
}

/* Navigation */
.admin-nav {
  flex: 1;
  padding: 1rem 0;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-item {
  margin-bottom: 0.25rem;
}

.nav-item.active .nav-link {
  background-color: #34495e;
  color: white;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  color: #ecf0f1;
  text-decoration: none;
  transition: background-color 0.2s;
}

.nav-link:hover {
  background-color: #34495e;
  color: white;
}

.nav-icon {
  font-size: 1.25rem;
  margin-right: 0.75rem;
  width: 1.5rem;
  text-align: center;
}

.nav-text {
  font-size: 0.95rem;
}

/* Main Content - Mobile First */
.admin-main {
  flex: 1;
  margin-left: 0;
  padding: 1rem;
  padding-top: calc(60px + 1rem); /* Header height + padding */
  min-height: 100vh;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #dee2e6;
}

.page-title {
  margin: 0;
  font-size: 2rem;
  font-weight: 600;
  color: #2c3e50;
}

.header-actions,
.admin-actions {
  display: flex;
  gap: 0.5rem;
}

.admin-content {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

@media (max-width: 767px) {
  .admin-content {
    padding: 1rem;
    border-radius: 0;
  }
  
  /* Make all tables in admin-content scrollable on mobile */
  .admin-content .admin-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Notifications */
.admin-notice,
.admin-alert {
  padding: 1rem;
  margin-bottom: 1.5rem;
  border-radius: 4px;
  font-size: 0.95rem;
}

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

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

/* Tables */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.admin-table th {
  text-align: left;
  padding: 0.75rem;
  background-color: #f8f9fa;
  border-bottom: 2px solid #dee2e6;
  font-weight: 600;
  color: #495057;
}

.admin-table td {
  padding: 0.75rem;
  border-bottom: 1px solid #dee2e6;
}

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

.status-cell {
  text-align: center;
}

.status-icon {
  font-size: 1.2rem;
  cursor: help;
}

.slug-cell {
  color: #666;
  font-family: monospace;
  font-size: 0.9rem;
}

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

/* Buttons */
.btn {
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background-color 0.2s;
}

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

.btn-primary {
  background-color: #3498db;
  color: white;
}

.btn-primary:hover {
  background-color: #2980b9;
}

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

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

.btn-danger {
  background-color: #e74c3c;
  color: white;
}

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

.btn-warning {
  background-color: #f39c12;
  color: #212529;
}

.btn-outline {
  background-color: transparent;
  color: #6c757d;
  border: 1px solid #dee2e6;
}

.btn-outline:hover {
  background-color: #f8f9fa;
}

.btn-outline-secondary {
  background-color: transparent;
  color: #6c757d;
  border: 1px solid #dee2e6;
}

.btn-outline-secondary:hover {
  background-color: #6c757d;
  color: white;
}

.btn-outline-primary {
  background-color: transparent;
  color: #3498db;
  border: 1px solid #3498db;
}

.btn-outline-primary:hover {
  background-color: #3498db;
  color: white;
}

.btn-outline-danger {
  background-color: transparent;
  color: #e74c3c;
  border: 1px solid #e74c3c;
}

.btn-outline-danger:hover {
  background-color: #e74c3c;
  color: white;
}

.btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-group {
  display: flex;
  gap: 0.5rem;
}

/* Forms */
.form-container {
  max-width: 600px;
}

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

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #495057;
}

.form-control {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border: 1px solid #ced4da;
  border-radius: 4px;
  transition: border-color 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-text {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: #6c757d;
}

.form-text.text-warning {
  color: #f39c12;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 2rem;
}

.inline-form {
  display: inline;
}

/* Links */
.link {
  color: #3498db;
  text-decoration: none;
}

.link:hover {
  color: #2980b9;
  text-decoration: underline;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: #6c757d;
}

/* Featured Articles specific */
.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 3px;
  text-transform: uppercase;
}

.badge-primary {
  background-color: #e3f2fd;
  color: #1976d2;
}

.badge-secondary {
  background-color: #f3e5f5;
  color: #7b1fa2;
}

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

.badge-danger {
  background-color: #ffebee;
  color: #c62828;
}

.text-danger {
  color: #dc3545;
}

.text-muted {
  color: #6c757d;
}

.text-center {
  text-align: center;
}

tr.inactive {
  opacity: 0.6;
}

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

/* Mobile table responsive */
@media (max-width: 767px) {
  /* Table wrapper for horizontal scrolling */
  .table-wrapper,
  .admin-content > .admin-table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
  }
  
  /* Extend wrapper to edge on mobile */
  .table-wrapper {
    margin: 0 -1rem;
    padding: 0 1rem;
  }
  
  /* Direct table in admin-content needs wrapper behavior */
  .admin-content > .admin-table {
    margin-left: -1rem;
    margin-right: -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  .admin-table {
    font-size: 0.875rem;
    min-width: 600px; /* Ensure table has minimum width for scrolling */
  }
  
  .admin-table th,
  .admin-table td {
    padding: 0.75rem 0.5rem;
    white-space: nowrap;
  }
  
  /* Improve touch targets for links in tables */
  .admin-table td a {
    display: inline-block;
    padding: 0.5rem 0;
    min-height: 44px;
    line-height: 1.5;
  }
  
  /* Make certain columns more compact on mobile */
  .admin-table th:first-child,
  .admin-table td:first-child {
    min-width: 120px;
  }
  
  /* Actions column sticky for better UX */
  .admin-table .actions-cell,
  .admin-table th:last-child,
  .admin-table td:last-child {
    position: sticky;
    right: 0;
    background-color: white;
    box-shadow: -2px 0 4px rgba(0, 0, 0, 0.1);
    z-index: 10;
  }
  
  .admin-table thead th:last-child {
    background-color: #f8f9fa;
  }
  
  .admin-table tr:hover .actions-cell,
  .admin-table tr:hover td:last-child {
    background-color: #f8f9fa;
  }
  
  /* Compact button styles in tables */
  .admin-table .btn-group {
    flex-direction: row;
    gap: 0.25rem;
  }
  
  .admin-table .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    min-height: 32px;
  }
  
  /* Visual scroll indicator */
  .table-wrapper::after,
  .admin-content > .admin-table::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.8));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
  }
  
  .table-wrapper:not(:hover)::after,
  .admin-content > .admin-table:not(:hover)::after {
    opacity: 1;
  }
}

.form-wrapper {
  max-width: 600px;
}

.form-check {
  margin-bottom: 0.5rem;
}

.form-check-input {
  margin-right: 0.5rem;
}

.form-check-label {
  cursor: pointer;
}

/* Legend */
.legend {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid #dee2e6;
}

.legend h3 {
  color: #666;
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.legend-items {
  display: flex;
  gap: 1.5rem;
  color: #666;
  font-size: 0.9rem;
  flex-wrap: wrap;
}

/* Info Sections */
.info-section,
.posts-section,
.settings-section {
  margin-bottom: 2rem;
}

.info-section h3,
.posts-section h3,
.settings-section h3 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: #2c3e50;
}

.info-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1rem;
}

.info-list dt {
  font-weight: 500;
  color: #6c757d;
}

.info-list dd {
  margin: 0;
  color: #212529;
}

.info-list code {
  background-color: #f8f9fa;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  font-size: 0.875rem;
}

.settings-list {
  background-color: #f8f9fa;
  padding: 1rem;
  border-radius: 4px;
}

.settings-list dt {
  font-weight: 500;
  margin-bottom: 0.25rem;
  color: #495057;
}

.settings-list dd {
  margin: 0 0 1rem 0;
  font-size: 1.25rem;
  color: #212529;
}

.settings-list dd:last-child {
  margin-bottom: 0;
}

.info-box {
  background-color: #e3f2fd;
  border: 1px solid #90caf9;
  color: #1565c0;
  padding: 1rem;
  border-radius: 4px;
  margin-top: 1rem;
}

.info-box p {
  margin: 0;
  font-size: 0.95rem;
}

/* Alert variations */
.alert {
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: 4px;
}

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

.alert h4 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.alert ul {
  margin-bottom: 0;
  padding-left: 1.5rem;
}

/* Desktop View */
@media (min-width: 768px) {
  .admin-header-mobile {
    display: none;
  }
  
  .sidebar-overlay {
    display: none;
  }
  
  .admin-sidebar {
    transform: translateX(0);
    position: static;
    flex-shrink: 0; /* Prevent sidebar from shrinking */
  }
  
  .admin-main {
    margin-left: 0; /* Remove margin since sidebar is in flex layout */
    flex: 1; /* Take remaining space */
    padding: 2rem;
    padding-top: 2rem; /* Reset mobile padding-top */
  }
}

/* Mobile specific styles */
@media (max-width: 767px) {
  .admin-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .header-actions {
    width: 100%;
  }
  
  .btn-group {
    flex-direction: column;
  }
  
  .legend-items {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  /* Hide overflow when sidebar is open on mobile */
  body.sidebar-open {
    overflow: hidden;
  }
  
  /* Mobile button optimization */
  .btn {
    min-height: 44px; /* iOS recommendation for touch targets */
    padding: 0.75rem 1rem;
    width: 100%;
    justify-content: center;
  }
  
  .btn-sm {
    min-height: 44px; /* Improved from 40px for better touch targets */
    padding: 0.625rem 0.75rem;
  }
  
  .btn-group {
    width: 100%;
  }
  
  .btn-group .btn {
    margin-bottom: 0.5rem;
  }
  
  .btn-group .btn:last-child {
    margin-bottom: 0;
  }
  
  /* Mobile form optimization */
  .form-container {
    max-width: 100%;
  }
  
  .form-control {
    font-size: 16px; /* Prevents zoom on iOS */
    min-height: 44px;
  }
  
  select.form-control {
    padding-right: 2rem; /* Space for dropdown arrow */
  }
  
  .form-actions {
    flex-direction: column;
    width: 100%;
  }
  
  .form-actions .btn {
    margin-bottom: 0.5rem;
  }
  
  .form-actions .btn:last-child {
    margin-bottom: 0;
  }
  
  /* Mobile navigation links */
  .nav-link {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }
  
  .nav-item:last-child .nav-link {
    border-bottom: none;
  }
  
  /* Adjust page title on mobile */
  .page-title {
    font-size: 1.5rem;
  }
}

/* Search Section - Common styles for all admin search forms */
.search-section {
  margin-bottom: 2rem;
  background: #f8f9fa;
  padding: 1.5rem;
  border-radius: 8px;
}

.search-form {
  width: 100%;
}

.search-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.search-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.search-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #333;
}

.search-input {
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.875rem;
  min-width: 200px;
}

.search-input-small {
  min-width: 150px;
}

.search-select {
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.875rem;
  min-width: 120px;
}

.search-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-left: auto;
}

/* Mobile search form optimization */
@media (max-width: 767px) {
  .search-section {
    padding: 1rem;
    margin: 0 -1rem 1.5rem;
    border-radius: 0;
  }
  
  .search-row {
    flex-direction: column;
    gap: 1rem;
  }
  
  .search-field {
    width: 100%;
  }
  
  .search-input,
  .search-input-small,
  .search-select {
    width: 100%;
    min-width: unset;
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  .search-actions {
    width: 100%;
    margin-left: 0;
    margin-top: 0.5rem;
  }
  
  .search-actions .btn {
    flex: 1;
  }
}

/* Author links in admin */
.author-links-admin {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.author-links-admin .link-item {
  display: flex;
  align-items: center;
  padding: 0.5rem;
  background: #f8f9fa;
  border-radius: 4px;
  border: 1px solid #e9ecef;
}

.author-links-admin .link-key {
  display: inline-block;
  min-width: 120px;
  font-weight: 500;
  color: #495057;
  margin-right: 1rem;
}

.author-links-admin .link-url {
  color: #0066cc;
  text-decoration: none;
  word-break: break-all;
  flex: 1;
}

.author-links-admin .link-url:hover {
  text-decoration: underline;
  color: #0052a3;
}

/* Status badges */
.status {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-active {
  background-color: #d4edda;
  color: #155724;
}

.status-inactive {
  background-color: #f8d7da;
  color: #721c24;
}

.status-error {
  background-color: #f8d7da;
  color: #721c24;
}

/* Form enhancements for prompts */
.form-control {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ced4da;
  border-radius: 4px;
  font-size: 0.875rem;
}

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

.form-text {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: #6c757d;
}

.form-check {
  margin-bottom: 1rem;
}

.form-check-input {
  margin-right: 0.5rem;
}

/* Detail pages */
.detail-section {
  margin-bottom: 2rem;
}

.detail-list {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 0.75rem;
}

.detail-list dt {
  font-weight: 600;
  color: #495057;
}

.detail-list dd {
  margin: 0;
  color: #212529;
}

/* Code blocks */
.code-block {
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  padding: 1rem;
  font-family: monospace;
  font-size: 0.875rem;
  overflow-x: auto;
  white-space: pre;
}

/* Empty states */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: #6c757d;
}

.empty-state p {
  margin: 0;
  font-size: 1.125rem;
}