@import url('tokens.css');

/* =========================================
   Base Reset & Defaults
   ========================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
/* Allow natural page height + page-level scrolling */
html, body {
  height: auto;                 /* was: 100% */
  min-height: 100%;
  font-family: var(--font-family);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: var(--line-height-base);
  overflow-y: auto;             /* ensure page scrolls when content is long */
}

/* =========================================
   App Shell Layout
   ========================================= */
/* Let the shell fill at least the viewport, but grow with content */
.app-shell {
  display: flex;
  min-height: 100svh;           /* was: height: 100vh; */
  width: 100%;
  overflow: visible;            /* was: hidden; */
}

/* =========================================
   Sidebar
   ========================================= */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--space-sm) 0;
  border-right: 1px solid var(--color-divider);
}
.sidebar nav ul {
  list-style: none;
}
.sidebar nav li {
  padding: var(--space-sm) 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard);
}
.sidebar nav li:hover {
  background: var(--color-accent-soft);
}
.sidebar nav .icon {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

/* =========================================
   Main Panel
   ========================================= */
.main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0; /* allow children to size/scroll correctly */
}

/* =========================================
   Header
   ========================================= */
/* Optional: keep header visible while page scrolls */
.main-header {
  height: var(--header-height);
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
  border-bottom: 1px solid var(--color-divider);
  position: sticky;  /* added */
  top: 0;            /* added */
  z-index: 10;       /* added */
}
.logo {
  font-weight: bold;
  color: var(--color-accent);
}
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Google button (kept for sign-in) */
.btn-google {
  background: var(--color-accent);
  color: #fff;
  padding: 6px 12px;
  border-radius: var(--radius-round);
  font-size: 0.85rem;
  text-decoration: none;
  transition: background var(--duration-fast) var(--ease-standard);
}
.btn-google:hover {
  background: var(--color-accent-hover);
}

/* =========================================
   Modern Premium Action Buttons (Header)
   - Go Unli (Card)   -> .btn-pro
   - Pay with PayPal  -> .btn-pro--outline
   - Sign out         -> .btn-danger
   ========================================= */
.header-actions { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }

/* Base look */
.btn-pro,
.btn-pro--outline,
.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-round);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform var(--duration-fast) var(--ease-standard),
              box-shadow var(--duration-fast) var(--ease-standard),
              background var(--duration-fast) var(--ease-standard),
              border-color var(--duration-fast) var(--ease-standard),
              opacity var(--duration-fast) var(--ease-standard);
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
  backdrop-filter: saturate(120%) blur(6px);
  -webkit-backdrop-filter: saturate(120%) blur(6px);
}

/* Primary (Go Unli / Card) */
.btn-pro {
  background: linear-gradient(135deg, var(--color-accent) 0%, #00b4ff 100%);
  color: #fff;
}
.btn-pro:hover {
  background: linear-gradient(135deg, var(--color-accent-hover) 0%, #27c3ff 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(0, 180, 255, .35), 0 4px 14px rgba(0,0,0,.08);
}

/* Outline (PayPal) */
.btn-pro--outline {
  background: rgba(255,255,255,.06);
  color: var(--color-accent);
  border-color: var(--color-accent);
}
.btn-pro--outline:hover {
  background: var(--color-accent-soft);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0,0,0,.1);
}

/* Danger (Sign out) */
.btn-danger {
  background: linear-gradient(135deg, #ff4d4f 0%, #ff7a7c 100%);
  color: #fff;
}
.btn-danger:hover {
  background: linear-gradient(135deg, #ff6a6b 0%, #ff9a9b 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(255, 90, 90, .25), 0 4px 14px rgba(0,0,0,.08);
}

/* Focus states (accessibility) */
.btn-pro:focus-visible,
.btn-pro--outline:focus-visible,
.btn-danger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0,180,255,.35);
}

/* Optional loading state */
.is-loading { pointer-events:none; opacity:.75; }
.is-loading .spinner {
  width:16px; height:16px; border-radius:50%;
  border:2px solid rgba(255,255,255,.35); border-top-color:#fff;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Icon sizing inside buttons */
.btn-pro svg,
.btn-pro--outline svg,
.btn-danger svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

/* PRO badge */
.badge-pro {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  line-height: 1;
  background: #ffeaa7;            /* warm gold */
  color: #5a4b00;                 /* readable on gold */
  border: 1px solid #f8c291;      /* subtle border */
  box-shadow: 0 1px 0 rgba(0,0,0,.05);
}

/* Tiny helper chip (can reuse anywhere) */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--color-accent-soft);
  color: var(--color-text);
  border: 1px solid var(--color-divider);
}

