/* ============================================================
   ACTA Design System — CSS Custom Properties
   ============================================================ */
:root {
  /* --- Primary Palette --- */
  --acta-blue-50:  #eff6ff;
  --acta-blue-100: #dbeafe;
  --acta-blue-200: #bfdbfe;
  --acta-blue-300: #93c5fd;
  --acta-blue-500: #3b82f6;
  --acta-blue-600: #2563eb;
  --acta-blue-700: #1d4ed8;
  --acta-blue-900: #1e3a5f;

  /* --- Slate/Neutral Palette --- */
  --acta-slate-50:  #f8fafc;
  --acta-slate-100: #f1f5f9;
  --acta-slate-200: #e2e8f0;
  --acta-slate-300: #cbd5e1;
  --acta-slate-500: #64748b;
  --acta-slate-700: #334155;
  --acta-slate-800: #1e293b;
  --acta-slate-900: #0f172a;

  /* --- Accent Colours --- */
  --acta-emerald:   #10b981;
  --acta-amber:     #f59e0b;
  --acta-rose:      #f43f5e;
  --acta-violet:    #7c3aed;

  /* --- Semantic Tokens --- */
  --color-bg:             var(--acta-slate-50);
  --color-surface:        #ffffff;
  --color-surface-alt:    var(--acta-slate-100);
  --color-border:         var(--acta-slate-200);
  --color-border-focus:   var(--acta-blue-500);
  --color-text-primary:   var(--acta-slate-900);
  --color-text-secondary: var(--acta-slate-500);
  --color-text-muted:     var(--acta-slate-300);
  --color-brand:          var(--acta-blue-600);
  --color-brand-hover:    var(--acta-blue-700);
  --color-success:        var(--acta-emerald);
  --color-warning:        var(--acta-amber);
  --color-danger:         var(--acta-rose);

  /* --- Gradients --- */
  --gradient-hero:  linear-gradient(135deg, var(--acta-blue-900) 0%, #0f2d5c 45%, var(--acta-blue-700) 100%);
  --gradient-card:  linear-gradient(160deg, #ffffff 0%, var(--acta-slate-50) 100%);
  --gradient-brand: linear-gradient(135deg, var(--acta-blue-600) 0%, var(--acta-violet) 100%);

  /* --- Shadows --- */
  --shadow-xs:   0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm:   0 2px 8px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md:   0 4px 20px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow-lg:   0 10px 40px rgba(15, 23, 42, 0.12), 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-glow: 0 0 0 3px rgba(59, 130, 246, 0.18);

  /* --- Glass Effect --- */
  --glass-bg:     rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.5);
  --glass-blur:   blur(12px);

  /* --- Typography --- */
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* --- Radius --- */
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   16px;
  --radius-xl:   24px;
  --radius-full: 9999px;

  /* --- Transitions --- */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   Base Reset & Body
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Override old h1 colour lock */
h1 { color: var(--color-text-primary) !important; }

a {
  color: var(--color-brand);
  text-decoration: none;
}
a:hover {
  color: var(--color-brand-hover);
  text-decoration: underline;
}

/* ============================================================
   Navbar
   ============================================================ */
.navbar {
  background: var(--acta-slate-900) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 0.65rem 1.5rem;
  box-shadow: 0 1px 12px rgba(0, 0, 0, 0.3);
}

.navbar-brand {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  color: #fff !important;
}

.navbar .btn {
  border-radius: var(--radius-md);
  font-size: 0.83rem;
  font-weight: 500;
  padding: 0.38rem 0.85rem;
  transition: all var(--transition-fast);
}

.navbar .btn-dark {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.85);
}
.navbar .btn-dark:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.22);
}

.navbar .btn-danger {
  background: var(--color-danger);
  border-color: transparent;
}
.navbar .btn-danger:hover {
  background: #e11d48;
  border-color: transparent;
}

.navbar .btn-success {
  background: var(--color-success);
  border-color: transparent;
}
.navbar .btn-success:hover {
  background: #059669;
  border-color: transparent;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-base), transform var(--transition-base);
}

