/* Cre8 — Base Styles */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Noto+Sans+Myanmar:wght@400;500;600;700&display=swap');

/* === RESET === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-main);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  transition: background var(--transition-base), color var(--transition-base);
  -webkit-font-smoothing: antialiased;
}

/* ========================================
   MOBILE LAYOUT (default)
   ======================================== */
#app {
  max-width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  display: flex;
  flex-direction: column;
}

.sidebar { display: none; }

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

.page {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
  padding: var(--space-lg);
  padding-bottom: 80px;
  display: none;
}

.page.active { display: flex; }


/* ========================================
   TABLET (480-767px) — centered mobile
   ======================================== */
@media (min-width: 480px) {
  .main-content {
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
  }
}


/* ========================================
   DESKTOP (768px+) — sidebar + content
   ======================================== */
@media (min-width: 768px) {
  #app {
    flex-direction: row;
    max-width: 100%;
  }
  
  /* Show sidebar, hide bottom nav */
  .sidebar { display: none; }
  .bottom-nav { display: none !important; }

  body.app-authenticated .sidebar { display: flex; }
  
  .main-content {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    margin: 0;
    min-height: 100vh;
    padding: 0 24px;
    overflow-x: hidden;
  }

  body.app-authenticated .main-content {
    margin-left: 240px;
    transition: margin-left 0.25s ease;
  }

  body.app-authenticated #app:has(.sidebar.collapsed) .main-content {
    margin-left: 64px;
  }
  
  .page {
    padding: 24px 0;
    padding-bottom: var(--space-xl);
    min-width: 0;
    max-width: none;
    margin: 0;
    width: 100%;
    overflow-x: hidden;
  }

  body:not(.app-authenticated) .main-content {
    padding: 0 24px;
  }
  
  /* Chat page takes full height on desktop */
  .chat-page {
    height: 100vh;
    width: min(100%, 1240px);
    max-width: 1240px;
    margin: 0 auto;
  }
  
  .login-page {
    margin: 0 auto;
  }
  
  .onboarding-page {
    max-width: 500px;
    margin: 0 auto;
  }
}

/* Large desktop */
@media (min-width: 1200px) {
  .chat-page {
    max-width: 1240px;
  }
}

/* Narrow desktop / split-screen: do not squeeze the product beside a full sidebar. */
@media (max-width: 900px) {
  body.app-authenticated .sidebar {
    display: none !important;
  }

  body.app-authenticated .bottom-nav {
    display: flex !important;
    max-width: 100%;
  }

  .main-content {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0 12px;
  }

  body.app-authenticated .main-content {
    margin-left: 0;
  }

  .page {
    width: 100%;
    max-width: 100%;
    padding: 16px 0 96px;
    overflow-x: hidden;
  }

  .chat-page {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
  }
}


/* ========================================
   SIDEBAR STYLES
   ======================================== */
.sidebar {
  width: 240px;
  min-width: 240px;
  height: 100vh;
  height: 100dvh;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border-right: 1px solid var(--border-color);
  transition: width 0.25s ease, min-width 0.25s ease;
  overflow: hidden;
  z-index: 50;
}

body:not(.app-authenticated) .sidebar {
  display: none !important;
}

body:not(.app-admin-user) [data-admin-only] {
  display: none !important;
}

.sidebar.collapsed {
  width: 64px;
  min-width: 64px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.sidebar-logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #e46f55;
  border: 0;
  box-shadow: none !important;
  filter: none !important;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-logo-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: fill;
  transform: none;
  border-radius: inherit;
}

.sidebar-logo-text {
  width: 70px;
  height: 28px;
  display: block;
  color: transparent;
  text-indent: -999px;
  overflow: hidden;
  white-space: nowrap;
  background: url('../../public/assets/cre8-logo-wordmark.png?v=20260531-brand-stable') left center / contain no-repeat;
}

.sidebar.collapsed .sidebar-logo-text { display: none; }
.sidebar.collapsed .sidebar-logo { justify-content: center; width: 100%; }

.sidebar-toggle {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 16px 0;
}

.sidebar.collapsed .sidebar-toggle {
  opacity: 0;
  width: 0;
  margin: 0;
  padding: 0;
  pointer-events: none;
  overflow: hidden;
}

/* Sidebar navigation */
.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar button {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
}

.sidebar-item {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid transparent;
  background: transparent !important;
  width: 100%;
  font: inherit;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  white-space: nowrap;
  box-shadow: none !important;
}

.sidebar-item:focus,
.sidebar-item:active {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
}

.sidebar-item:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
}

.sidebar-item:hover {
  background: var(--bg-elevated) !important;
  border-color: transparent;
  color: var(--text-primary);
}

.sidebar-item.active {
  background: var(--accent-soft) !important;
  border-color: transparent;
  color: var(--accent);
}

.sidebar-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke-width: 1.8;
}

.sidebar-item.active .sidebar-icon {
  stroke-width: 2.2;
}

body:not([data-theme="light"]) .sidebar .sidebar-item {
  appearance: none !important;
  -webkit-appearance: none !important;
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  border-color: transparent !important;
  color: var(--text-secondary) !important;
  box-shadow: none !important;
}

body:not([data-theme="light"]) .sidebar .sidebar-item:hover {
  background: var(--bg-elevated) !important;
  background-color: var(--bg-elevated) !important;
  color: var(--text-primary) !important;
}

body:not([data-theme="light"]) .sidebar .sidebar-item.active {
  background: var(--accent-soft) !important;
  background-color: var(--accent-soft) !important;
  color: var(--accent) !important;
}

body:not([data-theme="light"]) .sidebar .sidebar-item:not(.active):not(:hover) {
  background: transparent !important;
  background-color: transparent !important;
  border-color: transparent !important;
  color: var(--text-secondary) !important;
}

body:not([data-theme="light"]) .sidebar button.sidebar-item,
body:not([data-theme="light"]) .sidebar button.sidebar-item:focus,
body:not([data-theme="light"]) .sidebar button.sidebar-item:active {
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  border-color: transparent !important;
  box-shadow: none !important;
  color: var(--text-secondary) !important;
}

body:not([data-theme="light"]) .sidebar button.sidebar-item:hover {
  background: var(--bg-elevated) !important;
  background-color: var(--bg-elevated) !important;
  color: var(--text-primary) !important;
}

body:not([data-theme="light"]) .sidebar button.sidebar-item.active,
body:not([data-theme="light"]) .sidebar button.sidebar-item.active:focus,
body:not([data-theme="light"]) .sidebar button.sidebar-item.active:active {
  background: var(--accent-soft) !important;
  background-color: var(--accent-soft) !important;
  color: var(--accent) !important;
}

.sidebar-label {
  font-size: 14px;
  font-weight: 500;
}

.sidebar.collapsed .sidebar-label { display: none; }
.sidebar.collapsed .sidebar-item { justify-content: center; padding: 12px; }

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
}

.sidebar-user {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar.collapsed .sidebar-footer { display: none; }


/* ========================================
   SCROLLBAR
   ======================================== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

::selection { background: var(--accent-soft); color: var(--text-primary); }

a { color: var(--accent); text-decoration: none; }
img { max-width: 100%; height: auto; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::placeholder { color: var(--text-tertiary); }

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--border-color) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
