/* =============================================
   Artifex.ai — Ultimate Creative Suite 
   Premium UI Overhaul 
   ============================================= */

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

/* ---- Custom Reset & Base ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Colors - Deep Dark Base */
  --bg-primary:    #030303;
  --bg-secondary:  rgba(15, 15, 20, 0.7);
  --bg-card:       rgba(24, 24, 32, 0.6);
  --bg-hover:      rgba(35, 35, 45, 0.6);
  
  --border:        rgba(255, 255, 255, 0.08);
  --border-light:  rgba(255, 255, 255, 0.15);

  --accent-1:      #D951A5;
  --accent-2:      #B14BF4;
  --accent-3:      #6E7BFC;
  --gradient:      linear-gradient(135deg, var(--accent-1), var(--accent-2), var(--accent-3));

  --text-primary:  #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted:    rgba(255, 255, 255, 0.45);

  --sidebar-width: 240px;
  --radius:        18px;
  --radius-sm:     10px;
  --transition:    0.3s cubic-bezier(0.19, 1, 0.22, 1);
  --glass:         blur(16px) saturate(180%);
}

html, body {
  height: 100%;
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, .ai-name {
  font-family: 'Outfit', sans-serif;
}

a {
  text-decoration: none;
  color: inherit;
  transition: var(--transition);
}

/* =============================================
   Dynamic Background Blobs
   ============================================= */
body::before, body::after {
  content: '';
  position: fixed;
  width: 50vw;
  height: 50vw;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  opacity: 0.15;
  pointer-events: none;
  animation: blob-float 20s infinite alternate ease-in-out;
}

body::before {
  top: -10vw;
  left: -5vw;
  background: radial-gradient(circle, var(--accent-1), transparent);
}

body::after {
  bottom: -10vw;
  right: -5vw;
  background: radial-gradient(circle, var(--accent-3), transparent);
  animation-delay: -10s;
}

@keyframes blob-float {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(10vw, 5vw) scale(1.1); }
}

/* =============================================
   Layout - Sidebar + Main Content
   ============================================= */

body {
  display: flex;
}

.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-secondary);
  backdrop-filter: var(--glass);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  z-index: 1000;
  transition: width var(--transition);
}

.sidebar-logo {
  padding: 32px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-name {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-nav {
  padding: 0 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 14.5px;
  position: relative;
  overflow: hidden;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  transform: translateX(4px);
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  box-shadow: inset 0 0 0 1px var(--border-light);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 25%;
  height: 50%;
  width: 3px;
  background: var(--gradient);
  border-radius: 0 4px 4px 0;
}

.nav-item-icon {
  width: 20px;
  display: flex;
  justify-content: center;
}

/* Sidebar Profile Section (New) */
.sidebar-profile {
  margin-top: auto;
  padding: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gradient);
  padding: 2px;
}

.profile-avatar-inner {
  width: 100%;
  height: 100%;
  background: #111;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
}

.profile-info { flex: 1; overflow: hidden; }
.profile-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.profile-plan { font-size: 11px; color: var(--text-muted); font-weight: 500; }

/* Main Content Area */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  position: relative;
  animation: page-fade-in 0.6s cubic-bezier(0.19, 1, 0.22, 1);
}

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

/* =============================================
   Home - Hero Banner (Refined)
   ============================================= */
.home-banner {
  height: 440px;
  position: relative;
  overflow: hidden;
  margin: 20px;
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  border: 1px solid var(--border);
}

.banner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.05);
}

.banner-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.1), rgba(3,3,3,1));
}

.banner-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 40px;
}

.banner-title {
  font-size: 64px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: #fff;
  margin-bottom: 20px;
  line-height: 1.1;
  text-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.banner-description {
  font-size: 18px;
  color: var(--text-secondary);
  max-width: 600px;
  margin-bottom: 34px;
  font-weight: 400;
}

.banner-buttons { display: flex; gap: 16px; }

.banner-button {
  padding: 14px 34px;
  border-radius: 100px;
  font-weight: 700;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: all var(--transition);
  cursor: pointer;
  background: #fff;
  color: #000;
}

.banner-button.primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 10px 30px rgba(177, 75, 244, 0.4);
}

