/**
 * app.css — CaptainsLog Mini App base styles (v5-mini-app-2-1)
 *
 * CSS custom properties (--cl-*) are populated at runtime by app.js:applyTheme().
 * These defaults are safe fallbacks for development environments where the
 * Telegram SDK is not available (plain browser open of index.html).
 *
 * AC5, AC6, AC7, AC8, T3a–T3d
 */

/* --------------------------------------------------------------------------
   Alpine.js x-cloak rule (fix H2 — prevent flash of all panels before Alpine
   processes x-show directives on page load)
   -------------------------------------------------------------------------- */
[x-cloak] { display: none !important; }

/* --------------------------------------------------------------------------
   CSS custom property defaults (overridden by app.js:applyTheme at runtime)
   -------------------------------------------------------------------------- */
:root {
  /* Background colours */
  --cl-bg:           #ffffff;
  --cl-secondary-bg: #f4f4f5;

  /* Text colours */
  --cl-text:         #111111;
  --cl-hint:         #999999;
  --cl-link:         #2481cc;

  /* Button colours */
  --cl-btn:          #2481cc;
  --cl-btn-text:     #ffffff;

  /* Semantic status colours (L3 fix — v6-mini-app-s6-polish) */
  --cl-positive:     #34C759;
  --cl-warning:      #FF9500;
  --cl-negative:     #FF3B30;
}

/* --------------------------------------------------------------------------
   Base reset & body (AC7 — system font stack, AC8 — bg_color background)
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  width: 100%;
  overflow-x: hidden;
}

body {
  /* AC7: System font stack — no custom font loading */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
               Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;

  /* AC8: Background color from Telegram theme */
  background-color: var(--cl-bg);
  color:            var(--cl-text);

  /* Prevent tap highlight on mobile */
  -webkit-tap-highlight-color: transparent;
}

/* --------------------------------------------------------------------------
   Utility classes using CSS custom properties (T3b)
   These classes can be used alongside or instead of Tailwind utilities.
   -------------------------------------------------------------------------- */

/* Text colour utilities */
.text-cl           { color: var(--cl-text); }
.text-cl-hint      { color: var(--cl-hint); }
.text-cl-link      { color: var(--cl-link); }

/* Background colour utilities */
.bg-cl             { background-color: var(--cl-bg); }
.bg-cl-secondary   { background-color: var(--cl-secondary-bg); }

/* Button colour utilities */
.bg-cl-btn         { background-color: var(--cl-btn); }
.text-cl-btn-text  { color: var(--cl-btn-text); }

/* Border utilities */
.border-cl-hint    { border-color: var(--cl-hint); }

/* --------------------------------------------------------------------------
   App shell layout
   -------------------------------------------------------------------------- */
#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

#main-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Loading screen (shown while auth is in progress)
   z-index: 200 — must sit above the tab bar (z-index: 100) (fix H2)
   -------------------------------------------------------------------------- */
.loading-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--cl-bg);
  z-index: 200;
}

/* --------------------------------------------------------------------------
   Error screen (shown on auth failure — AC10)
   z-index: 200 — must sit above the tab bar (z-index: 100) (fix H2)
   -------------------------------------------------------------------------- */
.error-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background-color: var(--cl-bg);
  z-index: 200;
}

.error-screen__message {
  font-size: 16px;
  line-height: 1.5;
  text-align: center;
  color: var(--cl-text);
}

/* --------------------------------------------------------------------------
   Tab bar (v5-mini-app-2-2, updated v6-mini-app-s1)
   Fixed bottom navigation: 52px height, 4 equally-spaced tabs.
   Safe area uses JS API (contentSafeAreaInset) via --safe-bottom CSS var.
   -------------------------------------------------------------------------- */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  /* use min-height + height so the bar grows on notched iPhones.
     Buttons remain within the top 52px; padding-bottom absorbs the safe area
     so the interactive area is never compressed below 44px. */
  min-height: 52px;
  height: calc(52px + var(--safe-bottom, 0px));
  display: flex;
  align-items: flex-start;  /* buttons align to top 52px, not stretched into safe area */
  justify-content: space-around;
  background: var(--cl-secondary-bg);
  /* border-top with hint color at 20% opacity.
     Static fallback for Telegram Desktop on older Chromium. */
  border-top: 1px solid rgba(153, 153, 153, 0.2);
  border-top: 1px solid color-mix(in srgb, var(--cl-hint) 20%, transparent);
  z-index: 100;
  /* Safe area absorption via padding-bottom (JS API sets --safe-bottom) */
  padding-bottom: var(--safe-bottom, 0px);
}

