/* ═══════════════════════════════════════════════════════════════
   Coffee.CRM — Design System
   Inspired by Attio · Linear · Pipedrive
   ═══════════════════════════════════════════════════════════════ */

/* ── Rendering ────────────────────────────────────────────────── */
html { text-rendering: optimizeLegibility; }
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

:root {
  --crm-font-sans: Manrope, Segoe UI, Helvetica Neue, Arial, sans-serif;
  --crm-font-display: Fraunces, Georgia, Times New Roman, serif;
}

.font-sans,
body,
button,
input,
select,
textarea {
  font-family: var(--crm-font-sans) !important;
}

.crm-atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(circle at 10% 10%, rgba(0,191,165,0.12), transparent 34%),
    radial-gradient(circle at 85% 85%, rgba(26,32,53,0.14), transparent 38%),
    linear-gradient(180deg, #f9fbfb, #f2f5f8);
}

/* ── Selection ────────────────────────────────────────────────── */
::selection { background: rgba(0,191,165,0.15); color: #00695c; }

/* ── Scrollbars ───────────────────────────────────────────────── */
::-webkit-scrollbar          { width: 4px; height: 4px; }
::-webkit-scrollbar-track    { background: transparent; }
::-webkit-scrollbar-thumb    { background: rgba(148,163,184,0.45); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Focus rings ──────────────────────────────────────────────── */
:focus-visible { outline: 2px solid #00bfa5; outline-offset: 2px; border-radius: 6px; }
button:focus:not(:focus-visible), a:focus:not(:focus-visible) { outline: none; }

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR — Linear-style pill navigation
   ═══════════════════════════════════════════════════════════════ */

/* Reset the legacy border-left nav style */
aside nav a {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  margin: 1px 6px !important;
  padding: 6px 10px !important;
  font-size: 0.795rem !important;
  font-weight: 500 !important;
  border-radius: 7px !important;
  border: none !important;
  text-decoration: none !important;
  line-height: 1.3 !important;
  color: rgba(255,255,255,0.56) !important;
  background: transparent !important;
  transition: background 0.1s ease, color 0.1s ease !important;
}
aside nav a:hover {
  background: rgba(255,255,255,0.08) !important;
  color: rgba(255,255,255,0.92) !important;
}
/* Active nav item — overrides Tailwind bg-brand/[.12] text-brand border-brand classes */
aside nav a[class*="bg-brand"] {
  background: rgba(255,255,255,0.14) !important;
  color: #fff !important;
  font-weight: 600 !important;
}
aside nav a[class*="bg-brand"] i,
aside nav a[class*="bg-brand"] .bi {
  opacity: 1 !important;
}
aside nav i, aside nav .bi {
  opacity: 0.7;
  font-size: 0.9rem !important;
  width: 16px !important;
  flex-shrink: 0;
}
aside nav a:hover i, aside nav a:hover .bi { opacity: 0.95; }

/* Navigation section labels */
.nav-section-label {
  padding: 2px 16px 3px;
  margin-top: 12px;
  font-size: 0.59rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.26);
}

/* ═══════════════════════════════════════════════════════════════
   PAGE BACKGROUND & BODY
   ═══════════════════════════════════════════════════════════════ */
body { background: #f5f6f8 !important; }

/* ═══════════════════════════════════════════════════════════════
   CARDS — Attio-style layered shadow
   ═══════════════════════════════════════════════════════════════ */
#main-content .rounded-xl.bg-white,
#main-content .rounded-2xl.bg-white {
  border: 1px solid rgba(0,0,0,0.065);
  box-shadow:
    0 1px 2px rgba(15,23,42,0.04),
    0 3px 10px rgba(15,23,42,0.05);
  background: #fff;
}
/* Suppress nested elements inheriting card treatment — form controls are excluded */
#main-content .rounded-xl.bg-white .rounded-xl:not(input):not(select):not(textarea),
#main-content .rounded-xl.bg-white .rounded-lg:not(input):not(select):not(textarea),
#main-content .rounded-xl.bg-white .rounded-full:not(input):not(select):not(textarea),
#main-content .rounded-2xl.bg-white .rounded-xl:not(input):not(select):not(textarea),
#main-content .rounded-2xl.bg-white .rounded-full:not(input):not(select):not(textarea) { border: none !important; box-shadow: none !important; }

/* Card section header (the border-b divider line at top of card) */
#main-content .rounded-xl.bg-white > .border-b,
#main-content .rounded-2xl.bg-white > .border-b {
  border-bottom-color: rgba(0,0,0,0.05) !important;
}

/* Card lift on hover (stat cards) */
.card-lift {
  transition: transform 0.2s cubic-bezier(0.25,0.46,0.45,0.94), box-shadow 0.2s ease;
}
.card-lift:hover {
  transform: translateY(-2px);
  box-shadow:
    0 4px 8px rgba(15,23,42,0.05),
    0 12px 28px rgba(15,23,42,0.08) !important;
}

/* ═══════════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════════ */
.fixed .rounded-2xl.bg-white,
.fixed .rounded-xl.bg-white {
  border: 1px solid rgba(0,0,0,0.06) !important;
  box-shadow: 0 20px 60px rgba(15,23,42,0.2), 0 6px 20px rgba(15,23,42,0.1) !important;
}

/* ═══════════════════════════════════════════════════════════════
   TOPBAR — frosted glass like Notion/Linear
   ═══════════════════════════════════════════════════════════════ */
.crm-topbar {
  background: rgba(245,246,248,0.88);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 1px 0 rgba(255,255,255,0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* ═══════════════════════════════════════════════════════════════
   TABLES — Attio-inspired: minimal chrome, data-focused
   ═══════════════════════════════════════════════════════════════ */
#main-content th {
  font-size: 0.67rem !important;
  letter-spacing: 0.06em !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  color: #a0aec0 !important;
  background: transparent !important;
  border-bottom: 1px solid rgba(0,0,0,0.06) !important;
  padding-top: 0.65rem !important;
  padding-bottom: 0.65rem !important;
}
#main-content th.bg-slate-50 { background: transparent !important; }
#main-content tbody tr:last-child td { border-bottom: none !important; }
#main-content tbody tr td {
  border-bottom-color: rgba(0,0,0,0.04) !important;
}
#main-content tbody tr { transition: background 0.08s ease; }

/* Global teal-accent row hover — applies to ALL data tables, no class needed */
#main-content tbody tr:hover td { background: rgba(0,191,165,0.022) !important; }
#main-content tbody tr:hover td:first-child {
  box-shadow: inset 3px 0 0 #00bfa5;
  padding-left: calc(var(--row-px, 1.25rem) - 3px) !important;
}

