:root {
  --primary: #8b5cf6;
  --primary-dark: #7c3aed;
  --secondary: #ec4899;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --dark: #1f2937;
  --light: #f3f4f6;
  --white: #ffffff;
  --gray: #6b7280;
  --gray-light: #d1d5db;
  --sidebar-width: 260px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: var(--dark);
}

/* ==================== LOGIN PAGE ==================== */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.auth-card {
  background: white;
  border-radius: 20px;
  padding: 3rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.auth-logo {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 1.5rem;
  text-align: center;
}

/* Auth Tabs */
.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  background: var(--light);
  padding: 0.25rem;
  border-radius: 12px;
}

.auth-tab {
  flex: 1;
  padding: 0.75rem;
  border: none;
  background: transparent;
  color: var(--gray);
  font-weight: 600;
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.3s;
}

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

.auth-tab.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Auth Form */
.auth-form {
  margin-bottom: 1rem;
}

.auth-form.hidden {
  display: none;
}

/* Form Group */
.form-group {
  margin-bottom: 1.25rem;
  text-align: left;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--dark);
  font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.875rem;
  border: 2px solid var(--gray-light);
  border-radius: 10px;
  font-size: 1rem;
  transition: border-color 0.3s;
  font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
}

.form-group input::placeholder {
  color: var(--gray-light);
}

/* ==================== BUTTONS ==================== */
.btn {
  padding: 0.875rem 1.75rem;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  gap: 0.5rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(139, 92, 246, 0.4);
}

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

.btn-secondary {
  background: var(--light);
  color: var(--dark);
}

.btn-secondary:hover {
  background: var(--gray-light);
}

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

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

.btn-full {
  width: 100%;
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* ==================== DASHBOARD LAYOUT ==================== */
#dashboardPage {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.dashboard-header {
  background: white;
  border-bottom: 1px solid var(--gray-light);
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

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

.header-right {
  display: flex;
  align-items: center;
}

.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  color: var(--gray);
  transition: all 0.2s;
}

.sidebar-toggle:hover {
  background: var(--light);
  color: var(--primary);
}

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

.user-name {
  font-weight: 600;
  color: var(--dark);
}

.dashboard-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
  width: var(--sidebar-width);
  background: white;
  border-right: 1px solid var(--gray-light);
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
  height: calc(100vh - 64px);
  overflow-y: auto;
}

.sidebar.collapsed {
  width: 0;
  overflow: hidden;
}

.sidebar-nav {
  padding: 1.5rem;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: 10px;
  color: var(--gray);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s;
  margin-bottom: 0.5rem;
}

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

.sidebar-link.active {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
}

.sidebar-link svg {
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--gray-light);
}

.instagram-status {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--light);
  border-radius: 10px;
}

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-indicator.connected {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.status-indicator.disconnected {
  background: var(--gray);
}

.status-text {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray);
}

/* ==================== MAIN CONTENT ==================== */
.dashboard-main {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
}

.content-section {
  display: none;
}

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

/* ==================== WELCOME CARD ==================== */
.welcome-card {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
  padding: 2.5rem;
  border-radius: 20px;
  margin-bottom: 2rem;
  box-shadow: 0 10px 30px rgba(139, 92, 246, 0.3);
}

.welcome-card h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.welcome-card p {
  opacity: 0.9;
  font-size: 1.1rem;
}

/* ==================== INFO GRID ==================== */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.info-card {
  background: white;
  padding: 2rem;
  border-radius: 16px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  text-align: center;
  transition: all 0.3s;
}

.info-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.info-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.info-card h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 0.5rem;
}

.info-card p {
  color: var(--gray);
}

/* ==================== CARD ==================== */
.card {
  background: white;
  border-radius: 16px;
  padding: 2rem;
  margin: 10px 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.card h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 1.5rem;
}

.card h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--dark);
}

/* Instagram Connect Card */
.connect-instagram-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.connect-instagram-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.connect-instagram-icon svg {
  color: white;
}

.connect-instagram-content h3 {
  margin-bottom: 0.25rem;
  font-size: 1.25rem;
}

