/* Admin Layout with Collapsible Sidebar */

.admin-layout {
  display: flex;
  min-height: 100vh;
  background: #f9fafb;
}

/* Sidebar */
.admin-sidebar {
  width: 26rem;
  background: #1d2327;
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  transition: transform 0.3s ease, width 0.3s ease;
  z-index: 1000;
}

.admin-sidebar-header {
  padding: 2rem;
  border-bottom: 0.1rem solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-sidebar-header h2 {
  font-size: 1.8rem;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-site-link {
  color: white;
  text-decoration: none;
  transition: opacity 0.2s;
}

.admin-site-link:hover {
  opacity: 0.8;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0.6rem;
  border-radius: 0.4rem;
  display: none;
}

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

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

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  padding: 1.2rem 2rem;
  color: #d1d5db;
  text-decoration: none;
  transition: all 0.2s;
  font-size: 1.5rem;
  font-weight: 500;
}

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

.admin-nav-item.active {
  background: rgba(59, 130, 246, 0.2);
  color: white;
  border-left: 0.3rem solid #3b82f6;
}

.admin-nav-item svg {
  flex-shrink: 0;
}

/* Submenu parent items */
.admin-nav-parent {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  padding: 1.2rem 2rem;
  color: #d1d5db;
  text-decoration: none;
  transition: all 0.2s;
  font-size: 1.5rem;
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
}

.admin-nav-parent:hover {
  background: rgba(255, 255, 255, 0.05);
  color: white;
}

.admin-nav-parent svg {
  flex-shrink: 0;
}

.admin-nav-parent .chevron {
  margin-left: auto;
  transition: transform 0.2s;
}

.admin-nav-parent.expanded .chevron {
  transform: rotate(180deg);
}

/* Submenu container */
.admin-submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background: rgba(0, 0, 0, 0.2);
}

.admin-submenu.expanded {
  max-height: 50rem;
}

/* Submenu items */
.admin-submenu-item {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  padding: 1rem 2rem 1rem 5.2rem;
  color: #d1d5db;
  text-decoration: none;
  transition: all 0.2s;
  font-size: 1.4rem;
  font-weight: 400;
}

.admin-submenu-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: white;
}

.admin-submenu-item.active {
  background: rgba(59, 130, 246, 0.2);
  color: white;
  border-left: 0.3rem solid #3b82f6;
}

.admin-submenu-item svg {
  flex-shrink: 0;
  width: 1.8rem;
  height: 1.8rem;
}

/* Placeholder items (not yet implemented) */
.admin-nav-item-placeholder,
.admin-submenu-item-placeholder {
  color: #f59e0b;
  opacity: 0.7;
}

.admin-nav-item-placeholder:hover,
.admin-submenu-item-placeholder:hover {
  color: #fbbf24;
  opacity: 1;
  cursor: not-allowed;
}

/* Sidebar Footer */
.admin-sidebar-footer {
  border-top: 0.1rem solid rgba(255, 255, 255, 0.1);
  padding: 1.5rem;
}

.admin-user-info {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  margin-bottom: 1rem;
}

.admin-user-avatar {
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  background: #3b82f6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.6rem;
  flex-shrink: 0;
}

.admin-user-details {
  flex: 1;
  min-width: 0;
}

.admin-user-email {
  font-size: 1.4rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-user-role {
  font-size: 1.2rem;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-logout {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 1.2rem;
  color: #d1d5db;
  text-decoration: none;
  border-radius: 0.4rem;
  font-size: 1.4rem;
  transition: all 0.2s;
}

.admin-logout svg {
  flex-shrink: 0;
}

.admin-logout:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
}

/* Mobile overlay */
.admin-sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  display: none;
}

.admin-sidebar-overlay.active {
  display: block;
}

/* Main content */
.admin-main {
  flex: 1;
  margin-left: 26rem;
  transition: margin-left 0.3s ease;
}

.admin-mobile-header {
  display: none;
  align-items: center;
  gap: 1.5rem;
  padding: 1.5rem 2rem;
  background: white;
  border-bottom: 0.1rem solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 100;
}

.sidebar-toggle-mobile {
  background: none;
  border: none;
  color: #374151;
  cursor: pointer;
  padding: 0.6rem;
  border-radius: 0.4rem;
}

.sidebar-toggle-mobile:hover {
  background: #f3f4f6;
}

.admin-mobile-header h1 {
  font-size: 1.8rem;
  margin: 0;
  font-weight: 600;
}

/* Flash messages */
.admin-flash {
  padding: 1.5rem 2rem;
  margin: 2rem;
  border-radius: 0.6rem;
  font-size: 1.4rem;
  font-weight: 500;
}