/* Touch targets — each tab button fills the full 52px interactive zone
   (min-height: 52px) and at least 1/4 of the screen width (4 tabs).
   fix M1: merged duplicate color declaration into this single rule block. */
.tab-bar__btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  /* Ensure at least 52px height within the bar (≥44px touch target) */
  min-height: 52px;
  background: none;
  border: none;
  outline: none;  /* custom focus indicator via :focus-visible below (fix L1) */
  cursor: pointer;
  padding: 0;
  /* Inactive tab: hint color (AC3, T1d) */
  color: var(--cl-hint);
  /* Prevent tap highlight flash on iOS/Android */
  -webkit-tap-highlight-color: transparent;
  /* Smooth color transition for active state */
  transition: color 0.15s ease;
}

/* fix L1: themed keyboard focus indicator for desktop / accessibility users */
.tab-bar__btn:focus-visible {
  outline: 2px solid var(--cl-link);
  outline-offset: -2px;
  border-radius: 4px;
}

/* Active tab: link color (AC3, T1c) */
.tab-bar__btn[aria-selected="true"] {
  color: var(--cl-link);
}

.tab-bar__icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  /* Inherit the button's color for the SVG stroke/fill */
  color: inherit;
}

.tab-bar__label {
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0.01em;
  color: inherit;
  /* Prevent label from wrapping */
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Main content area (v5-mini-app-2-2, updated v6-mini-app-s1)
   Content must not slide under the fixed tab bar (52px height, 4 tabs).
   Safe area uses JS API via --safe-bottom CSS var.
   -------------------------------------------------------------------------- */
.content-area {
  flex: 1;
  overflow-y: auto;
  /* position:relative required so .ptr-indicator (position:absolute) anchors here (H1) */
  position: relative;
  /* 52px tab bar + safe area inset so no content is hidden */
  padding-bottom: calc(52px + var(--safe-bottom, 0px));
  -webkit-overflow-scrolling: touch;
}

/* --------------------------------------------------------------------------
   Tab placeholder screens (T4a — each tab shows its name centered)
   -------------------------------------------------------------------------- */
.tab-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  padding: 24px;
  font-size: 18px;
  font-weight: 500;
  color: var(--cl-hint);
}

/* --------------------------------------------------------------------------
   Group selector header (v5-mini-app-2-3)
   T1a: Sticky header bar at the top of the content area.
   AC1: Always shows group avatar + name.
   -------------------------------------------------------------------------- */
.group-header {
  position: sticky;
  top: 0;
  z-index: 90;
  background: var(--cl-bg);
  border-bottom: 1px solid rgba(153, 153, 153, 0.15);
  border-bottom: 1px solid color-mix(in srgb, var(--cl-hint) 15%, transparent);
  /* Contain the absolute-positioned dropdown */
  isolation: isolate;
}

/* Trigger button / static label — flex row, vertically centred (T1b) */
.group-header__trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--cl-text);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  /* Minimum 44px touch target height */
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

/* Keyboard focus ring for the trigger button */
.group-header__trigger:not(.group-header__trigger--static):focus-visible {
  outline: 2px solid var(--cl-link);
  outline-offset: -2px;
}

/* Static (non-interactive) single-group variant: no pointer cursor (AC6) */
.group-header__trigger--static {
  cursor: default;
  pointer-events: none;
}

/* Group name text */
.group-header__name {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* T1c: Chevron icon, rotates to point up when dropdown is open */
.group-header__chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--cl-hint);
  transition: transform 0.2s ease;
}

.group-header__chevron--open {
  transform: rotate(180deg);
}

/* --------------------------------------------------------------------------
   Group avatar (first letter fallback) — used in header + dropdown
   -------------------------------------------------------------------------- */
.group-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--cl-btn);
  color: var(--cl-btn-text);
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  line-height: 1;
  text-transform: uppercase;
}