.connect-instagram-content p {
  color: var(--gray);
  font-size: 0.95rem;
}

/* ==================== ACCOUNT DETAILS ==================== */
.account-details {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--light);
  border-radius: 10px;
}

.detail-label {
  font-weight: 600;
  color: var(--gray);
}

.detail-value {
  font-weight: 500;
  color: var(--dark);
}

/* ==================== BADGE ==================== */
.badge {
  display: inline-block;
  padding: 0.375rem 0.875rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 600;
}

.badge-success {
  background: #d1fae5;
  color: #065f46;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-danger {
  background: #fee2e2;
  color: #991b1b;
}

.badge-info {
  background: #dbeafe;
  color: #1e40af;
}

/* ==================== ALERTS ==================== */
.alert {
  padding: 1rem 1.5rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  border-left: 4px solid;
  animation: slideIn 0.3s ease;
}

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

.alert-success {
  background: #d1fae5;
  border-color: var(--success);
  color: #065f46;
}

.alert-error {
  background: #fee2e2;
  border-color: var(--danger);
  color: #991b1b;
}

.alert-info {
  background: #dbeafe;
  border-color: #3b82f6;
  color: #1e40af;
}

/* ==================== UTILITIES ==================== */
.hidden {
  display: none !important;
}

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

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  .dashboard-header {
    padding: 0 1rem;
  }

  .dashboard-main {
    padding: 1rem;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 64px;
    z-index: 99;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  }

  .sidebar.collapsed {
    transform: translateX(-100%);
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .welcome-card {
    padding: 2rem;
  }

  .welcome-card h1 {
    font-size: 1.5rem;
  }

  .auth-card {
    padding: 2rem;
  }
}

@media (max-width: 480px) {
  .user-name {
    display: none;
  }

  .btn-small {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }
}

/* ==================== CARD HEADER ==================== */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.card-header h2 {
  margin-bottom: 0;
}

.card-header .btn {
  gap: 0.5rem;
}

/* ==================== LOADING STATE ==================== */
.loading-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--gray);
}

.spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 1rem;
  border: 4px solid var(--gray-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.spinner-small {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 0.5rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  vertical-align: middle;
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--gray);
}

.empty-icon {
  margin-bottom: 1rem;
  color: var(--gray-light);
}

.empty-icon svg {
  width: 100%;
  height: 100%;
}

.empty-state h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 0.5rem;
}

.empty-state p {
  margin-bottom: 1.5rem;
}

/* ==================== LINK ==================== */
.link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.link:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

/* ==================== INSTAGRAM PROFILE ==================== */
.instagram-profile {
  padding: 0;
}

.profile-header {
  display: flex;
  gap: 1.5rem;
  padding: 1.5rem;
  border-bottom: 1px solid var(--gray-light);
}

.profile-avatar {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  background: var(--light);
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-avatar svg {
  color: var(--gray);
}

.profile-info {
  flex: 1;
  min-width: 0;
}

.profile-actions {
  display: flex;
  align-items: flex-start;
}

.profile-username {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 0.25rem;
}

.profile-name {
  font-size: 1rem;
  font-weight: 500;
  color: var(--gray);
  margin-bottom: 0.5rem;
}

.profile-bio {
  font-size: 0.95rem;
  color: var(--dark);
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.profile-website {
  font-size: 0.9rem;
  color: var(--primary);
  word-break: break-all;
}

.profile-website:empty {
  display: none;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--gray-light);
  border-bottom: 1px solid var(--gray-light);
}

.stat-item {
  background: white;
  padding: 0.3rem 0.6rem;
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

/* Profile Meta */
.profile-meta {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.5rem;
}

.meta-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: var(--light);
  border-radius: 8px;
}

.meta-label {
  font-weight: 600;
  color: var(--gray);
  font-size: 0.875rem;
}

.meta-value {
  font-weight: 500;
  color: var(--dark);
  font-size: 0.875rem;
}

/* ==================== MEDIA GRID ==================== */
.media-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
}

.media-item {
  position: relative;
  aspect-ratio: 1;
  background: var(--light);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s;
}

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

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

.media-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  padding: 1rem;
  color: white;
  opacity: 0;
  transition: opacity 0.2s;
}

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

