﻿@tailwind base;
@tailwind components;
@tailwind utilities;
/* ─── Expandable text utilities (forced-safe, not JIT-scanned) ─────────────── */
/* These must be here to survive Docker layer caching of assets:precompile.     */
@layer utilities {
  .line-clamp-3 {
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }
  .line-clamp-6 {
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 6;
  }
}


/* â”€â”€â”€ Base â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */

@layer base {
  html { font-family: 'Inter', system-ui, sans-serif; }

  body {
    @apply bg-warm text-gray-800 antialiased;
    margin: 0;
  }

  h1, h2, h3, h4 { @apply tracking-tight; }

  a { @apply transition-colors duration-150; }
}

/* â”€â”€â”€ Components â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */

@layer components {

  /* Buttons */
  .btn {
    @apply inline-flex items-center justify-center gap-2 font-semibold rounded-xl
           transition-all duration-150 cursor-pointer whitespace-nowrap
           text-sm px-5 py-2.5 no-underline;
  }
  .btn-primary {
    @apply btn bg-brand text-white border border-brand
           hover:bg-brand-hover hover:border-brand-hover;
  }
  .btn-secondary {
    @apply btn bg-white text-gray-700 border border-gray-200
           hover:bg-gray-50;
  }
  .btn-ghost {
    @apply btn bg-transparent text-gray-500 border border-transparent
           hover:bg-gray-100 hover:text-gray-700;
  }
  .btn-danger {
    @apply btn bg-white text-gray-600 border border-gray-200
           hover:bg-red-50 hover:border-red-200 hover:text-red-700;
  }
  .btn-sm {
    @apply text-xs px-3.5 py-2;
  }
  .btn-lg {
    @apply text-base px-6 py-3;
  }

  /* Cards */
  .card {
    @apply bg-white rounded-2xl border border-gray-100 shadow-soft p-6;
  }
  .card-hover {
    @apply card hover:shadow-soft-md hover:border-gray-200 transition-all duration-200;
  }

  /* Inputs */
  .input {
    @apply w-full border border-gray-200 rounded-xl px-4 py-3 text-gray-800
           placeholder-gray-400 bg-white text-sm
           focus:outline-none focus:ring-2 focus:ring-brand/20 focus:border-brand
           transition-colors duration-150;
  }
  .input-textarea {
    @apply input resize-none;
  }
  .label {
    @apply block text-sm font-medium text-gray-700 mb-1.5;
  }

  /* Badges */
  .badge {
    @apply inline-flex items-center text-xs font-semibold px-2.5 py-1 rounded-full;
  }
  .badge-brand    { @apply badge bg-brand text-white; }
  .badge-mint     { @apply badge bg-mint-light text-brand border border-mint; }
  .badge-lavender { @apply badge bg-lavender-light text-lavender-dark border border-lavender; }
  .badge-red      { @apply badge bg-red-50 text-red-700 border border-red-200; }
  .badge-green    { @apply badge bg-mint-light text-green-800 border border-mint; }

  /* Page layout */
  .page {
    @apply min-h-screen bg-warm py-10 px-5;
  }
  .page-inner {
    @apply max-w-5xl mx-auto;
  }
  .max-width {
    @apply max-w-5xl mx-auto;
  }

  /* Section headings */
  .page-title {
    @apply text-4xl font-bold text-gray-900 tracking-tight;
  }
  .page-subtitle {
    @apply text-gray-400 text-sm font-medium;
  }
  .page-description {
    @apply text-gray-500 text-base leading-relaxed max-w-2xl;
  }

  /* Grids */
  .grid-2 {
    @apply grid grid-cols-1 gap-5 sm:grid-cols-2;
  }
  .grid-3 {
    @apply grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-3;
  }

  /* Flash messages */
  .flash-notice {
    @apply max-w-2xl mx-auto mt-5 px-4 py-3 rounded-xl text-sm text-center
           bg-mint-light text-brand border border-mint;
    cursor: pointer;
  }
  .flash-alert {
    @apply max-w-2xl mx-auto mt-5 px-4 py-3 rounded-xl text-sm text-center
           bg-red-50 text-red-700 border border-red-200;
    cursor: pointer;
  }
  .flash-warning {
    @apply max-w-2xl mx-auto mt-5 px-4 py-3 rounded-xl text-sm
           bg-amber-50 text-amber-800 border border-amber-200;
    cursor: pointer;
  }

  /* Nav links */
  .nav-link {
    @apply text-gray-500 font-semibold text-sm px-3.5 py-2 rounded-xl
           no-underline transition-colors duration-150
           hover:bg-gray-100 hover:text-gray-700;
  }
  .nav-link-active {
    @apply text-gray-900 bg-brand-light;
  }

  /* Auth card (login / signup) */
  .auth-page {
    @apply min-h-screen bg-warm py-12 px-5 flex items-start justify-center;
  }
  .auth-card {
    @apply card w-full max-w-md shadow-soft-md;
  }

  /* Glass nav bar */
  .ps-nav {
    @apply sticky top-0 z-50 backdrop-blur-md border-b border-[#d4e8da]
           bg-[rgba(250,250,250,0.97)];
  }
}

/* â”€â”€â”€ Chat layout (preserved) â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */

/* Body becomes a flex column locked to the viewport — nav takes its natural height,
   .ps-chat-page fills the rest. Desktop uses 100vh; mobile overrides to 100dvh
   so the keyboard doesn't cover the send form. */
body:has(.ps-chat-page) {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

body:has(.ps-chat-page) footer {
  display: none;
}

/* Outer page: fills remaining body height after nav */
.ps-chat-page {
  background: #fafafa;
  flex: 1;
  min-height: 0;
  padding: 12px 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Inner wrap: fills page vertically; inline max-width/margin:0 auto keep it centred on desktop */
.ps-chat-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: auto;
  width: 100%; /* without this, margin:0 auto shrinks the wrap to content width */
}

/* Flash messages become fixed toasts on ALL screen sizes when the chat layout is active.
   Without this, flashes are flex-items in the locked 100vh column: on desktop they push
   the chat area down (bottom input cut off); on tablet/mobile the layout can overflow.
   Making them fixed removes them from the flex flow so the chat fills the full height. */
body:has(.ps-chat-page) .flash-notice,
body:has(.ps-chat-page) .flash-alert,
body:has(.ps-chat-page) .flash-warning {
  position: fixed;
  top: 72px;   /* nav height (~56px) + 16px gap */
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 40px);
  max-width: 640px;
  margin: 0;
  z-index: 45;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}


@media (max-width: 640px) {
  /* Dynamic viewport height so keyboard doesn't cover the send form on iOS/Android */
  body:has(.ps-chat-page) {
    height: 100dvh;
  }

  .ps-chat-page {
    padding: 0 !important;
    min-height: unset !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .ps-chat-page .ps-chat-wrap {
    flex: 1;
    min-height: 0;
    height: auto;
    padding: 12px 16px 0 16px;
    max-width: 100% !important;  /* override inline style max-width:700/800px */
    margin: 0 !important;         /* override inline style margin:0 auto → restores align-self:stretch */
    box-sizing: border-box;
  }

  .ps-chat-page .ps-chat-wrap > div:first-child {
    flex-shrink: 0;
    margin-bottom: 12px !important;
  }

  .ps-chat-page #messages,
  .ps-chat-page #group-messages {
    margin-bottom: 8px !important;
    padding-bottom: 16px !important;
  }

  .ps-chat-page #message-form {
    flex-shrink: 0;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .ps-chat-page #group-message-form {
    flex-shrink: 0;
    margin-left: -16px;
    margin-right: -16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  /* Buttons: allow text to wrap on mobile so long labels don't overflow cards */
  .btn {
    white-space: normal;
    text-align: center;
  }

  /* Flash messages become fixed toasts on mobile so they never push
     the chat page layout off-screen */
  .flash-notice,
  .flash-alert,
  .flash-warning {
    position: fixed !important;
    top: 64px !important;   /* 56px nav + 8px gap */
    left: 12px !important;
    right: 12px !important;
    margin: 0 !important;
    z-index: 45;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10);
  }
}