.admin-flash-notice {
  background: #d1fae5;
  color: #065f46;
  border: 0.1rem solid #a7f3d0;
}

.admin-flash-alert {
  background: #fee2e2;
  color: #991b1b;
  border: 0.1rem solid #fecaca;
}

/* Desktop collapsed state */
@media (min-width: 1024px) {
  .sidebar-toggle {
    display: block;
  }

  .admin-sidebar.collapsed {
    width: 7rem;
  }

  .admin-sidebar.collapsed .admin-sidebar-header h2,
  .admin-sidebar.collapsed .admin-nav-item span,
  .admin-sidebar.collapsed .admin-nav-parent span,
  .admin-sidebar.collapsed .admin-nav-parent .chevron,
  .admin-sidebar.collapsed .admin-user-details,
  .admin-sidebar.collapsed .admin-logout span {
    opacity: 0;
    width: 0;
    overflow: hidden;
  }

  .admin-sidebar.collapsed .admin-nav-item {
    justify-content: center;
  }

  .admin-sidebar.collapsed .admin-nav-parent {
    justify-content: center;
  }

  .admin-sidebar.collapsed .admin-submenu {
    display: none;
  }

  .admin-sidebar.collapsed .admin-logout {
    justify-content: center;
  }

  .admin-main {
    transition: margin-left 0.3s ease;
  }

  .admin-sidebar.collapsed ~ .admin-main {
    margin-left: 7rem;
  }
}

/* Mobile responsive */
@media (max-width: 1023px) {
  .admin-sidebar {
    transform: translateX(-100%);
  }

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

  .admin-main {
    margin-left: 0;
    width: 100%;
  }

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

/* Mobile - Stack image previews */
@media (max-width: 767px) {
  .image-upload-group {
    flex-direction: column;
    align-items: center;
  }

  .image-preview-container {
    margin-bottom: 1.5rem;
  }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 1023px) {
  .admin-mobile-header h1 {
    font-size: 2rem;
  }
}

/* Image Preview Components */
.image-preview-container {
  width: 12rem;
  height: 12rem;
  border: 0.1rem solid #d1d5db;
  border-radius: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.image-preview-placeholder {
  color: #d1d5db;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.image-preview-placeholder svg {
  width: 5rem;
  height: 5rem;
}

.image-preview-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
}

.image-upload-group {
  display: flex;
  align-items: start;
  gap: 2rem;
}

/* Image preview remove button */
.image-preview-remove {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(220, 38, 38, 0.9);
  color: white;
  border: none;
  border-radius: 0.4rem;
  width: 2.8rem;
  height: 2.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  padding: 0;
}

.image-preview-removable:hover .image-preview-remove {
  opacity: 1;
}

.image-preview-remove:hover {
  background: rgba(185, 28, 28, 1);
}

.image-preview-remove svg {
  flex-shrink: 0;
}

/* Media Picker Modal */
.media-picker-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  align-items: center;
  justify-content: center;
}

.media-picker-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
}

.media-picker-content {
  position: relative;
  background: white;
  border-radius: 0.8rem;
  width: 90%;
  max-width: 900px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2rem 2.5rem rgba(0, 0, 0, 0.3);
}

.media-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2rem;
  border-bottom: 0.1rem solid #e5e7eb;
}

.media-picker-header h2 {
  margin: 0;
  font-size: 2rem;
  font-weight: 600;
}

.media-picker-close {
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  color: #6b7280;
  border-radius: 0.4rem;
  transition: all 0.2s;
}

.media-picker-close:hover {
  background: #f3f4f6;
  color: #1f2937;
}

.media-picker-search {
  padding: 2rem;
  border-bottom: 0.1rem solid #e5e7eb;
}

.media-picker-grid {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1.5rem;
  align-content: start;
}

.media-picker-item {
  cursor: pointer;
  border: 0.2rem solid transparent;
  border-radius: 0.6rem;
  overflow: hidden;
  transition: all 0.2s;
  background: #f9fafb;
}

.media-picker-item:hover {
  border-color: #3b82f6;
  box-shadow: 0 0.4rem 0.6rem rgba(59, 130, 246, 0.1);
}

.media-picker-item img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
}

.media-picker-item-title {
  padding: 0.8rem;
  font-size: 1.2rem;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-picker-pagination {
  padding: 2rem;
  border-top: 0.1rem solid #e5e7eb;
}

.pagination-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2rem;
}

.pagination-info {
  font-size: 1.4rem;
  color: #6b7280;
}

.media-picker-loading,
.media-picker-empty,
.media-picker-error {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  font-size: 1.6rem;
  color: #6b7280;
}

.media-picker-error {
  color: #dc2626;
}