.media-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
}

.media-stat {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.media-caption {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.9);
  margin-top: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Media Item Cards (for Instagram Posts Management) */
.media-item-card {
  background: white;
  border: 1px solid var(--gray-light);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

.media-item-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  transform: translateY(-4px);
}

.media-item-image {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  cursor: pointer;
}

.media-item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

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

.media-item-details {
  padding: 1rem;
}

.media-item-stats {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--dark);
}

.stat-item svg {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}

.media-item-caption {
  font-size: 0.8125rem;
  color: var(--gray);
  line-height: 1.4;
  margin-bottom: 0.75rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.4em;
  max-height: 2.4em;
}

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

.media-item-actions .btn {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.media-item-actions .btn svg {
  width: 12px;
  height: 12px;
}

/* ==================== RESPONSIVE FOR PROFILE ==================== */
@media (max-width: 768px) {
  .profile-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .profile-avatar {
    width: 100px;
    height: 100px;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .stat-value {
    font-size: 1.25rem;
  }

  .stat-label {
    font-size: 0.75rem;
  }

  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
  }

  .media-item-actions {
    flex-direction: column;
  }

  .media-item-actions .btn {
    width: 100%;
  }
}

@media (max-width: 1024px) {
  .media-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
  }
}

@media (max-width: 768px) {
  .media-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .media-item-actions {
    flex-direction: row;
  }

  .media-item-actions .btn {
    width: auto;
  }
}

@media (max-width: 480px) {
  .profile-username {
    font-size: 1.25rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-item {
    padding: 1rem;
  }

  .media-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .media-item-actions {
    flex-direction: column;
  }

  .media-item-actions .btn {
    width: 100%;
    font-size: 0.6875rem;
    padding: 0.5rem 0.625rem;
  }
}

/* ==================== IMAGE EDITOR ==================== */
.upload-area {
  border: 2px dashed var(--gray-light);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  transition: border-color 0.3s;
}

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

.upload-placeholder {
  cursor: pointer;
  color: var(--gray);
}

.upload-placeholder:hover {
  color: var(--primary);
}

.upload-placeholder svg {
  margin-bottom: 1rem;
  color: var(--gray-light);
}

.upload-placeholder h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 0.5rem;
}

.upload-placeholder p {
  font-size: 0.9rem;
}

.uploaded-image-preview {
  position: relative;
  display: inline-block;
}

.uploaded-image-preview img {
  max-width: 100%;
  max-height: 400px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.uploaded-image-preview .btn {
  position: absolute;
  top: 10px;
  right: 10px;
}

.edit-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

/* Generation Status */
.generation-status {
  text-align: center;
  padding: 2rem;
  color: var(--gray);
}

.generation-status .spinner {
  margin: 0 auto 1rem;
}

.generation-status p {
  margin: 0;
}

/* Result Card */
.result-container {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 2rem;
  align-items: start;
}

.result-image img {
  width: 100%;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.result-details {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

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

/* Caption Section */
.caption-section {
  border: 1px solid var(--gray-light);
  border-radius: 12px;
  padding: 1.5rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.section-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

.caption-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.hashtags-section {
  margin-top: 1rem;
}

.hashtags-section label {
  display: block;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 0.5rem;
}

.hashtags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.hashtag-badge {
  background: var(--light);
  color: var(--primary);
  padding: 0.375rem 0.75rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
}

/* Generation Info */
.generation-info h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 1rem;
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--gray-light);
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  font-weight: 500;
  color: var(--gray);
  font-size: 0.9rem;
}

.info-value {
  font-weight: 500;
  color: var(--dark);
  font-size: 0.9rem;
  text-align: right;
  max-width: 60%;
  word-break: break-word;
}

/* Responsive for Image Editor */
@media (max-width: 1024px) {
  .result-container {
    grid-template-columns: 1fr;
  }

  .result-details {
    order: -1;
  }
}

@media (max-width: 768px) {
  .upload-area {
    padding: 1.5rem;
  }

  .action-buttons {
    flex-direction: column;
  }

  .action-buttons .btn {
    width: 100%;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .caption-actions {
    flex-direction: column;
  }

  .caption-actions .btn {
    width: 100%;
  }

  .result-actions {
    flex-direction: column;
  }

  .result-actions .btn {
    width: 100%;
  }
}

/* ==================== SETTINGS PAGE ==================== */
.settings-section {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--gray-light);
}

.settings-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.settings-section h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 0.5rem;
}

.section-description {
  color: var(--gray);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

.settings-subsection {
  margin-top: 2rem;
  padding: 1.5rem;
  background: var(--light);
  border-radius: 12px;
}

.settings-subsection h4 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 1rem;
}

/* Background Upload */
.background-upload-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.background-preview {
  position: relative;
  display: inline-block;
  width: fit-content;
}

.background-preview img {
  max-width: 300px;
  max-height: 200px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.background-preview .btn {
  position: absolute;
  top: 10px;
  right: 10px;
}

.background-upload-placeholder {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 2rem;
  border: 2px dashed var(--gray-light);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
  color: var(--gray);
}

.background-upload-placeholder:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(139, 92, 246, 0.05);
}

.background-upload-placeholder svg {
  flex-shrink: 0;
}

/* Settings Actions */
.settings-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
}

