/* ArtistCMS Admin - Professional Dashboard Design */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary: #64748b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  
  --bg: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --border: #e2e8f0;
  --border-focus: #cbd5e1;
  
  --text: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
}

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

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-secondary);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
}

code, pre {
  font-family: 'JetBrains Mono', monospace;
}

/* Loading Screen */
.loading {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  z-index: 9999;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Login Screen */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
  background: var(--bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  max-width: 480px;
  width: 100%;
}

.login-header {
  background: var(--text);
  color: white;
  padding: 2rem;
  text-align: center;
}

.login-header h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.login-header p {
  opacity: 0.8;
  font-size: 0.875rem;
}

.login-content {
  padding: 2.5rem;
}

.login-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.login-content > p {
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.login-info {
  margin-top: 2rem;
  padding: 1rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-text {
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
  white-space: nowrap;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

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

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

.btn-secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-focus);
}

.btn-text {
  background: transparent;
  color: var(--text-secondary);
  padding: 0.5rem;
}

.btn-text:hover {
  color: var(--text);
  background: var(--bg-tertiary);
}

#github-login-btn {
  width: 100%;
  justify-content: center;
  padding: 0.875rem;
  font-size: 1rem;
}

/* Admin Container */
.admin-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.admin-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

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

.header-divider {
  color: var(--border);
  font-weight: 300;
}

.site-select {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  min-width: 200px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
}

.site-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-left: 1rem;
  border-left: 1px solid var(--border);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
}

/* Main Content */
.admin-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-section {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-section h3 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.sidebar-help {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-bottom: 1rem;
}

/* Modules List */
.modules-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.module-item {
  padding: 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: grab;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.module-item:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-focus);
}

.module-item.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

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

.module-icon {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
}

.module-item span {
  font-size: 0.875rem;
  font-weight: 500;
}

.module-toggle {
  margin-left: auto;
  width: 40px;
  height: 22px;
  background: var(--border);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}

.module-toggle.active {
  background: var(--success);
}

.module-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.module-toggle.active::after {
  transform: translateX(18px);
}

/* Theme Controls */
.theme-controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.theme-controls label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
}

.theme-controls input[type="color"] {
  width: 48px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* Editor */
.editor {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-secondary);
}

.editor-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 3rem;
  text-align: center;
  color: var(--text-tertiary);
}

.editor-empty svg {
  margin-bottom: 1.5rem;
  opacity: 0.3;
}

.editor-empty h2 {
  color: var(--text-secondary);
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.editor-content {
  padding: 2rem;
}

/* Editor Sections */
.editor-section {
  background: var(--bg);
  border: 2px dashed transparent;
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 1.5rem;
  transition: all 0.2s;
  position: relative;
}

.editor-section:hover {
  border-color: var(--border-focus);
  box-shadow: var(--shadow);
}

.editor-section.editing {
  border-color: var(--primary);
  border-style: solid;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.section-actions {
  display: flex;
  gap: 0.5rem;
}

.section-action {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.section-action:hover {
  background: var(--bg-secondary);
  color: var(--text);
}

/* Form Controls */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.form-input,
.form-textarea,
.form-select {
  font-family: 'DM Sans', sans-serif;
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: var(--bg);
  color: var(--text);
  transition: all 0.2s;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
  font-family: 'DM Sans', sans-serif;
}

/* Image Upload */
.image-upload {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.image-upload:hover {
  border-color: var(--primary);
  background: var(--bg-secondary);
}

.image-upload.dragging {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.05);
}

.image-preview {
  margin-top: 1rem;
  max-width: 100%;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Preview Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  max-width: 1200px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

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

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.2s;
}

.modal-close:hover {
  background: var(--bg-secondary);
  color: var(--text);
}

.modal-body {
  flex: 1;
  overflow: hidden;
}

#preview-iframe {
  width: 100%;
  height: 100%;
  min-height: 600px;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
  .admin-header {
    flex-wrap: wrap;
    height: auto;
    padding: 1rem;
  }
  
  .header-divider {
    display: none;
  }
  
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  
  .admin-content {
    flex-direction: column;
  }
}