/* â”€â”€â”€ Edit profile sidebar â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */

@media (max-width: 640px) {
  .ps-edit-sidebar      { display: none !important; }
  .ps-edit-back-mobile  { display: block; }
}

/* ─── Context menu panel ──────────────────────────────────────────────────────── */

.ctx-panel {
  position: fixed;
  z-index: 9999;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.11), 0 2px 6px rgba(0,0,0,0.06);
  padding: 4px;
  min-width: 158px;
  overflow: hidden;
  user-select: none;
}
.ctx-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: #374151;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border-radius: 8px;
  text-align: left;
  transition: background 100ms;
  white-space: nowrap;
}
.ctx-btn:hover        { background: #f3f4f6; }
.ctx-danger           { color: #dc2626; }
.ctx-danger:hover     { background: #fef2f2; }
.ctx-icon {
  font-size: 14px;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
  line-height: 1;
}

/* Long-press visual feedback (WhatsApp style) */
.ctx-pressing {
  background: rgba(90, 138, 106, 0.06);
  border-radius: 8px;
  transition: background 200ms;
}
.ctx-selected {
  background: rgba(90, 138, 106, 0.13);
  border-radius: 8px;
}

/* Three-dot ⋮ button — hidden by default, shown on message hover (desktop) or always (touch) */
.ctx-dots-btn {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  padding: 2px 5px;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1;
  transition: background 100ms, color 100ms;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
}
.ctx-dots-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #374151;
}
/* Show on hover of the message row (desktop) */
@media (hover: hover) and (pointer: fine) {
  [data-controller~="ctx"]:hover .ctx-dots-btn { display: flex; }
}
/* Always show on touch devices */
@media (hover: none), (pointer: coarse) {
  .ctx-dots-btn { display: flex; }
}