.banner-button:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 15px 40px rgba(0,0,0,0.4);
}

/* =============================================
   Media Grid & Cards
   ============================================= */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  padding: 40px;
}

.media-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  backdrop-filter: var(--glass);
  transition: all var(--transition);
}

.media-card:hover {
  transform: translateY(-8px);
  border-color: var(--border-light);
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

/* Masonry Variances */
.media-card:nth-child(3n) .media-card-img, 
.media-card:nth-child(3n) .media-card-video {
  aspect-ratio: 4/5;
}

.media-card-img, .media-card-video {
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  display: block;
}

.media-card-info { padding: 18px; }

.media-card-prompt {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 12px;
}

.media-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.media-type {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-2);
}

/* =============================================
   Generate Page & Form
   ============================================= */
.generation-section {
  max-width: 800px;
  margin: 60px auto;
  padding: 40px;
  background: var(--bg-card);
  border-radius: 32px;
  border: 1px solid var(--border);
  backdrop-filter: var(--glass);
  box-shadow: 0 40px 100px rgba(0,0,0,0.6);
  position: relative;
}

.generation-section::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 32px;
  padding: 1px;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent, rgba(255,255,255,0.05));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.form-group label {
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  margin-bottom: 12px;
}

.form-group textarea {
  width: 100%;
  min-height: 160px;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.6;
  resize: none;
  transition: var(--transition);
}

.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 40px rgba(177, 75, 244, 0.15);
  background: rgba(0,0,0,0.3);
}

.generate-button {
  margin-top: 24px;
  width: 100%;
  padding: 18px;
  border-radius: 100px;
  background: var(--gradient);
  color: #fff;
  border: none;
  font-weight: 700;
  font-size: 17px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 15px 40px rgba(177, 75, 244, 0.4);
}

.generate-button:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 20px 50px rgba(177, 75, 244, 0.55);
}

/* Magical Loading Portal */
.loading-animation {
  position: fixed;
  inset: 0;
  background: rgba(3, 3, 3, 0.9);
  backdrop-filter: blur(20px);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.loading-portal {
  width: 120px;
  height: 120px;
  position: relative;
  margin-bottom: 32px;
}

.loading-portal::before, .loading-portal::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 4px solid transparent;
  border-top-color: var(--accent-2);
  animation: portal-spin 2s cubic-bezier(1, 0, 0, 1) infinite;
}

.loading-portal::after {
  inset: 15px;
  border-top-color: var(--accent-1);
  animation-duration: 3s;
}

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

.loading-text {
  font-family: 'Outfit', sans-serif;
  font-size: 24px;
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* =============================================
   Result Page & Media Detail
   ============================================= */
.generation-result-container {
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 40px;
}

.generation-result {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 40px;
  overflow: hidden;
  backdrop-filter: var(--glass);
  box-shadow: 0 50px 100px rgba(0,0,0,0.5);
  margin-bottom: 60px;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

.generation-result-media {
  width: 100%;
  max-height: 600px;
  object-fit: contain;
  background: #000;
  display: block;
  border-bottom: 1px solid var(--border);
}

.media-details {
  padding: 40px;
}

.prompt-section h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-2);
  margin-bottom: 12px;
  opacity: 0.8;
}

.original-prompt, .enhanced-prompt {
  font-size: 18px;
  line-height: 1.6;
  color: var(--text-primary);
  margin-bottom: 32px;
}

.enhanced-prompt {
  padding: 24px;
  background: rgba(177, 75, 244, 0.05);
  border-radius: 20px;
  border-left: 4px solid var(--accent-1);
}

.creation-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.stat {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
}