.card-header {
  background: var(--gradient-card);
  border-bottom: 1px solid var(--color-border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
  padding: 0.875rem 1.25rem;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
  color: var(--color-text-primary);
}

.card-glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-md);
}

.card-elevated {
  box-shadow: var(--shadow-lg);
  border: none;
}

/* Legacy .grad-card — modernised */
.grad-card {
  background: var(--gradient-card);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  transition: all var(--transition-fast);
  letter-spacing: 0.01em;
}

.btn-primary {
  background: var(--color-brand);
  border-color: var(--color-brand);
}
.btn-primary:hover {
  background: var(--color-brand-hover);
  border-color: var(--color-brand-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.btn-success {
  background: var(--color-success);
  border-color: var(--color-success);
}
.btn-success:hover {
  background: #059669;
  border-color: #059669;
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--color-danger);
  border-color: var(--color-danger);
}
.btn-danger:hover {
  background: #e11d48;
  border-color: #e11d48;
  transform: translateY(-1px);
}

.btn-outline-danger:hover  { transform: translateY(-1px); }
.btn-outline-primary:hover { transform: translateY(-1px); }

.btn-outline-light:hover {
  background-color: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.3);
  color: #fff;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

/* ============================================================
   Form Controls
   ============================================================ */
.form-control,
.form-select {
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.875rem;
  font-size: 0.9375rem;
  color: var(--color-text-primary);
  background: var(--color-surface);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-control:focus,
.form-select:focus {
  border-color: var(--color-border-focus);
  box-shadow: var(--shadow-glow);
  outline: none;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--acta-slate-700);
  margin-bottom: 0.35rem;
}

/* 2FA Code Input Boxes */
.code-box {
  width: 52px;
  height: 60px;
  font-size: 1.75rem;
  font-weight: 700;
  text-align: center;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.code-box:focus {
  border-color: var(--color-brand);
  box-shadow: var(--shadow-glow);
  outline: none;
}

/* Hide number spinners */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

/* Checkboxes */
input[type="checkbox"] {
  accent-color: var(--color-brand);
  cursor: pointer;
}

.big-checkbox { width: 22px; height: 22px; margin-right: 12px !important; }

.list-group-item { border-radius: var(--radius-md) !important; margin-bottom: 0.5rem !important; }

/* ============================================================
   SweetAlert overrides
   ============================================================ */
.swal2-popup a {
  word-break: break-all;
  display: block;
  margin-top: 5px;
  font-size: 0.9rem;
}

/* ============================================================
   Hero Section (Landing Page)
   ============================================================ */
.hero-section {
  background: var(--gradient-hero);
  border-radius: var(--radius-xl);
  padding: 5rem 2rem 4.5rem;
  color: #fff;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: -40%;
  left: -10%;
  width: 55%;
  height: 200%;
  background: radial-gradient(ellipse, rgba(147, 197, 253, 0.12) 0%, transparent 70%);
  pointer-events: none;
}

.hero-section h1 {
  color: #fff !important;
  font-size: clamp(2rem, 5vw, 3.25rem);
  letter-spacing: -0.04em;
  margin-bottom: 1rem;
}

.hero-section .lead {
  color: rgba(255, 255, 255, 0.75);
  font-size: 1.15rem;
  max-width: 580px;
  margin: 0 auto 2rem;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
  padding: 0.35rem 1rem;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 1.5rem;
}

/* ============================================================
   Feature Cards (Landing Page)
   ============================================================ */
.feature-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
  height: 100%;
}

.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--acta-blue-200);
}

.feature-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  margin: 0 auto 1.25rem;
}