/* Smaller avatar variant inside the dropdown list */
.group-avatar--sm {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

/* --------------------------------------------------------------------------
   Group dropdown overlay (T2a–T2d)
   Appears immediately below the header; absolute-positioned.
   T2d: subtle drop shadow.
   -------------------------------------------------------------------------- */
.group-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--cl-bg);
  border-bottom: 1px solid rgba(153, 153, 153, 0.15);
  border-bottom: 1px solid color-mix(in srgb, var(--cl-hint) 15%, transparent);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  /* z-index is meaningful within the header's isolated stacking context */
  z-index: 1;
  max-height: 60vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Alpine x-transition CSS classes (fix M3 — these classes must exist for the
   transition directives in index.html to work; without them the dropdown
   appears/disappears instantly with no animation). */
.group-dropdown--enter {
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.group-dropdown--enter-start {
  opacity: 0;
  transform: translateY(-4px);
}
.group-dropdown--enter-end {
  opacity: 1;
  transform: translateY(0);
}

/* Respect reduced-motion preference for dropdown animation */
@media (prefers-reduced-motion: reduce) {
  .group-dropdown--enter {
    transition: none;
  }
}

/* T2b: Each dropdown item — avatar + name + checkmark */
.group-dropdown__item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--cl-text);
  font-size: 15px;
  text-align: left;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  transition: background-color 0.1s ease;
}

.group-dropdown__item:hover,
.group-dropdown__item:focus-visible {
  background-color: var(--cl-secondary-bg);
}

.group-dropdown__item:focus-visible {
  outline: 2px solid var(--cl-link);
  outline-offset: -2px;
}

/* Currently selected item highlight (T2b).
   Uses aria-checked because role="menuitemradio" uses aria-checked, not aria-selected. */
.group-dropdown__item[aria-checked="true"] {
  background-color: var(--cl-secondary-bg);
  font-weight: 600;
}

.group-dropdown__item-name {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* T2b: Checkmark icon for active group */
.group-dropdown__check {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--cl-link);
}

/* --------------------------------------------------------------------------
   Spinner (shared loading indicator — used by loading-screen and components)
   -------------------------------------------------------------------------- */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--cl-secondary-bg);
  border-top-color: var(--cl-btn);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

/* Fix L3: respect reduced-motion OS preference for users with vestibular disorders */
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
    border-top-color: var(--cl-btn);
    opacity: 0.6;
  }
}

/* ==========================================================================
   Skeleton loading system (v5-mini-app-2-4)
   AC1, AC2, AC7 — reusable skeleton components with pulse animation.

   PERFORMANCE: The pulse animation changes opacity only — never width, height,
   margin, padding, or any layout-triggering property. This keeps it firmly on
   the compositor thread (60fps, no layout/paint cost).
   ========================================================================== */

/* --------------------------------------------------------------------------
   Keyframe: opacity-only pulse (AC1, T1e, T2a)
   0%,100% → 0.3   50% → 0.7  (AC2: color is var(--cl-hint) at 15% opacity)
   -------------------------------------------------------------------------- */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.3; }
  50%       { opacity: 0.7; }
}

/* --------------------------------------------------------------------------
   .skeleton — base class (T2a)
   All skeleton variants extend this class.
   Color: var(--cl-hint) at 15% opacity (AC2, T2c).
   Static hex fallback (153,153,153) for environments without the custom
   property resolved (Telegram Desktop old Chromium).
   -------------------------------------------------------------------------- */
.skeleton {
  /* Static fallback for environments without CSS custom property support */
  background-color: rgba(153, 153, 153, 0.15);
  /* Modern browsers: use actual hint color at 15% opacity (AC2, T2c) */
  background-color: color-mix(in srgb, var(--cl-hint) 15%, transparent);
  border-radius: 4px;
  display: block;
  /* opacity animation only — no layout properties (60fps) */
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* --------------------------------------------------------------------------
   Disable animation for users who prefer reduced motion (T1e, accessibility)
   The element is still visible (opacity: 0.5) but static.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
    opacity: 0.5;
  }
}

/* --------------------------------------------------------------------------
   .skeleton-line — single text line placeholder (T1d)
   Use width utilities (e.g. Tailwind w-3/4, w-1/2) to vary widths.
   -------------------------------------------------------------------------- */
.skeleton-line {
  height: 14px;
  border-radius: 3px;
}

/* --------------------------------------------------------------------------
   .skeleton-circle — avatar / icon placeholder (T2b)
   -------------------------------------------------------------------------- */
.skeleton-circle {
  border-radius: 50%;
}

/* --------------------------------------------------------------------------
   .skeleton-card — dashboard/event card placeholder (T1a, T2b)
   Full-width rectangle matching a typical card height.
   -------------------------------------------------------------------------- */
