/* Grid Gallery Styles */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 15px;
  padding: 20px;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid #dee2e6;
  border-radius: var(--border-radius);
  background: #f8f9fa;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  border: 2px solid #dee2e6;
  border-radius: var(--border-radius);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  background: white;
}

.gallery-item:hover {
  border-color: var(--primary-color);
  transform: scale(1.05);
  box-shadow: var(--shadow-lg);
}

.gallery-item.selected {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(14, 26, 223, 0.2);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 5px;
}

.gallery-item .item-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 4px;
  font-size: 10px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.gallery-item:hover .item-name {
  opacity: 1;
}

.gallery-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  background: white;
  border-top: 1px solid #dee2e6;
}

.gallery-status {
  font-size: 14px;
  color: var(--dark-color);
  font-weight: 500;
}

.gallery-upload-container {
  border: 1px solid #dee2e6;
  border-radius: var(--border-radius);
  padding: 15px;
  background: #f8f9fa;
}

.gallery-images-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 10px;
  margin-bottom: 15px;
  min-height: 60px;
  padding: 10px;
  background: white;
  border: 1px solid #e9ecef;
  border-radius: 4px;
}

.gallery-image-item {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
}

.gallery-image-item:hover {
  border-color: var(--primary-color);
  transform: scale(1.05);
}

.gallery-image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-image-item .remove-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(220, 53, 69, 0.9);
  color: white;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 10px;
  cursor: pointer;
  display: none;
}

.gallery-image-item:hover .remove-btn {
  display: block;
}

.gallery-info {
  margin-top: 10px;
  color: #6c757d;
  font-size: 12px;
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #0e1adf;
  --secondary-color: #161717;
  --success-color: #28a745;
  --danger-color: #dc3545;
  --warning-color: #ffc107;
  --info-color: #17a2b8;
  --light-color: #f8f9fa;
  --dark-color: #343a40;
  --border-radius: 8px;
  --transition: all 0.3s ease;
  --shadow: 0 2px 4px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 8px rgba(0,0,0,0.15);
  --border-color: #dee2e6;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--light-color);
  color: var(--dark-color);
  line-height: 1.6;
}

/* Admin Layout */
#adminApp {
  display: flex;
  min-height: 100vh;
}

/* Header */
.admin-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: white;
  border-bottom: 1px solid var(--border-color);
  z-index: 1000;
  display: flex;
  align-items: center;
  padding: 0 20px;
  box-shadow: var(--shadow);
}

.admin-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.admin-nav h1 {
  font-size: 1.5rem;
  color: var(--primary-color);
  font-weight: 600;
}

.admin-user {
  display: flex;
  align-items: center;
  gap: 15px;
}

.logout-btn {
  background: var(--danger-color);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.logout-btn:hover {
  background: #c82333;
}

/* Sidebar */
.admin-sidebar {
  position: fixed;
  top: 60px;
  left: 0;
  width: 250px;
  height: calc(100vh - 60px);
  background: white;
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
}

.sidebar-nav ul {
  list-style: none;
  padding: 20px 0;
}

.sidebar-nav li {
  margin-bottom: 5px;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: var(--dark-color);
  text-decoration: none;
  transition: all 0.3s ease;
  gap: 10px;
}

.nav-link:hover {
  background: var(--light-color);
  color: var(--primary-color);
}

.nav-link.active {
  background: var(--primary-color);
  color: white;
}

/* Main Content */
.admin-main {
  margin-left: 250px;
  margin-top: 60px;
  padding: 30px;
  flex: 1;
  min-height: calc(100vh - 60px);
}

.admin-section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.admin-section.active {
  display: block;
}

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

/* Section Header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 15px;
  border-bottom: 2px solid var(--border-color);
}

.section-header h2 {
  font-size: 2rem;
  color: var(--dark-color);
  font-weight: 600;
}

.section-header p {
  color: #6c757d;
  margin-top: 5px;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.btn-primary:hover {
  background: #e55a2b;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

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

.btn-success:hover {
  background: #218838;
}

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

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

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

.btn-info:hover {
  background: #138496;
}

/* Dashboard Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 15px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}

.stat-icon {
  font-size: 2rem;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--light-color);
  border-radius: 50%;
}

.stat-info h3 {
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--dark-color);
}

.stat-info p {
  color: #6c757d;
  font-size: 0.9rem;
}

/* Activity Log */
.recent-activity {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.recent-activity h3 {
  margin-bottom: 15px;
  color: var(--dark-color);
}

.activity-list {
  max-height: 200px;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-time {
  color: #6c757d;
  font-size: 0.85rem;
}

.activity-text {
  color: var(--dark-color);
}

/* Characters Grid */
.characters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.character-card {
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  text-align: center;
  transition: var(--transition);
  cursor: move;
  position: relative;
}

.character-card.dragging {
  opacity: 0.5;
  transform: rotate(5deg);
}

.drag-handle {
  position: absolute;
  top: 10px;
  left: 10px;
  color: var(--primary-color);
  font-size: 20px;
  cursor: move;
  padding: 5px;
  border-radius: 4px;
  transition: var(--transition);
}

.drag-handle:hover {
  background: var(--light-color);
}

.character-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-color);
}

.character-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.character-name {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--dark-color);
}

