/* Re:Beauty Photos Admin — Modern Minimal Design */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-light: #EEF2FF;
  --primary-50: #E0E7FF;
  --accent: #7C3AED;
  --danger: #DC2626;
  --danger-light: #FEF2F2;
  --warning: #F59E0B;
  --warning-light: #FFFBEB;
  --success: #059669;
  --success-light: #ECFDF5;
  --bg: #F9FAFB;
  --surface: #FFFFFF;
  --text: #111827;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --border: #E5E7EB;
  --border-light: #F3F4F6;
  --sidebar-bg: #111827;
  --sidebar-hover: #1F2937;
  --sidebar-active: #4F46E5;
  --sidebar-text: #9CA3AF;
  --sidebar-text-active: #FFFFFF;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ═══════════════ LOGIN ═══════════════ */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #111827;
  position: relative;
  overflow: hidden;
}

.login-container::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 30% 50%, rgba(79,70,229,0.15) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 50%, rgba(124,58,237,0.1) 0%, transparent 50%);
  animation: bgShift 20s ease-in-out infinite alternate;
}

@keyframes bgShift {
  0% { transform: translate(0, 0); }
  100% { transform: translate(-5%, 3%); }
}

.login-card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}

.login-logo {
  text-align: center;
  margin-bottom: 36px;
}

.login-logo h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.login-logo p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
  font-weight: 400;
}

/* ═══════════════ FORMS ═══════════════ */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  transition: all var(--transition);
  background: var(--surface);
  color: var(--text);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}

.form-group input::placeholder { color: var(--text-muted); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 400 !important;
}

.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }

.error-message {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 18px;
}

/* ═══════════════ BUTTONS ═══════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--border-light); }

.btn-danger {
  background: var(--surface);
  color: var(--danger);
  border-color: var(--border);
}
.btn-danger:hover:not(:disabled) { background: var(--danger-light); border-color: var(--danger); }

.btn-warning {
  background: var(--surface);
  color: var(--warning);
  border-color: var(--border);
}
.btn-warning:hover:not(:disabled) { background: var(--warning-light); border-color: var(--warning); }

.btn-success {
  background: var(--surface);
  color: var(--success);
  border-color: var(--border);
}
.btn-success:hover:not(:disabled) { background: var(--success-light); border-color: var(--success); }

.btn-full { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }

.btn-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  line-height: 1;
  border-radius: var(--radius);
  transition: all var(--transition);
}
.btn-close:hover { color: var(--text); background: var(--border-light); }

/* ═══════════════ ADMIN LAYOUT ═══════════════ */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* ═══════════════ SIDEBAR ═══════════════ */
.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  border-right: 1px solid rgba(255,255,255,0.06);
}

.sidebar-header {
  padding: 24px 20px 20px;
}