.skeleton-card {
  width: 100%;
  height: 96px;
  border-radius: 12px;
}

/* --------------------------------------------------------------------------
   .skeleton-list-item — list row placeholder (T1b)
   Slightly shorter than a card; represents a single list row.
   -------------------------------------------------------------------------- */
.skeleton-list-item {
  width: 100%;
  height: 64px;
  border-radius: 8px;
}

/* --------------------------------------------------------------------------
   .skeleton-chart — chart area placeholder (T1c)
   Single large rectangle representing a chart canvas.
   -------------------------------------------------------------------------- */
.skeleton-chart {
  width: 100%;
  height: 200px;
  border-radius: 12px;
}

/* --------------------------------------------------------------------------
   .skeleton-avatar — small circular avatar (convenience alias)
   -------------------------------------------------------------------------- */
.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ==========================================================================
   Pull-to-refresh indicator (v5-mini-app-2-4)
   AC3, AC4, T3c, T3d — visual bar shown at top during a pull gesture.
   ========================================================================== */

/* --------------------------------------------------------------------------
   .ptr-indicator — fixed bar at very top of content area.
   Hidden by default; JS adds .ptr-indicator--visible during active pull.
   Color: var(--cl-link) (AC4, T3d).
   -------------------------------------------------------------------------- */
.ptr-indicator {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  /* Static fallback */
  background-color: #2481cc;
  background-color: var(--cl-link);
  /* Scale starts at 0 (invisible) — transform/opacity only, no layout */
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.15s ease, opacity 0.15s ease;
  opacity: 0;
  z-index: 50;
  border-radius: 0 0 2px 2px;
}

.ptr-indicator--pulling {
  opacity: 1;
}

.ptr-indicator--ready {
  opacity: 1;
  /* Solid full-width bar when threshold reached */
  background-color: var(--cl-link);
}

.ptr-indicator--refreshing {
  opacity: 1;
  transform: scaleX(1);
  /* Shimmer animation while refresh is in progress — opacity only (60fps) */
  animation: ptr-shimmer 1s ease-in-out infinite;
}

@keyframes ptr-shimmer {
  0%, 100% { opacity: 0.6; }
  50%       { opacity: 1.0; }
}

@media (prefers-reduced-motion: reduce) {
  .ptr-indicator--refreshing {
    animation: none;
    opacity: 0.8;
  }
}

/* ==========================================================================
   Inline error state (v5-mini-app-2-4)
   AC5, T4a, T4b, T4c — "Couldn't load — pull to retry" message.
   ========================================================================== */

.inline-error {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  /* AC5, T4b: hint color */
  color: var(--cl-hint);
}

/* ==========================================================================
   Dashboard screen styles (v5-mini-app-3-1)
   AC1–AC9, T1a–T5c
   ========================================================================== */

/* --------------------------------------------------------------------------
   Dashboard container — scrollable column with 16px padding and safe spacing
   -------------------------------------------------------------------------- */
