/* ============================
   MENTRA AI — DESIGN SYSTEM
   ============================ */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,200..800;1,200..800&display=swap');

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

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #111118;
  --bg-card: rgba(255, 255, 255, 0.03);
  --bg-card-hover: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(16, 185, 129, 0.3);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #10b981;
  --accent-light: #34d399;
  --accent-dark: #059669;
  --accent-glow: rgba(16, 185, 129, 0.15);
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 80px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px rgba(16, 185, 129, 0.1);
  --transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

html {
  overflow-x: hidden;
}

body {
  font-family: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
}

::selection {
  background: rgba(16, 185, 129, 0.3);
  color: #fff;
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-light); }

/* ============================
   AUTH PAGE STYLES
   ============================ */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
  overflow: hidden;
}

.auth-bg {
  position: fixed;
  inset: 0;
  background: 
    radial-gradient(ellipse at 20% 50%, rgba(16, 185, 129, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(16, 185, 129, 0.05) 0%, transparent 40%),
    radial-gradient(ellipse at 50% 80%, rgba(99, 102, 241, 0.04) 0%, transparent 40%),
    var(--bg-primary);
  z-index: 0;
}

.auth-grid-lines {
  position: fixed;
  inset: 0;
  background-image: 
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 60px 60px;
  z-index: 0;
}

.auth-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 2.5rem;
}

.auth-logo-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 1rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(16, 185, 129, 0.3);
}

.auth-logo h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-logo p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.auth-card {
  background: var(--bg-card);
  backdrop-filter: blur(40px) saturate(150%);
  -webkit-backdrop-filter: blur(40px) saturate(150%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
}

/* Tab Switcher */
.auth-tabs {
  display: flex;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 2rem;
  border: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: 0.75rem;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
}

.auth-tab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.3);
}

.auth-tab:not(.active):hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

/* Form */
.auth-form { display: none; }
.auth-form.active { display: block; }

.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  letter-spacing: 0.03em;
}

.form-input {
  width: 100%;
  padding: 0.875rem 1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  transition: var(--transition);
  outline: none;
}

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

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: rgba(255, 255, 255, 0.06);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.875rem 1.5rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(16, 185, 129, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.form-error {
  color: var(--danger);
  font-size: 0.8rem;
  margin-top: 0.5rem;
  display: none;
}

.form-error.show {
  display: block;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.auth-footer {
  text-align: center;
  margin-top: 2rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.auth-footer a {
  color: var(--accent);
  font-weight: 600;
}

/* ============================
   APP PAGE — LAYOUT
   ============================ */
.app-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Top Bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.top-bar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.top-bar-logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.top-bar-logo h2 {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.top-bar-logo h2 span {
  color: var(--accent);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.credits-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--accent-glow);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-light);
}

.credits-badge svg {
  width: 16px;
  height: 16px;
}

.user-menu {
  position: relative;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e293b, #334155);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  transition: var(--transition);
}

.user-avatar:hover {
  border-color: var(--accent);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 100;
}

.user-dropdown.show {
  display: block;
  animation: fadeIn 0.2s ease;
}

.user-dropdown a,
.user-dropdown button {
  display: block;
  width: 100%;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}

.user-dropdown a:hover,
.user-dropdown button:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

/* Main Content */
.app-content {
  flex: 1;
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.studio-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 3rem;
}

@media (max-width: 768px) {
  .studio-grid { grid-template-columns: 1fr; }
  .top-bar { padding: 1rem; }
  .app-content { padding: 1rem; }
}

/* Upload Panel */
.panel {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  transition: var(--transition);
}

.panel:hover {
  border-color: rgba(255, 255, 255, 0.1);
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.panel-header-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-glow);
  color: var(--accent);
}

.panel-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.panel-header p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Upload Zone */
.upload-zone {
  border: 2px dashed rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.upload-zone.has-image {
  padding: 1rem;
  border-style: solid;
  border-color: var(--accent);
}

.upload-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.upload-zone h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.upload-zone p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.upload-preview {
  max-width: 100%;
  max-height: 400px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  display: none;
}

.upload-zone.has-image .upload-preview { display: block; margin: 0 auto; }
.upload-zone.has-image .upload-icon,
.upload-zone.has-image h4,
.upload-zone.has-image p { display: none; }

.upload-actions {
  margin-top: 1.5rem;
  display: flex;
  gap: 0.75rem;
}

.btn-generate {
  flex: 1;
  padding: 1rem;
  font-size: 0.95rem;
}

.btn-clear {
  padding: 1rem;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.btn-clear:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--danger);
}

/* Result Panel */
.result-area {
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.01);
  position: relative;
  overflow: hidden;
}

.result-placeholder {
  text-align: center;
  color: var(--text-muted);
}

.result-placeholder svg {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  opacity: 0.3;
}

.result-placeholder p {
  font-size: 0.85rem;
}

.result-image {
  max-width: 100%;
  max-height: 500px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  display: none;
}

.result-image.show { display: block; }

.result-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.75rem;
  display: none;
}

.result-actions.show { display: flex; }

.btn-download {
  flex: 1;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 1px solid var(--border);
  font-size: 0.85rem;
}

.btn-download:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent);
}

/* Loading Spinner */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1.5rem;
  z-index: 10;
  border-radius: var(--radius);
}

.loading-overlay.show {
  display: flex;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(16, 185, 129, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: center;
}

.loading-text span {
  color: var(--accent);
  font-weight: 600;
}

/* History Section */
.history-section {
  margin-top: 1rem;
}

.history-section h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

.history-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
}

.history-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: var(--shadow-glow);
}

.history-card img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
}

.history-card-info {
  padding: 0.75rem;
}

.history-card-info p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.history-card-status {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-done { background: rgba(16, 185, 129, 0.15); color: var(--accent); }
.status-failed { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.status-processing { background: rgba(245, 158, 11, 0.15); color: var(--warning); }

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

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

.fade-in {
  animation: fadeIn 0.6s ease forwards;
}

.slide-up {
  animation: slideUp 0.8s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

/* ============================
   TOAST NOTIFICATIONS
   ============================ */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  animation: fadeIn 0.3s ease;
  min-width: 280px;
  box-shadow: var(--shadow-md);
}

.toast-success {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--accent-light);
}

.toast-error {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 640px) {
  .auth-card { padding: 1.5rem; }
  .auth-container { max-width: 100%; }
  .panel { padding: 1.25rem; }
  .upload-zone { padding: 2rem 1rem; }
  .history-grid { grid-template-columns: repeat(2, 1fr); }
}