.sidebar-header h2 {
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-subtitle {
  font-size: 10px;
  color: var(--primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: 2px;
  display: block;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 2px;
  font-size: 13px;
  font-weight: 400;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #E5E7EB;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 500;
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.user-email, .user-info span {
  font-size: 12px;
  color: var(--sidebar-text);
  display: block;
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ═══════════════ MAIN ═══════════════ */
.main-content {
  flex: 1;
  margin-left: 220px;
  padding: 28px 32px;
  min-height: 100vh;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ═══════════════ UTILITY ═══════════════ */
.loading {
  text-align: center;
  padding: 60px 40px;
  color: var(--text-muted);
  font-size: 13px;
}

.empty-state {
  text-align: center;
  padding: 60px 40px;
  color: var(--text-muted);
  font-size: 13px;
}

.error {
  color: var(--danger);
  text-align: center;
  padding: 24px;
  font-size: 13px;
}

.result-count {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ═══════════════ DASHBOARD STATS ═══════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border);
  transition: box-shadow var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-icon {
  font-size: 20px;
  margin-bottom: 12px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  border-radius: var(--radius);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}

/* ═══════════════ DATA TABLE ═══════════════ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 24px;
}

.data-table th,
.data-table td {
  padding: 10px 16px;
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid var(--border-light);
}

.data-table th {
  background: var(--bg);
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.data-table tbody tr:hover { background: var(--border-light); }
.data-table tr:last-child td { border-bottom: none; }

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
}

.status-created { background: var(--warning-light); color: #B45309; }
.status-image_generated { background: var(--success-light); color: #065F46; }
.status-completed { background: var(--primary-light); color: var(--primary); }

/* ═══════════════ BACKGROUNDS GRID ═══════════════ */
.backgrounds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.bg-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: all var(--transition);
}

.bg-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.bg-card.inactive { opacity: 0.55; }

.bg-card-image {
  position: relative;
  height: 150px;
  background: var(--border-light);
  overflow: hidden;
}

.bg-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 300ms ease;
}

.bg-card:hover .bg-card-image img { transform: scale(1.03); }

.no-image {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 12px;
}

.bg-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 8px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.bg-badge.active { background: rgba(5,150,105,0.9); color: #fff; }
.bg-badge.inactive { background: rgba(107,114,128,0.85); color: #fff; }

.bg-card-info { padding: 14px 16px 8px; }

.bg-card-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--text);
}

.bg-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.category-tag {
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 100px;
  font-weight: 500;
  font-size: 11px;
}

.bg-card-actions {
  display: flex;
  gap: 6px;
  padding: 10px 16px 14px;
  border-top: 1px solid var(--border-light);
  margin-top: 8px;
}

/* ═══════════════ MODAL ═══════════════ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

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

.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

/* ═══════════════ IMAGE UPLOAD ═══════════════ */
.image-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  overflow: hidden;
  background: var(--bg);
}

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

.image-upload-area span {
  color: var(--text-muted);
  font-size: 13px;
}

.image-upload-area img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ═══════════════ PHOTOS ═══════════════ */
.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.filter-bar .form-group { margin-bottom: 0; min-width: 130px; }

.tab-buttons {
  display: flex;
  gap: 0;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 3px;
  border: 1px solid var(--border);
}

.tab-btn {
  padding: 7px 14px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  background: transparent;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.tab-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.photo-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: all var(--transition);
}

.photo-card:hover { box-shadow: var(--shadow-md); }

.photo-card-image {
  height: 160px;
  background: var(--border-light);
  overflow: hidden;
}

.photo-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
  transition: transform 300ms ease;
}

.photo-card:hover .photo-card-image img { transform: scale(1.03); }

.photo-card-info { padding: 10px 14px; }
.photo-card-date { font-size: 12px; color: var(--text-secondary); margin-bottom: 2px; }
.photo-card-meta { font-size: 11px; color: var(--text-muted); }

/* Dashboard recent images */
.recent-images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}

.recent-image-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  height: 110px;
  background: var(--border-light);
}

.recent-image-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.recent-image-date {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
  color: #fff;
  font-size: 10px;
}

.bg-stats-container { margin-bottom: 32px; }

/* ═══════════════ IMAGE MODAL ═══════════════ */
.image-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  cursor: pointer;
}

.image-modal-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
}

.image-modal-content img {
  max-width: 100%;
  max-height: 85vh;
  border-radius: var(--radius);
}

.image-modal-content .btn-close {
  position: absolute;
  top: -10px;
  right: -10px;
  background: #fff;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  box-shadow: var(--shadow-md);
  font-size: 16px;
}

/* ═══════════════ DASHBOARD H3 ═══════════════ */
.dashboard h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 14px;
  margin-top: 8px;
}

/* ═══════════════ PAGINATION ═══════════════ */
.pagination {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

.pagination-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}

.page-btn:hover:not(:disabled):not(.active) {
  background: var(--border-light);
  border-color: var(--text-muted);
}

.page-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.page-btn.disabled,
.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 36px;
  color: var(--text-muted);
  font-size: 14px;
}

.list-summary {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.list-summary strong {
  color: var(--text);
}

/* ═══════════════ HEADER ACTIONS ═══════════════ */
.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--transition);
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary);
}

/* ═══════════════ RESPONSIVE ═══════════════ */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { width: 56px; }

  .sidebar-header h2,
  .sidebar-subtitle,
  .nav-item span:not(.nav-icon),
  .sidebar-footer .user-email,
  .sidebar-footer .user-info span {
    display: none;
  }

  .sidebar-header { padding: 20px 10px; text-align: center; }
  .nav-item { justify-content: center; padding: 10px; }
  .main-content { margin-left: 56px; padding: 20px 16px; }
  .form-row { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .modal-content { margin: 8px; padding: 20px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