.dashboard {
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --------------------------------------------------------------------------
   Skeleton loading state (AC12)
   Mirrors the layout of the real content with animate skeleton cards.
   -------------------------------------------------------------------------- */
.dashboard-skeleton {
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dashboard-skeleton__period {
  height: 32px;
  width: 180px;
  border-radius: 20px;
  /* reuse skeleton animation — fix L2(3-1): use color-mix pattern matching .skeleton class */
  background-color: color-mix(in srgb, var(--cl-hint) 15%, transparent);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* --------------------------------------------------------------------------
   Period toggle — Today / 7d / 30d (AC6, T2a–T2c)
   -------------------------------------------------------------------------- */
.period-toggle {
  display: flex;
  gap: 6px;
}

.period-toggle__btn {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--cl-hint);
  background: none;
  color: var(--cl-hint);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  -webkit-tap-highlight-color: transparent;
  /* fix H2(3-1): enforce 44px minimum touch target */
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

/* AC6: Active period uses link color background (T2b) */
.period-toggle__btn--active {
  background: var(--cl-link);
  color: var(--cl-btn-text, #fff);
  border-color: var(--cl-link);
}

/* --------------------------------------------------------------------------
   Hero card — event count big number (AC1, T1a)
   AC7: entire card is tappable (navigates to Event Browser)
   -------------------------------------------------------------------------- */
.dashboard-hero {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 16px;
  background: var(--cl-secondary-bg);
  border-radius: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  transition: opacity 0.1s ease;
}

.dashboard-hero:active {
  opacity: 0.7;
}

.dashboard-hero:focus-visible {
  outline: 2px solid var(--cl-link);
  outline-offset: 2px;
}

.dashboard-hero__count {
  font-size: 40px;
  font-weight: 700;
  color: var(--cl-text);
  line-height: 1;
}

.dashboard-hero__label {
  font-size: 16px;
  color: var(--cl-hint);
}

.dashboard-hero__period {
  font-size: 13px;
  color: var(--cl-hint);
  margin-left: auto;
}

.dashboard-hero__caret {
  font-size: 20px;
  color: var(--cl-hint);
  margin-left: 4px;
}

/* --------------------------------------------------------------------------
   Sentiment gauge — SVG arc (AC2, T5a–T5c)
   AC8: tappable, navigates to Insights tab.
   -------------------------------------------------------------------------- */
.sentiment-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  background: var(--cl-secondary-bg);
  border-radius: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.1s ease;
}

.sentiment-section:active {
  opacity: 0.7;
}

.sentiment-section:focus-visible {
  outline: 2px solid var(--cl-link);
  outline-offset: 2px;
}

.sentiment-gauge {
  width: 120px;
  height: 70px;
}

/* Track arc: grey base */
.sentiment-gauge__track {
  stroke: var(--cl-secondary-bg);
  filter: brightness(0.92);
}

/* Value arc: colored by dominant sentiment */
.sentiment-gauge__arc--positive { stroke: #34c759; }  /* iOS green */
.sentiment-gauge__arc--neutral  { stroke: #ff9f0a; }  /* iOS orange */
.sentiment-gauge__arc--negative { stroke: #ff3b30; }  /* iOS red */
.sentiment-gauge__arc--unknown  { stroke: var(--cl-hint); }

.sentiment-gauge__label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: -4px;
}

.sentiment-gauge__value {
  font-size: 20px;
  font-weight: 700;
}
.sentiment-gauge__value--positive { color: #34c759; }
.sentiment-gauge__value--neutral  { color: #ff9f0a; }
.sentiment-gauge__value--negative { color: #ff3b30; }
.sentiment-gauge__value--unknown  { color: var(--cl-hint); }

.sentiment-gauge__name {
  font-size: 12px;
  color: var(--cl-hint);
  text-transform: capitalize;
}

/* --------------------------------------------------------------------------
   Dashboard sections — shared card wrapper (T1c, T1d, T1e)
   -------------------------------------------------------------------------- */
.dashboard-section {
  background: var(--cl-secondary-bg);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.1s ease;
}

.dashboard-section:active {
  opacity: 0.7;
}

.dashboard-section:focus-visible {
  outline: 2px solid var(--cl-link);
  outline-offset: 2px;
}

/* Non-clickable section (tags, recent events) */
.dashboard-section--static {
  cursor: default;
}

.dashboard-section__title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--cl-hint);
  margin-bottom: 10px;
}

/* --------------------------------------------------------------------------
   Event type badges — horizontal row (AC3, T1c)
   -------------------------------------------------------------------------- */
.event-type-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.event-type-badge {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.event-type-badge__name {
  font-size: 15px;
  color: var(--cl-text);
  text-transform: capitalize;
}

.event-type-badge__count {
  font-size: 15px;
  font-weight: 600;
  color: var(--cl-link);
  min-width: 32px;
  text-align: right;
}

/* --------------------------------------------------------------------------
   Tag pills (AC4, T1d)
   -------------------------------------------------------------------------- */
.tag-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 14px;
  background: var(--cl-bg);
  border: 1px solid var(--cl-hint);
  font-size: 13px;
  color: var(--cl-text);
}

.tag-pill__count {
  font-size: 11px;
  color: var(--cl-hint);
}

/* --------------------------------------------------------------------------
   Recent events compact list (AC5, T1e)
   AC9: each row is tappable
   -------------------------------------------------------------------------- */
.recent-events {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.recent-event {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;   /* fix M5(3-1): increased from 10px to reach ~44px touch target */
  min-height: 44px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border-bottom: 1px solid rgba(153, 153, 153, 0.15);
  transition: opacity 0.1s ease;
}

.recent-event:last-child {
  border-bottom: none;
}

.recent-event:active {
  opacity: 0.6;
}

.recent-event:focus-visible {
  outline: 2px solid var(--cl-link);
  border-radius: 4px;
}

.recent-event__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.recent-event__summary {
  font-size: 14px;
  color: var(--cl-text);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.recent-event__type {
  font-size: 12px;
  color: var(--cl-link);
  text-transform: capitalize;
}

.recent-event__time {
  font-size: 12px;
  color: var(--cl-hint);
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Empty state (AC11 — no events yet / template-agnostic)
   -------------------------------------------------------------------------- */
.dashboard-empty {
  padding: 32px 16px;
  text-align: center;
  font-size: 15px;
  color: var(--cl-text);
  line-height: 1.6;
}

.dashboard-empty__hint {
  margin-top: 8px;
  font-size: 13px;
  color: var(--cl-hint);
}

/* ==========================================================================
   Event Browser screen (v5-mini-app-3-2)
   ========================================================================== */

/* --------------------------------------------------------------------------
   Filter chips (AC3, AC4)
   -------------------------------------------------------------------------- */
.filter-chips {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 8px;
  padding: 12px 16px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;           /* Firefox */
}

.filter-chips::-webkit-scrollbar {
  display: none;                   /* Safari / Chrome */
}

.filter-chip {
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
  border: 1.5px solid var(--cl-hint);
  background: transparent;
  color: var(--cl-text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s ease, color 0.1s ease, border-color 0.1s ease;
  text-transform: capitalize;
  /* fix M4(3-2): enforce 44px minimum touch target per iOS HIG / WCAG 2.5.5 */
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

/* AC4: Active (filled) state */
.filter-chip--active {
  background: var(--cl-link);
  border-color: var(--cl-link);
  color: #ffffff;
}

/* Tag variant — slightly different styling */
.filter-chip--tag {
  font-weight: 400;
}

.filter-chip:active {
  opacity: 0.7;
}

/* --------------------------------------------------------------------------
   Event list + date groups (AC1)
   -------------------------------------------------------------------------- */
.event-browser,
.event-list {
  display: flex;
  flex-direction: column;
}

.event-browser-skeleton {
  padding: 16px;
}

.event-date-group {
  margin-bottom: 4px;
}

.event-date-header {
  padding: 10px 16px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--cl-hint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
  background: var(--cl-bg);
  z-index: 1;
}

/* --------------------------------------------------------------------------
   Event card (AC2)
   -------------------------------------------------------------------------- */
.event-card {
  margin: 0 16px 8px;
  padding: 12px;
  border-radius: 10px;
  background: var(--cl-secondary-bg);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.1s ease;
}

.event-card:active {
  opacity: 0.65;
}

.event-card:focus-visible {
  outline: 2px solid var(--cl-link);
  outline-offset: 2px;
}

.event-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.event-card__type {
  font-size: 12px;
  font-weight: 600;
  color: var(--cl-link);
  text-transform: capitalize;
}

.event-card__time {
  font-size: 12px;
  color: var(--cl-hint);
  flex-shrink: 0;
}

.event-card__summary {
  font-size: 14px;
  color: var(--cl-text);
  line-height: 1.4;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.event-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 20px;
}

.event-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

/* Smaller tag pill variant for event cards */
.tag-pill--sm {
  padding: 2px 6px;
  font-size: 11px;
}

/* --------------------------------------------------------------------------
   Sentiment dot (8px colored circle — AC2)
   -------------------------------------------------------------------------- */
.sentiment-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--cl-hint);    /* default / unknown */
}

.sentiment-dot--positive  { background: #34c759; }
.sentiment-dot--neutral   { background: #ff9500; }
.sentiment-dot--negative  { background: #ff3b30; }
.sentiment-dot--unknown   { background: var(--cl-hint); }

/* --------------------------------------------------------------------------
   Infinite scroll sentinel + load-more spinner (AC5)
   -------------------------------------------------------------------------- */
.scroll-sentinel {
  height: 1px;
  width: 100%;
}

.load-more {
  display: flex;
  justify-content: center;
  padding: 16px 0;
}

/* Small spinner variant for load-more indicator */
.spinner--sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

/* --------------------------------------------------------------------------
   Event browser empty state
   -------------------------------------------------------------------------- */
.event-browser-empty {
  padding: 32px 16px;
  text-align: center;
  font-size: 15px;
  color: var(--cl-text);
  line-height: 1.6;
}

.event-browser-empty__hint {
  margin-top: 8px;
  font-size: 13px;
  color: var(--cl-hint);
}

/* ==========================================================================
   Event Detail screen (v5-mini-app-3-2, T4)
   ========================================================================== */
.event-detail {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.event-detail-skeleton {
  padding: 16px;
}

.event-detail__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(153, 153, 153, 0.2);
}

.event-detail__time {
  font-size: 12px;
  color: var(--cl-hint);
}

.event-detail__section {
  margin-bottom: 16px;
}

.event-detail__section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--cl-hint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.event-detail__summary {
  font-size: 15px;
  color: var(--cl-text);
  line-height: 1.5;
}

/* Original messages: quoted style */
.event-detail__messages {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.event-detail__message {
  font-size: 13px;
  color: var(--cl-text);
  background: var(--cl-secondary-bg);
  border-left: 3px solid var(--cl-link);
  border-radius: 0 6px 6px 0;
  padding: 8px 10px;
  line-height: 1.4;
}

/* Entities key-value pairs */
.event-detail__entities {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.event-detail__entity-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 14px;
}

.event-detail__entity-key {
  font-weight: 500;
  color: var(--cl-hint);
  text-transform: capitalize;
  flex-shrink: 0;
}

.event-detail__entity-val {
  color: var(--cl-text);
  text-align: right;
  word-break: break-word;
}

/* Quantities */
.event-detail__quantity {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(153, 153, 153, 0.1);
}

.event-detail__quantity-label {
  color: var(--cl-hint);
  text-transform: capitalize;
}

.event-detail__quantity-value {
  font-weight: 600;
  color: var(--cl-text);
}

/* Dates */
.event-detail__date {
  font-size: 14px;
  color: var(--cl-hint);
  padding: 4px 0;
}

/* ==========================================================================
   Activity Summary screen (v5-mini-app-3-3)
   ========================================================================== */

/* --------------------------------------------------------------------------
   Dashboard Activity nav row (entry point to activity sub-screen)
   -------------------------------------------------------------------------- */
.dashboard-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 0;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--cl-link);
  font-size: 14px;
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.1s ease;
  min-height: 44px;   /* touch target */
}

.dashboard-nav-row:active {
  opacity: 0.6;
}

.dashboard-nav-row:focus-visible {
  outline: 2px solid var(--cl-link);
  border-radius: 4px;
}

.dashboard-nav-row__label {
  flex: 1;
  text-align: left;
}

.dashboard-nav-row__caret {
  font-size: 18px;
  color: var(--cl-hint);
}

/* --------------------------------------------------------------------------
   Activity summary container + skeleton
   -------------------------------------------------------------------------- */
.activity-summary {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.activity-skeleton {
  padding: 4px 0;
}

/* --------------------------------------------------------------------------
   Period card (AC1, AC4)
   -------------------------------------------------------------------------- */
.activity-period {
  border-radius: 10px;
  background: var(--cl-secondary-bg);
  overflow: hidden;
}

.activity-period__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.1s ease;
  min-height: 52px;
  text-align: left;
}

.activity-period__header:active {
  opacity: 0.7;
}

.activity-period__header:focus-visible {
  outline: 2px solid var(--cl-link);
  outline-offset: -2px;
}

.activity-period__label {
  font-size: 15px;
  font-weight: 600;
  color: var(--cl-text);
}

.activity-period__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.activity-period__count {
  font-size: 13px;
  color: var(--cl-hint);
}

.activity-period__chevron {
  width: 16px;
  height: 16px;
  color: var(--cl-hint);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

/* Rotate chevron when period is expanded */
.activity-period__chevron--open {
  transform: rotate(180deg);
}

/* --------------------------------------------------------------------------
   Period body: type breakdown + quantities + event list (AC2)
   -------------------------------------------------------------------------- */
.activity-period__body {
  padding: 0 16px 14px;
  border-top: 1px solid rgba(153, 153, 153, 0.15);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Event type breakdown rows */
.activity-type-breakdown {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 10px;
}

.activity-type-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}

.activity-type-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--cl-text);
}

/* Quantities (T3) */
.activity-quantities {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 2px;
  border-top: 1px solid rgba(153, 153, 153, 0.1);
}

.activity-quantity-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--cl-hint);
  padding: 3px 0;
}

.activity-quantity-value {
  font-weight: 500;
  color: var(--cl-text);
}

/* Event cards inside period body (T2b, T5b) */
.activity-events {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 4px;
}

/* Override event-card margin inside activity body */
.activity-events .event-card {
  margin: 0;
}