/* Setting Toggle */
.setting-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--light);
  border-radius: 10px;
  margin-bottom: 1rem;
}

.setting-toggle:last-child {
  margin-bottom: 0;
}

.toggle-info {
  flex: 1;
}

.toggle-info label {
  display: block;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 0.25rem;
}

.toggle-info small {
  display: block;
  color: var(--gray);
  font-size: 0.875rem;
}

/* Switch Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--gray-light);
  transition: 0.3s;
  border-radius: 26px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(24px);
}

/* Templates */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.section-header h3 {
  margin: 0;
}

.templates-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.template-card {
  background: var(--light);
  border-radius: 12px;
  padding: 1.5rem;
  transition: all 0.3s;
  border: 2px solid transparent;
}

.template-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.1);
}

.template-card.is-default {
  border-color: var(--primary);
  background: rgba(139, 92, 246, 0.05);
}

.template-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.template-card-header h4 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--dark);
  word-break: break-word;
}

.template-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  background: var(--primary);
  color: white;
  font-size: 0.75rem;
  border-radius: 20px;
  font-weight: 600;
}

.template-badge-default {
  background: #10b981;
}

.template-card-body {
  margin-bottom: 1rem;
}

.template-info {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--gray);
}

.template-info-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.template-info-item svg {
  flex-shrink: 0;
  color: var(--gray);
}

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

.template-card-actions .btn {
  flex: 1;
}