.character-actions {
  display: flex;
  gap: 10px;
}

.character-actions button {
  padding: 5px 10px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: background-color 0.3s ease;
}

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

.edit-btn:hover {
  background: #138496;
}

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

.delete-btn:hover {
  background: #c82333;
}

.character-description {
  color: #6c757d;
  margin-bottom: 10px;
}

.character-story {
  font-size: 0.9rem;
  color: var(--dark-color);
  line-height: 1.4;
}

/* Gallery Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
}

.gallery-item {
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-item:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}

.gallery-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.gallery-info {
  padding: 15px;
}

.gallery-title {
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--dark-color);
}

.gallery-description {
  font-size: 0.9rem;
  color: #6c757d;
  margin-bottom: 10px;
}

.gallery-actions {
  display: flex;
  gap: 10px;
}

/* Content Editor */
.content-editor {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.editor-tabs {
  display: flex;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 20px;
}

.tab-btn {
  padding: 12px 20px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #6c757d;
  border-bottom: 2px solid transparent;
  transition: all 0.3s ease;
}

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

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

.tab-content {
  display: none;
}

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

.tab-content h3 {
  margin-bottom: 20px;
  color: var(--dark-color);
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  color: var(--dark-color);
}

.form-input,
.form-textarea,
.form-color {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 14px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-input:focus,
.form-textarea:focus,
.form-color:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

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

.form-color {
  height: 40px;
  cursor: pointer;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

/* Settings Form */
.settings-form {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 600px;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  margin: 0;
  color: var(--dark-color);
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #6c757d;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.3s ease;
}

.modal-close:hover {
  background: var(--light-color);
}

.modal-body {
  padding: 20px;
}

/* Image Gallery Styles */
.image-upload-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-gallery {
  background: var(--info-color);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-gallery:hover {
  background: #138496;
}

.image-preview {
  margin-top: 10px;
  position: relative;
  display: inline-block;
}

.image-preview img {
  max-width: 200px;
  max-height: 200px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

.btn-remove {
  position: absolute;
  top: -10px;
  right: -10px;
  background: var(--danger-color);
  color: white;
  border: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
}

/* Gallery Modal */
.modal-content.large {
  max-width: 900px;
  width: 90%;
}

.gallery-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.tab-btn {
  background: none;
  border: none;
  padding: 12px 24px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}

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

.tab-content {
  display: none;
}

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

/* Upload Area */
.upload-area {
  border: 2px dashed var(--border-color);
  border-radius: var(--border-radius);
  padding: 40px;
  text-align: center;
  transition: var(--transition);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-area.drag-over {
  border-color: var(--primary-color);
  background: rgba(14, 26, 223, 0.05);
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.upload-icon {
  font-size: 48px;
  opacity: 0.5;
}

/* Media Library */
.media-search {
  margin-bottom: 20px;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 15px;
  max-height: 400px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
}

.media-item {
  position: relative;
  border-radius: var(--border-radius);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
}

.media-item:hover {
  transform: scale(1.05);
}

.media-item img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: var(--border-radius);
}

.media-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 8px;
  opacity: 0;
  transition: var(--transition);
}

.media-item:hover .media-overlay {
  opacity: 1;
}

.media-name {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 5px;
}

.btn-select {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 4px 8px;
  border-radius: 3px;
  font-size: 11px;
  cursor: pointer;
  width: 100%;
}

.btn-select:hover {
  background: #0a16b8;
}

/* URL Input */
.url-input-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 500px;
}

/* Responsive Design */
@media (max-width: 768px) {
  .admin-sidebar {
    width: 200px;
  }
  
  .admin-main {
    margin-left: 200px;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .characters-grid {
    grid-template-columns: 1fr;
  }
  
  .gallery-grid {
    grid-template-columns: 1fr;
  }
  
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }
}

@media (max-width: 480px) {
  .admin-sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  
  .admin-sidebar.mobile-open {
    transform: translateX(0);
  }
  
  .admin-main {
    margin-left: 0;
  }
  
  .admin-nav h1 {
    font-size: 1.2rem;
  }
  
  .modal-content {
    width: 95%;
    margin: 10px;
  }
}

/* Loading Spinner */
.spinner {
  border: 3px solid var(--light-color);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Toast Notifications */
.toast {
  position: fixed;
  top: 80px;
  right: 20px;
  padding: 15px 20px;
  border-radius: 4px;
  color: white;
  font-weight: 500;
  z-index: 3000;
  animation: slideInRight 0.3s ease;
  max-width: 300px;
}

.toast.success {
  background: var(--success-color);
}

.toast.error {
  background: var(--danger-color);
}

.toast.warning {
  background: var(--warning-color);
}

.toast.info {
  background: var(--info-color);
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