.feature-icon-blue   { background: var(--acta-blue-50);  color: var(--acta-blue-600); }
.feature-icon-green  { background: #ecfdf5; color: var(--acta-emerald); }
.feature-icon-amber  { background: #fffbeb; color: var(--acta-amber); }
.feature-icon-violet { background: #f5f3ff; color: var(--acta-violet); }
.feature-icon-rose   { background: #fff1f2; color: var(--acta-rose); }
.feature-icon-slate  { background: var(--acta-slate-100); color: var(--acta-slate-700); }

/* Benefits / Security cards on landing page */
.security-card,
.benefits-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 2.5rem;
  margin-top: 3rem;
  border: 1px solid var(--color-border);
}

/* ============================================================
   Session Header Card
   ============================================================ */
.session-header-card {
  background: var(--gradient-hero);
  border: none;
  border-radius: var(--radius-lg);
  color: #fff;
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-md);
}

.session-header-card .case-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  margin: 0;
}

.session-header-card .case-address {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.875rem;
  margin: 0.2rem 0 0;
}

/* ============================================================
   Dashboard Welcome Card
   ============================================================ */
.welcome-card {
  background: var(--gradient-hero);
  border: none;
  border-radius: var(--radius-lg);
  color: #fff;
  padding: 1.5rem 2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-md);
}

/* ============================================================
   Property List Items (Dashboard)
   ============================================================ */
#properties-list .list-group-item,
#shared-list .list-group-item {
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-md) !important;
  margin-bottom: 0.5rem !important;
  padding: 0.875rem 1rem;
  background: var(--color-surface);
  transition: all var(--transition-fast);
  cursor: pointer;
}

#properties-list .list-group-item:hover,
#shared-list .list-group-item:hover {
  background: var(--acta-blue-50);
  border-color: var(--acta-blue-200) !important;
  transform: translateX(2px);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   Document List
   ============================================================ */
#docs-list .list-group-item {
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-sm) !important;
  margin-bottom: 0.375rem !important;
  padding: 0.7rem 0.875rem;
  transition: background var(--transition-fast);
}

#docs-list .list-group-item:hover {
  background: var(--acta-blue-50);
  border-color: var(--acta-blue-200) !important;
}

.doc-menu {
  border-top: 1px solid var(--color-border);
  padding-top: 8px;
}

/* ============================================================
   Upload Zone
   ============================================================ */
.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  background: var(--acta-slate-50);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.upload-zone:hover {
  border-color: var(--acta-blue-300);
  background: var(--acta-blue-50);
}

/* ============================================================
   Chat Window
   ============================================================ */
#chat-window {
  position: fixed;
  bottom: 0;
  right: 24px;
  width: 50vw;
  min-height: 400px;
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border);
  border-bottom: none;
  z-index: 1055;
  transform: translateY(100%);
  opacity: 0;
  transition: transform var(--transition-slow), opacity var(--transition-slow);
}

/* Support both .open and .active class names used by JS */
#chat-window.open,
#chat-window.active {
  transform: translateY(0);
  opacity: 1;
}

#chat-box {
  display: flex;
  flex-direction: column-reverse;
  max-height: 60vh;
  min-height: 220px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--acta-slate-50);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  padding: 1rem;
}

#chat-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 1050;
  backdrop-filter: blur(2px);
}

#chat-toggle {
  position: fixed;
  bottom: 5px;
  right: 25px;
  z-index: 1050;
  width: 100px;
  height: 60px;
  font-size: 2rem;
  border-radius: var(--radius-lg);
}

/* ============================================================
   Mentions
   ============================================================ */
.mention {
  background: var(--color-brand) !important;
  color: #fff !important;
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  font-weight: 600;
  font-size: 0.875em;
}

.mention-suggestions {
  position: absolute;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 9999;
  max-height: 180px;
  overflow-y: auto;
}

.mention-suggestions div {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.875rem;
  transition: background var(--transition-fast);
}

.mention-suggestions div:hover {
  background: var(--acta-blue-50);
  color: var(--color-brand);
}

/* ============================================================
   Excluded Users
   ============================================================ */
#excluded-users {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex-wrap: nowrap;
  min-height: 50px;
  margin-top: 10px;
  padding: 0.75rem;
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: var(--radius-md);
  overflow-y: auto;
  max-height: 250px;
}

/* ============================================================
   Property Notes (Notepad Style)
   ============================================================ */
@font-face {
  font-family: 'Patrick Hand';
  src: url('PatrickHand-Regular.ttf') format('truetype');
}