/* .tbl-row kept for explicit use (customer dashboard etc) */
.tbl-row { transition: background 0.08s ease; }

/* ═══════════════════════════════════════════════════════════════
   FORMS & INPUTS
   ═══════════════════════════════════════════════════════════════ */
input, select, textarea {
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
/* Visible resting border — overrides Tailwind's very-light border-slate-200 */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
select,
textarea {
  border-color: #b8c4d0 !important;
}
input:focus, select:focus, textarea:focus {
  border-color: #00bfa5 !important;
  box-shadow: 0 0 0 3px rgba(0,191,165,0.1) !important;
  outline: none !important;
}
input[type="checkbox"]:focus { box-shadow: none !important; }

/* ── WCAG AA contrast fixes for brand color on white ─────────── */
#main-content .text-brand,
#main-content button.text-brand,
#main-content a.text-brand { color: #00695c !important; }
#main-content .hover\:text-brand:hover { color: #00695c !important; }
#main-content .border-brand { border-color: #00866e !important; }

/* ═══════════════════════════════════════════════════════════════
   STATUS BADGES  (consistent pill sizing)
   ═══════════════════════════════════════════════════════════════ */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* Pulsing live dot (in-transit / working) */
.dot-live::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 4px;
  vertical-align: middle;
  animation: dotPulse 1.6s ease-in-out infinite;
}
@keyframes dotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.35; transform: scale(0.65); }
}

/* ═══════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════ */
a, button {
  transition: color 0.1s ease, background-color 0.1s ease,
              border-color 0.1s ease, box-shadow 0.1s ease,
              opacity 0.1s ease, transform 0.12s ease;
}
button:active:not(:disabled), a:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ═══════════════════════════════════════════════════════════════
   TYPOGRAPHY  (Linear-style: tight, purposeful)
   ═══════════════════════════════════════════════════════════════ */
h1, h2, h3, h4, h5, h6 { letter-spacing: -0.02em; }
p, li { line-height: 1.56; }
#main-content h1 { font-size: 1.18rem; font-weight: 700; color: #0f172a; letter-spacing: -0.025em; }

h1,
.crm-display {
  font-family: var(--crm-font-display) !important;
  font-variation-settings: opsz 64;
}

/* ── Code ──────────────────────────────────────────────────────── */
code {
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 0.79em;
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 4px;
  color: #334155;
}

/* ═══════════════════════════════════════════════════════════════
   PAGE ANIMATION
   ═══════════════════════════════════════════════════════════════ */
#main-content {
  animation: fadeUp 0.15s cubic-bezier(0.25,0.46,0.45,0.94) both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════════════════
   PAGE HEADER CONSISTENCY
   ═══════════════════════════════════════════════════════════════ */
/* Subtitle text under page h1 should always be slate-500 */
#main-content .page-subtitle,
#main-content h1 + p.text-sm { color: #64748b !important; }

/* Icons inside page h1 — scale and colour them consistently */
#main-content h1 > i.bi {
  font-size: 0.9em;
  color: #00bfa5;
  margin-right: 0.4rem;
  vertical-align: -0.05em;
}

/* Card section headers (px-5 py-3.5 border-b) get consistent icon styling */
.card-header i.bi { color: #00bfa5; margin-right: 0.4rem; }

/* ═══════════════════════════════════════════════════════════════
   MOBILE
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 1023px) {
  button, a[role="button"] { min-height: 36px; }

  #main-content {
    padding: 1rem 0.95rem 1.2rem !important;
  }

  .crm-topbar {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  aside {
    width: 18.5rem !important;
    box-shadow: 0 22px 48px rgba(15, 23, 42, 0.28);
  }
}
