/* ==========================================================================
   VIVY AI — styles.css
   Premium purple gradient theme with glassmorphism, mobile-first responsive
   layout, dark/light mode via CSS variables + [data-theme].
   ========================================================================== */

/* -----------------------------  ROOT VARIABLES  ----------------------------- */
:root[data-theme="dark"] {
  --bg: #0f0a1f;
  --bg-secondary: #171029;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-solid: #1c1533;
  --border: rgba(255, 255, 255, 0.1);
  --text: #f3f0fb;
  --text-muted: #b6aed1;
  --primary: #8b5cf6;
  --primary-2: #a855f7;
  --primary-3: #6d28d9;
  --accent: #c084fc;
  --success: #34d399;
  --error: #f87171;
  --warning: #fbbf24;
  --info: #60a5fa;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

:root[data-theme="light"] {
  --bg: #f6f4fc;
  --bg-secondary: #ffffff;
  --surface: rgba(255, 255, 255, 0.7);
  --surface-solid: #ffffff;
  --border: rgba(109, 40, 217, 0.12);
  --text: #241a3d;
  --text-muted: #6a6083;
  --primary: #7c3aed;
  --primary-2: #9333ea;
  --primary-3: #5b21b6;
  --accent: #a855f7;
  --success: #059669;
  --error: #dc2626;
  --warning: #d97706;
  --info: #2563eb;
  --shadow: 0 8px 24px rgba(124, 58, 237, 0.12);
}

/* -----------------------------  RESET  --------------------------------------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 76px; /* space for mobile bottom nav */
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
img { max-width: 100%; display: block; }
::selection { background: var(--primary); color: #fff; }

/* Background gradient glow */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 15% 10%, rgba(139, 92, 246, 0.25), transparent 45%),
    radial-gradient(circle at 85% 90%, rgba(168, 85, 247, 0.2), transparent 45%);
  pointer-events: none;
  z-index: 0;
}

/* -----------------------------  TYPOGRAPHY  ----------------------------------- */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.25; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.1rem; } h4 { font-size: 1rem; }
p { color: var(--text-muted); line-height: 1.6; }
.gradient-text {
  background: linear-gradient(135deg, var(--primary-2), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* -----------------------------  LAYOUT  --------------------------------------- */
.page { position: relative; z-index: 1; max-width: 480px; margin: 0 auto; padding: 20px 18px 24px; }
.app-shell { display: flex; min-height: 100vh; }
.main-content { flex: 1; min-width: 0; }

@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .page { max-width: 760px; padding: 32px 40px; }
  .app-shell .page { max-width: none; }
}

/* -----------------------------  GLASS CARD  ------------------------------------ */
.glass-card {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.card { background: var(--surface-solid); border: 1px solid var(--border); border-radius: 18px; padding: 18px; box-shadow: var(--shadow); }

/* -----------------------------  BUTTONS  --------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 14px; padding: 14px 20px; font-weight: 600; font-size: 0.95rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  width: 100%;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4); }
.btn-primary:hover { box-shadow: 0 8px 26px rgba(139, 92, 246, 0.55); }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-google { background: var(--surface-solid); color: var(--text); border: 1.5px solid var(--border); }
.btn-danger { background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff; }
.btn-sm { padding: 8px 14px; font-size: 0.82rem; width: auto; border-radius: 10px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); color: var(--text); flex-shrink: 0; }

/* -----------------------------  FORMS  ------------------------------------------ */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }
.form-input, .form-textarea, .form-select {
  width: 100%; padding: 14px 16px; border-radius: 14px; border: 1.5px solid var(--border);
  background: var(--surface-solid); color: var(--text); font-size: 0.95rem; outline: none;
  transition: border-color 0.15s ease;
}
.form-input:focus, .form-textarea:focus, .form-select:focus { border-color: var(--primary); }
.form-textarea { resize: vertical; min-height: 120px; }
.form-check { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text-muted); }
.field-error { color: var(--error); font-size: 0.78rem; margin-top: 5px; display: none; }
.input-wrap { position: relative; }
.input-wrap .material-icons { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); cursor: pointer; font-size: 20px; }