/* Checkbox Group */
.checkbox-group {
  display: flex;
  gap: 2rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-weight: 500;
  color: var(--dark);
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* Modal Large */
.modal-large {
  max-width: 600px;
  width: 90%;
}

/* Required field marker */
.required {
  color: #ef4444;
}

/* Responsive for Settings */
@media (max-width: 768px) {
  .settings-actions {
    flex-direction: column;
  }

  .settings-actions .btn {
    width: 100%;
  }

  .setting-toggle {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .background-upload-placeholder {
    flex-direction: column;
    text-align: center;
  }
}

/* ==================== GALLERY PAGE ==================== */
.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.gallery-header h2 {
  margin: 0;
}

.gallery-controls {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.gallery-controls select {
  padding: 0.5rem 1rem;
  border: 1px solid var(--gray-light);
  border-radius: 8px;
  background: white;
  font-size: 0.9rem;
  cursor: pointer;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.gallery-item {
  background: white;
  border: 1px solid var(--gray-light);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s;
}

.gallery-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.gallery-item-image {
  position: relative;
  width: 100%;
  max-height: 300px;
  overflow: hidden;
  background: var(--light);
  border-radius: 12px 12px 0 0;
}

.gallery-item-image img {
  width: 100%;
  height: auto;
  max-height: 300px;
  object-fit: cover;
  display: block;
}

.gallery-item-status {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 0.375rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.gallery-item-status.completed {
  background: #d1fae5;
  color: #065f46;
}

.gallery-item-status.processing {
  background: #fef3c7;
  color: #92400e;
}

.gallery-item-status.failed {
  background: #fee2e2;
  color: #991b1b;
}

.gallery-item-details {
  padding: 1rem;
}

.gallery-item-prompt {
  font-size: 0.875rem;
  color: var(--dark);
  margin-bottom: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.gallery-item-caption {
  font-size: 0.8rem;
  color: var(--gray);
  margin-bottom: 1rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.gallery-item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--gray);
  margin-bottom: 1rem;
}

.gallery-item-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

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

.action-group.primary-actions {
  justify-content: space-between;
}

.action-group.secondary-actions {
  display: none;
  flex-wrap: wrap;
  padding: 0.75rem;
  background: var(--light);
  border-radius: 8px;
  margin-top: 0.5rem;
}

.action-group.secondary-actions.show {
  display: flex;
}

.gallery-item-actions .btn {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
}

.action-group.secondary-actions .btn {
  flex: 1 1 calc(50% - 0.25rem);
}

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

.gallery-item-actions .btn:disabled:hover {
  transform: none;
  box-shadow: none;
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
  backdrop-filter: blur(4px);
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
  display: none !important;
  opacity: 0;
}

.modal {
  background: white;
  border-radius: 16px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  position: relative;
  z-index: 10000;
}

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

.modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--gray);
  cursor: pointer;
  padding: 0.25rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s;
}

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

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  padding: 1.5rem;
  border-top: 1px solid var(--gray-light);
}

.modal-image-preview {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: 12px;
  background: var(--light);
  margin-bottom: 1.5rem;
}

/* Responsive for Gallery */
@media (max-width: 768px) {
  .gallery-header {
    flex-direction: column;
    align-items: stretch;
  }

  .gallery-controls {
    width: 100%;
    flex-direction: column;
  }

  .gallery-controls select {
    width: 100%;
  }

  .gallery-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .action-group.primary-actions {
    flex-direction: row;
  }

  .action-group.secondary-actions {
    flex-direction: column;
  }

  .action-group.secondary-actions .btn {
    flex: 1 1 100%;
  }

  .gallery-item-actions .btn {
    padding: 0.625rem 0.75rem;
  }

  .gallery-item-actions .btn svg {
    margin-right: 0.25rem;
  }
}

@media (max-width: 480px) {
  .action-group.primary-actions {
    flex-direction: column;
  }
}

/* ==================== ORDER LIKES MODAL ==================== */
.order-info {
  padding: 1rem;
  background: var(--light);
  border-radius: 8px;
  margin-bottom: 1rem;
}

.order-info p {
  margin: 0;
  color: var(--gray);
  font-size: 0.9rem;
}

.order-info strong {
  color: var(--dark);
}

/* ==================== ORDER STATUS MODAL ==================== */
.order-status-display {
  padding: 0;
}

.order-status-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gray-light);
}

.order-status-badge {
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.order-status-badge.status-pending {
  background: #fef3c7;
  color: #92400e;
}

.order-status-badge.status-processing {
  background: #dbeafe;
  color: #1e40af;
}

.order-status-badge.status-partial {
  background: #e0e7ff;
  color: #4338ca;
}

.order-status-badge.status-completed {
  background: #d1fae5;
  color: #065f46;
}

.order-status-badge.status-failed {
  background: #fee2e2;
  color: #991b1b;
}

.order-status-badge.status-cancelled {
  background: #f3f4f6;
  color: #6b7280;
}

.order-id {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray);
}

.order-status-details {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: var(--light);
  border-radius: 8px;
}

.status-label {
  font-weight: 600;
  color: var(--gray);
  font-size: 0.875rem;
}

.status-value {
  font-weight: 500;
  color: var(--dark);
  font-size: 0.875rem;
}

.status-row .link {
  font-size: 0.875rem;
}

.status-error {
  padding: 1rem;
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #991b1b;
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

.status-error strong {
  font-weight: 600;
}

.status-success {
  padding: 1rem;
  background: #d1fae5;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  color: #065f46;
  font-size: 0.875rem;
  font-weight: 500;
  margin-top: 0.5rem;
}