.action-buttons {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.like-button.large {
  padding: 14px 28px;
  border-radius: 100px;
  font-size: 16px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
}

.like-button.large .like-count {
  font-size: 16px;
  font-weight: 700;
}

/* UI Utilities */

.header { padding: 40px 40px 10px; }
.header-title { font-size: 32px; font-weight: 800; }
.header-subtitle { font-size: 14px; opacity: 0.6; }

.action-btn {
  padding: 10px 24px;
  border-radius: 100px;
  font-weight: 600;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.action-btn:hover {
  background: var(--gradient);
  border-color: transparent;
  transform: translateY(-2px);
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 100px;
}

/* =============================================
   Responsive Tuning
   ============================================= */
/* =============================================
   Video Card Play Overlay
   ============================================= */
.video-card-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16/11;
  background: #0d0d0f;
  overflow: hidden;
}

.media-card-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition);
}

.play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  border-radius: 50%;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  transition: all var(--transition);
  border: 1px solid rgba(255, 255, 255, 0.15);
  pointer-events: none;
}

.media-card:hover .play-overlay {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.1);
  background: var(--gradient);
  border-color: transparent;
}

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

@media (max-width: 1024px) {
  :root { --sidebar-width: 80px; }
  .ai-name, .sidebar-profile .profile-info, .sidebar-nav .nav-item span:not(.nav-item-icon) { display: none; }
  .sidebar-logo, .sidebar-profile { justify-content: center; padding: 24px 0; }
  .header, .media-grid { padding: 24px; }
  .banner-title { font-size: 40px; }
}

/* =============================================
   Mobile Bottom Navigation
   ============================================= */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 55px;
  background: var(--bg-secondary);
  backdrop-filter: var(--glass);
  border-top: 1px solid var(--border-light);
  z-index: 2000;
  padding: 0 10px;
  padding-bottom: env(safe-area-inset-bottom);
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 10px;
  font-weight: 500;
  transition: all var(--transition);
}

.mobile-nav-item.active {
  color: var(--accent-1);
}

.mobile-nav-item svg {
  transition: transform var(--transition);
}

.mobile-nav-item.active svg {
  transform: translateY(-2px);
  filter: drop-shadow(0 4px 8px rgba(217, 81, 165, 0.4));
}

@media (max-width: 640px) {
  .sidebar { display: none; }
  .mobile-bottom-nav { display: flex; }
  .main-content { 
    margin-left: 0; 
    padding-bottom: calc(55px + env(safe-area-inset-bottom)); 
  }
  .media-grid { grid-template-columns: 1fr; }
  .generation-section { margin: 15px; padding: 20px; }
  .header { margin-top: 10px; padding: 15px; }
  
  /* Banner Fixes */
  .home-banner { height: auto; min-height: 380px; margin: 15px; border-radius: 20px; }
  .banner-content { padding: 30px 20px; }
  .banner-title { font-size: 32px; margin-bottom: 15px; }
  .banner-description { font-size: 15px; margin-bottom: 25px; }
  .banner-buttons { flex-direction: column; width: 100%; gap: 12px; }
  .banner-button { width: 100%; justify-content: center; padding: 16px; }
  
  /* Empty State */
  .empty-state { margin: 0 15px 30px; padding: 50px 20px; }
  .empty-state h3 { font-size: 20px; }
  .empty-state p { font-size: 14px; }
}

/* =============================================
   Empty State
   ============================================= */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 20px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--border-light);
  border-radius: var(--radius);
  margin: 0 40px 40px;
  opacity: 0.8;
}

.empty-state h3 {
  font-size: 22px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.empty-state p {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.empty-state .action-btn {
  background: var(--bg-hover);
  border: 1px solid var(--border-light);
  padding: 10px 24px;
  border-radius: 100px;
  color: var(--text-primary);
  font-weight: 500;
  transition: all var(--transition);
}

.empty-state .action-btn:hover {
  background: var(--gradient);
  border-color: transparent;
  transform: translateY(-2px);
}

/* Generation Warning */
.generation-warning {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: rgba(255, 171, 0, 0.1);
  border: 1px solid rgba(255, 171, 0, 0.2);
  border-radius: 12px;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.warning-icon {
  color: #ffab00;
  flex-shrink: 0;
  margin-top: 2px;
}

.warning-content strong {
  display: block;
  color: #ffab00;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.25rem;
}

.warning-content p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 0;
}

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