/* -----------------------------  AUTH SCREENS  ------------------------------------ */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.auth-box { width: 100%; max-width: 400px; padding: 32px 26px; }
.auth-logo { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 22px; }
.auth-logo .logo-mark { width: 44px; height: 44px; border-radius: 14px; background: linear-gradient(135deg, var(--primary), var(--accent)); display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; font-size: 1.2rem; }
.auth-divider { display: flex; align-items: center; gap: 10px; margin: 18px 0; color: var(--text-muted); font-size: 0.8rem; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-footer { text-align: center; margin-top: 18px; font-size: 0.88rem; color: var(--text-muted); }

/* -----------------------------  TOP HEADER  -------------------------------------- */
.top-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.top-header h1 { font-size: 1.3rem; }
.header-actions { display: flex; gap: 10px; }

/* -----------------------------  NOTIFICATIONS / TOASTS  --------------------------- */
#notification-container { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 10px; width: min(92vw, 380px); }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-radius: 14px;
  background: var(--surface-solid); border: 1px solid var(--border); box-shadow: var(--shadow);
  animation: slideDown 0.25s ease; font-size: 0.88rem;
}
.toast-hide { animation: slideUp 0.3s ease forwards; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { to { opacity: 0; transform: translateY(-14px); } }
.toast-icon { font-size: 20px; }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--error); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--info); }
.toast-message { flex: 1; }
.toast-close { background: none; border: none; color: var(--text-muted); font-size: 1.1rem; }

/* -----------------------------  DASHBOARD  ---------------------------------------- */
.profile-card { display: flex; align-items: center; gap: 14px; padding: 20px; margin-bottom: 18px; }
.avatar { width: 58px; height: 58px; border-radius: 16px; object-fit: cover; background: linear-gradient(135deg, var(--primary), var(--accent)); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 1.3rem; flex-shrink: 0; }
.plan-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 700; margin-top: 4px; }
.plan-free { background: rgba(96, 165, 250, 0.15); color: var(--info); }
.plan-premium { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #1c1533; }
.usage-bar-track { height: 8px; border-radius: 8px; background: var(--surface); overflow: hidden; margin-top: 6px; }
.usage-bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 8px; transition: width 0.4s ease; }

.quick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 18px; }
@media (min-width: 640px) { .quick-grid { grid-template-columns: repeat(4, 1fr); } }
.quick-card {
  padding: 18px 14px; text-align: left; display: flex; flex-direction: column; gap: 10px;
  transition: transform 0.15s ease;
}
.quick-card:active { transform: scale(0.96); }
.quick-card .qc-icon { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }
.quick-card .qc-title { font-weight: 600; font-size: 0.88rem; }

.ad-banner { padding: 14px; text-align: center; font-size: 0.8rem; color: var(--text-muted); border: 1.5px dashed var(--border); border-radius: 16px; margin-top: 18px; background: var(--surface); }

/* -----------------------------  BOTTOM NAV (mobile)  ------------------------------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  display: flex; justify-content: space-around; align-items: center;
  background: var(--surface-solid); border-top: 1px solid var(--border);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  backdrop-filter: blur(16px);
}
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 0.62rem; color: var(--text-muted); padding: 4px 8px; border-radius: 10px; }
.bottom-nav a.active { color: var(--primary); }
.bottom-nav a .material-icons { font-size: 22px; }
@media (min-width: 900px) { .bottom-nav { display: none; } }

/* -----------------------------  SIDEBAR (desktop)  ---------------------------------- */
.sidebar {
  display: none; width: 240px; flex-shrink: 0; padding: 24px 16px; border-right: 1px solid var(--border);
  background: var(--surface-solid); min-height: 100vh; position: sticky; top: 0;
}
@media (min-width: 900px) { .sidebar { display: flex; flex-direction: column; gap: 6px; } }
.sidebar-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; padding: 0 6px; }
.sidebar a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; color: var(--text-muted); font-weight: 500; font-size: 0.9rem; }
.sidebar a.active, .sidebar a:hover { background: var(--surface); color: var(--primary); }
.sidebar a .material-icons { font-size: 20px; }