#property-notes {
  font-family: 'Patrick Hand', cursive;
  font-size: 1rem;
  line-height: 28px;
  background: #fffef7;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 27px,
    rgba(59, 130, 246, 0.08) 28px
  );
  border: 1.5px solid #e8dfc8;
  border-radius: var(--radius-md);
  padding: 5px 20px;
  color: #333;
  box-shadow: var(--shadow-xs);
  min-height: 300px;
}

/* Notes Toolbar */
.notes-toolbar button {
  border: 1px solid var(--color-border);
  background: var(--acta-slate-100);
  margin-right: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  transition: background var(--transition-fast);
}
.notes-toolbar button:hover { background: var(--acta-slate-200); }

/* ============================================================
   Checklist
   ============================================================ */
#checklist .list-group-item {
  border-radius: var(--radius-md) !important;
  margin-bottom: 0.5rem !important;
  border: 1px solid var(--color-border) !important;
  padding: 0.875rem 1rem;
  transition: background var(--transition-fast);
}

/* ============================================================
   Redact Canvas
   ============================================================ */
#redactCanvas { touch-action: none; }

/* ============================================================
   Presence Indicator
   ============================================================ */
.presence-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  vertical-align: middle;
  margin-right: 6px;
  transform-origin: center;
}

.presence-dot.text-success {
  animation: pulse 1.8s ease-in-out infinite;
}

/* ============================================================
   Tooltip
   ============================================================ */
.tooltip-btn {
  position: relative;
  background: none;
  border: none;
}

.tooltip-text {
  display: none;
  opacity: 0;
  transition: opacity 0.2s;
  position: absolute;
  top: 120%;
  left: 0;
  background: var(--acta-slate-900);
  color: #fff;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  white-space: nowrap;
  z-index: 1000;
  box-shadow: var(--shadow-md);
}

.tooltip-btn:hover .tooltip-text {
  display: block;
  opacity: 1;
}

.linked-doc-label { cursor: pointer; }

/* ============================================================
   Animations
   ============================================================ */
@keyframes pulse {
  0%   { transform: scale(1);    opacity: 1;   }
  50%  { transform: scale(1.25); opacity: 0.6; }
  100% { transform: scale(1);    opacity: 1;   }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

.animate-fade-in  { animation: fadeInUp 0.35s ease both; }
.animate-slide-in { animation: slideInRight 0.35s ease both; }

.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 50ms; }
.stagger-children > *:nth-child(3) { animation-delay: 100ms; }
.stagger-children > *:nth-child(4) { animation-delay: 150ms; }
.stagger-children > *:nth-child(5) { animation-delay: 200ms; }

/* ============================================================
   Bootstrap Overrides
   ============================================================ */
.bg-secondary { background-color: var(--acta-slate-100) !important; }
.bg-light     { background-color: var(--color-bg) !important; }
.bg-dark      { background-color: var(--acta-slate-800) !important; }
.text-muted   { color: var(--color-text-secondary) !important; }

.small { font-size: 0.8em !important; }

.badge {
  border-radius: var(--radius-full);
  font-weight: 500;
  font-size: 0.75rem;
  padding: 0.3em 0.7em;
}

.alert {
  border-radius: var(--radius-md);
  border-width: 1px;
  padding: 0.6rem 1rem !important;
}

.accordion-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md) !important;
  margin-bottom: 0.5rem;
  overflow: hidden;
}

.accordion-button:not(.collapsed) {
  background: var(--acta-blue-50);
  color: var(--acta-blue-700);
  box-shadow: none;
}

.accordion-button:focus { box-shadow: var(--shadow-glow); }

.accordion-button i {
  color: var(--color-brand);
  width: 22px;
  text-align: center;
  margin-right: 10px;
}

.modal-content {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  border-bottom: 1px solid var(--color-border);
  padding: 1.25rem 1.5rem;
}

/* ============================================================
   Legacy Colour Helpers
   ============================================================ */
.bg-light-green { background: #ecfdf5; }
.bg-light-dark  { background: var(--acta-slate-800); }
.bg-owner       { background: var(--acta-blue-50) !important; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 767px) {
  #chat-window {
    width: 100vw;
    right: 0;
  }

  #chat-box {
    max-height: 30vh;
    min-height: 180px;
  }

  .hero-section {
    padding: 3rem 1.25rem;
  }
}