/* Inline notice (e.g., limit reached) */
.notice {
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: #2a2d34;
  color: var(--color-text);
  border: 1px solid var(--color-divider);
  font-size: 0.85rem;
}

/* =========================================
   Tool Container (Shared Layout for All Tools)
   ========================================= */
.tool-container {
  flex: 1;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
  overflow: visible;            /* was: hidden; let content extend page */
  min-height: auto;             /* was: 0; avoid trapping scroll area */
}
.tool-inner {
  width: 100%;
  max-width: 1000px;            /* similar to ChatGPT */
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: auto;             /* was: 0; allow content to define height */
}

/* =========================================
   Chat UI (Shared Component)
   ========================================= */
.chat-box {
  flex: 1;
  background: var(--color-surface);
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  overflow-y: auto;             /* chat scrolls internally */
  box-shadow: var(--shadow-1);
  scrollbar-gutter: stable;     /* prevent layout shift when scrollbar appears */

  /* nicer default scrollbar (Firefox + WebKit) */
  scrollbar-width: thin;
  scrollbar-color: var(--color-divider) transparent;
}
.chat-message {
  margin-bottom: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  max-width: 80%;
  line-height: 1.5;
  white-space: pre-wrap; /* preserve newlines from text */
}
.chat-message.user {
  background: var(--color-accent-soft);
  color: var(--color-text);
  align-self: flex-end;
}
.chat-message.bot {
  background: #2a2d34;
  color: var(--color-text);
  align-self: flex-start;
}

/* =========================================
   Chat Input (Sticky at bottom)
   ========================================= */
.chat-input {
  display: flex;
  align-items: center;
  margin-top: var(--space-sm);
  padding: 12px;
  background: var(--color-surface);
  border-top: 1px solid var(--color-divider);
  border-radius: 0 0 var(--radius-md) var(--radius-md);

  position: sticky;  /* keep in view as you scroll messages */
  bottom: 0;
  z-index: 1;
}
.chat-input input {
  flex: 1;
  padding: 14px;
  border: none;
  background: var(--color-bg);
  color: var(--color-text);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  font-size: 0.95rem;
}
.chat-input input:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--color-accent);
}
.chat-input button {
  padding: 14px 18px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard);
}
.chat-input button:hover {
  background: var(--color-accent-hover);
}

/* =========================================
   Scrollbar Styling (WebKit)
   ========================================= */
.chat-box::-webkit-scrollbar {
  width: 8px;
}
.chat-box::-webkit-scrollbar-thumb {
  background: var(--color-divider);
  border-radius: var(--radius-round);
}

/* =========================================
   Responsive Tweaks
   ========================================= */
@media (max-width: 900px) {
  .sidebar {
    width: 64px;
  }
  .sidebar nav li {
    font-size: 0.78rem;
  }
  .tool-container {
    padding: var(--space-sm);
  }
  .chat-message {
    max-width: 100%;
  }
  /* Stack header CTAs neatly on mobile */
  .header-actions { gap: 8px; }
  .header-actions a {
    width: 100%;
    justify-content: center;
  }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .btn-pro,
  .btn-pro--outline,
  .btn-danger,
  .btn-pro:hover,
  .btn-pro--outline:hover,
  .btn-danger:hover {
    transition: none;
    transform: none;
  }
}