/* -----------------------------  CHAT  ------------------------------------------------ */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 76px); max-width: 720px; margin: 0 auto; }
@media (min-width: 900px) { .chat-wrap { height: 100vh; } }
.chat-header { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--surface-solid); }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 84%; padding: 12px 16px; border-radius: 18px; font-size: 0.92rem; line-height: 1.55; position: relative; }
.msg-user { align-self: flex-end; background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; border-bottom-right-radius: 4px; }
.msg-ai { align-self: flex-start; background: var(--surface-solid); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg-actions { display: flex; gap: 6px; margin-top: 6px; opacity: 0.75; }
.msg-actions button { background: none; border: none; color: var(--text-muted); font-size: 0.72rem; display: flex; align-items: center; gap: 3px; }
.msg-actions .material-icons { font-size: 15px; }
.typing-dots { display: inline-flex; gap: 4px; align-items: center; }
.typing-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); animation: bounce 1.2s infinite ease-in-out; }
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-5px); opacity: 1; } }

.chat-input-bar { display: flex; align-items: flex-end; gap: 8px; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--surface-solid); }
.chat-input-bar textarea { flex: 1; resize: none; max-height: 120px; border-radius: 16px; border: 1.5px solid var(--border); background: var(--bg); color: var(--text); padding: 12px 14px; font-size: 0.9rem; outline: none; }
.send-btn { width: 44px; height: 44px; border-radius: 14px; background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; border: none; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.send-btn:disabled { opacity: 0.5; }
.code-block { background: #0d0818; color: #d8d0f2; padding: 12px 14px; border-radius: 10px; overflow-x: auto; font-size: 0.82rem; font-family: "Courier New", monospace; margin: 8px 0; }
code { background: rgba(139, 92, 246, 0.15); padding: 2px 6px; border-radius: 6px; font-size: 0.85em; }

/* -----------------------------  TABS  -------------------------------------------------- */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab-btn { flex-shrink: 0; padding: 9px 16px; border-radius: 12px; background: var(--surface-solid); border: 1px solid var(--border); color: var(--text-muted); font-size: 0.82rem; font-weight: 600; white-space: nowrap; }
.tab-btn.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; border-color: transparent; }

/* -----------------------------  RESULT BOX  --------------------------------------------- */
.result-box { padding: 18px; margin-top: 16px; font-size: 0.9rem; line-height: 1.6; min-height: 80px; }
.result-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* -----------------------------  SKELETON LOADING  ---------------------------------------- */
.skeleton { background: linear-gradient(90deg, var(--surface) 25%, rgba(255,255,255,0.12) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 10px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-line { height: 14px; margin-bottom: 8px; }
.skeleton-card { height: 90px; border-radius: 18px; }

/* -----------------------------  SPLASH LOADER  ---------------------------------------------- */
.splash { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: var(--bg); z-index: 9999; }
.splash .logo-mark { width: 80px; height: 80px; border-radius: 24px; font-size: 2rem; animation: pulse 1.8s infinite ease-in-out; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* -----------------------------  HISTORY LIST  -------------------------------------------------- */
.history-item { display: flex; align-items: center; gap: 12px; padding: 14px; margin-bottom: 10px; }
.history-item .hi-title { font-weight: 600; font-size: 0.9rem; }
.history-item .hi-preview { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.history-item .hi-actions { display: flex; gap: 6px; margin-left: auto; }
.pin-icon.active { color: var(--warning); }
.fav-icon.active { color: #f472b6; }

/* -----------------------------  SETTINGS  -------------------------------------------------- */
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 16px 4px; border-bottom: 1px solid var(--border); }
.settings-row:last-child { border-bottom: none; }
.settings-row .sr-label { display: flex; align-items: center; gap: 12px; font-size: 0.92rem; }
.switch { position: relative; width: 46px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider-toggle { position: absolute; inset: 0; background: var(--border); border-radius: 20px; transition: 0.2s; cursor: pointer; }
.slider-toggle::before { content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.2s; }
input:checked + .slider-toggle { background: var(--primary); }
input:checked + .slider-toggle::before { transform: translateX(20px); }

/* -----------------------------  IMAGE UPLOAD  -------------------------------------------------- */
.upload-zone { border: 2px dashed var(--border); border-radius: 18px; padding: 30px 16px; text-align: center; cursor: pointer; transition: border-color 0.2s ease; }
.upload-zone:hover, .upload-zone.dragover { border-color: var(--primary); }
.upload-preview { max-height: 220px; border-radius: 14px; margin: 0 auto; }

/* -----------------------------  UTILS  -------------------------------------------------- */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.82rem; }
.text-center { text-align: center; }
.w-full { width: 100%; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state .material-icons { font-size: 48px; opacity: 0.4; margin-bottom: 10px; }
