/* ==========================================================================
   ChambersOS — iOS-Inspired Design System & Styling
   Legal Practice Management CRM for India (DEMO)
   ========================================================================== */

:root {
  /* Core Color Palette (Light Mode Default) */
  --bg-canvas: #F5F7FB;
  --bg-surface: #FFFFFF;
  --bg-surface-glass: rgba(255, 255, 255, 0.85);
  --bg-surface-elevated: #FFFFFF;
  --bg-sidebar: rgba(248, 250, 252, 0.92);
  --bg-card: #FFFFFF;
  --bg-card-hover: #F8FAFC;
  --bg-input: #F1F5F9;
  --bg-input-focus: #FFFFFF;
  --bg-badge: #F1F5F9;

  /* Borders & Dividers */
  --border-subtle: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.14);
  --border-glass: rgba(255, 255, 255, 0.7);

  /* Typography Colors */
  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-tertiary: #94A3B8;
  --text-inverse: #FFFFFF;

  /* Accent Colors (Apple / iOS System Colors) */
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-soft: rgba(37, 99, 235, 0.1);
  --primary-border: rgba(37, 99, 235, 0.25);

  --success: #16A34A;
  --success-soft: rgba(22, 163, 74, 0.12);
  --success-border: rgba(22, 163, 74, 0.25);

  --warning: #F59E0B;
  --warning-soft: rgba(245, 158, 11, 0.12);
  --warning-border: rgba(245, 158, 11, 0.25);

  --danger: #DC2626;
  --danger-soft: rgba(220, 38, 38, 0.12);
  --danger-border: rgba(220, 38, 38, 0.25);

  --purple: #8B5CF6;
  --purple-soft: rgba(139, 92, 246, 0.12);

  --teal: #0D9488;
  --teal-soft: rgba(13, 148, 136, 0.12);

  /* Radius System */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows (Soft Apple System Shadows) */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 16px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 12px 32px -4px rgba(15, 23, 42, 0.08), 0 4px 12px -2px rgba(15, 23, 42, 0.04);
  --shadow-modal: 0 24px 48px -12px rgba(15, 23, 42, 0.16), 0 8px 24px -6px rgba(15, 23, 42, 0.08);

  /* Glass Blur */
  --blur-glass: blur(18px);
  --blur-overlay: blur(10px);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-base: 250ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 350ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Layout dimensions */
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 76px;
  --header-height: 68px;
}

/* Dark Mode Overrides */
[data-theme="dark"] {
  --bg-canvas: #0B0F19;
  --bg-surface: #131B2E;
  --bg-surface-glass: rgba(19, 27, 46, 0.88);
  --bg-surface-elevated: #182239;
  --bg-sidebar: rgba(14, 20, 36, 0.94);
  --bg-card: #141E34;
  --bg-card-hover: #192540;
  --bg-input: #1C2742;
  --bg-input-focus: #141E34;
  --bg-badge: #1C2742;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-glass: rgba(255, 255, 255, 0.12);

  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-tertiary: #64748B;
  --text-inverse: #0F172A;

  --primary: #3B82F6;
  --primary-hover: #60A5FA;
  --primary-soft: rgba(59, 130, 246, 0.2);
  --primary-border: rgba(59, 130, 246, 0.35);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px -4px rgba(0, 0, 0, 0.5);
  --shadow-modal: 0 24px 48px -12px rgba(0, 0, 0, 0.7);
}

/* Global Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  overflow-x: hidden;
}

/* App Shell Structure */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100vw;
  background-color: var(--bg-canvas);
  position: relative;
}

/* ==========================================================================
   Sidebar Navigation
   ========================================================================== */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: sticky;
  top: 0;
  background: var(--bg-sidebar);
  backdrop-filter: var(--blur-glass);
  -webkit-backdrop-filter: var(--blur-glass);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-base), transform var(--transition-base);
  z-index: 100;
  flex-shrink: 0;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

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

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  overflow: hidden;
}

.brand-logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #2563EB, #1D4ED8);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  transition: opacity var(--transition-fast);
}

.sidebar.collapsed .brand-text {
  display: none;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-name {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.demo-pill {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: var(--warning-soft);
  color: #B45309;
  border: 1px solid var(--warning-border);
}

.brand-tagline {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.sidebar-collapse-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.sidebar-collapse-btn:hover {
  background: var(--bg-badge);
  color: var(--text-primary);
}

/* Nav Menu */
.sidebar-nav {
  flex: 1;
  padding: 16px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  padding: 10px 12px 4px;
  transition: opacity var(--transition-fast);
}

.sidebar.collapsed .nav-section-label {
  display: none;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 13.5px;
  transition: all var(--transition-fast);
  position: relative;
  white-space: nowrap;
}

.nav-link:hover {
  background: var(--bg-badge);
  color: var(--text-primary);
}

.nav-link.active {
  background: var(--primary);
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.nav-link i {
  font-size: 18px;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar.collapsed .nav-link {
  justify-content: center;
  padding: 10px;
}

.sidebar.collapsed .nav-link span,
.sidebar.collapsed .nav-link .nav-counter {
  display: none;
}

.nav-counter {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--bg-badge);
  color: var(--text-secondary);
}

.nav-link.active .nav-counter {
  background: rgba(255, 255, 255, 0.25);
  color: #FFFFFF;
}

/* Sidebar Footer Profile */
.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid var(--border-subtle);
  background: inherit;
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.user-profile-badge:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #475569, #1E293B);
  color: #FFFFFF;
  font-weight: 600;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  text-align: left;
}

.sidebar.collapsed .user-info {
  display: none;
}

.user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

/* Top Navigation Bar (Frosted Glass Floating Header) */
.top-header {
  height: var(--header-height);
  position: sticky;
  top: 0;
  z-index: 90;
  background: var(--bg-surface-glass);
  backdrop-filter: var(--blur-glass);
  -webkit-backdrop-filter: var(--blur-glass);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-title-group {
  display: flex;
  flex-direction: column;
}

.breadcrumb-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.page-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.header-center {
  flex: 1;
  max-width: 440px;
}

/* Global Search Input (iOS Spotlight look) */
.search-pill-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid transparent;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.search-pill-box:hover,
.search-pill-box:focus-within {
  background: var(--bg-input-focus);
  border-color: var(--primary-border);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.search-pill-box i {
  color: var(--text-tertiary);
  font-size: 16px;
}

.search-pill-input {
  border: none;
  background: transparent;
  width: 100%;
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
}

.search-shortcut-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* Header Right Actions */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.quick-create-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--primary);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.quick-create-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.quick-create-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 300;
  animation: fadeIn 150ms ease;
}

.quick-create-dropdown.active {
  display: block !important;
}

.quick-create-dropdown .dropdown-item {
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background var(--transition-fast);
}

.quick-create-dropdown .dropdown-item:hover {
  background: var(--bg-badge);
}

.header-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
}

.header-icon-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.notification-badge {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: var(--radius-full);
  box-shadow: 0 0 0 2px var(--bg-surface);
}

.demo-reset-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--warning-border);
  background: var(--warning-soft);
  color: #B45309;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

[data-theme="dark"] .demo-reset-btn {
  color: #FBBF24;
}

.demo-reset-btn:hover {
  background: var(--warning);
  color: #FFFFFF;
}

/* ==========================================================================
   Content Viewport & Cards
   ========================================================================== */
.content-area {
  flex: 1;
  padding: 26px 28px 48px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

.view-section {
  display: none;
  animation: fadeIn 200ms ease;
}

.view-section.active {
  display: block;
}

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

/* Card Surface Standard */
.ios-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
  overflow: hidden;
}

.ios-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title-group {
  display: flex;
  flex-direction: column;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.card-body {
  padding: 20px 22px;
}

/* ==========================================================================
   Dashboard Widgets & KPI Cards
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px 18px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-border);
}

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.kpi-icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.kpi-icon-wrap.blue { background: var(--primary-soft); color: var(--primary); }
.kpi-icon-wrap.green { background: var(--success-soft); color: var(--success); }
.kpi-icon-wrap.amber { background: var(--warning-soft); color: #D97706; }
.kpi-icon-wrap.red { background: var(--danger-soft); color: var(--danger); }
.kpi-icon-wrap.purple { background: var(--purple-soft); color: var(--purple); }

.kpi-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.kpi-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Dashboard 2-column layouts */
.dashboard-grid-main {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.dashboard-grid-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* Action Quick Bar */
.quick-actions-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.action-pill-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.action-pill-btn:hover {
  background: var(--bg-badge);
  color: var(--text-primary);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.action-pill-btn.primary {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary-border);
}

.action-pill-btn.primary:hover {
  background: var(--primary);
  color: #FFFFFF;
}

/* ==========================================================================
   Kanban Pipeline (Critical Feature)
   ========================================================================== */
.kanban-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.kanban-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-select {
  padding: 7px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 13px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.filter-select:focus {
  border-color: var(--primary);
}

.kanban-board-container {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 18px;
  min-height: calc(100vh - 250px);
  scroll-snap-type: x mandatory;
}

.kanban-column {
  flex: 0 0 310px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 240px);
  transition: background var(--transition-fast), border var(--transition-fast);
  scroll-snap-align: start;
}

.kanban-column.drag-over {
  background: rgba(37, 99, 235, 0.06);
  border: 2px dashed var(--primary);
}

.column-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.col-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.col-badge-indicator {
  width: 9px;
  height: 9px;
  border-radius: var(--radius-full);
}

.col-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: capitalize;
}

.col-count-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--bg-badge);
  color: var(--text-secondary);
}

.col-quick-add-btn {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.col-quick-add-btn:hover {
  background: var(--bg-badge);
  color: var(--primary);
}

.column-cards-container {
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

/* Kanban Matter Card */
.matter-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 14px;
  box-shadow: var(--shadow-sm);
  cursor: grab;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast), opacity var(--transition-fast);
  position: relative;
  user-select: none;
}

.matter-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.matter-card:active {
  cursor: grabbing;
}

.matter-card.dragging {
  opacity: 0.45;
  transform: scale(0.97);
  box-shadow: var(--shadow-lg);
}

.matter-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.matter-id-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  font-family: monospace;
}

.priority-pill {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.priority-pill.urgent { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-border); }
.priority-pill.high { background: var(--warning-soft); color: #B45309; border: 1px solid var(--warning-border); }
.priority-pill.medium { background: var(--primary-soft); color: var(--primary); border: 1px solid var(--primary-border); }
.priority-pill.low { background: var(--bg-badge); color: var(--text-secondary); }

.matter-card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.matter-card-client {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.matter-card-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11.5px;
  color: var(--text-tertiary);
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hearing-pill-next {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: rgba(37, 99, 235, 0.08);
  color: var(--primary);
  margin-top: 6px;
}

.card-footer-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-subtle);
  font-size: 11px;
}

.advocate-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ==========================================================================
   Tables & Lists
   ========================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.ios-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.ios-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-card);
}

.ios-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: middle;
}

.ios-table tr:hover td {
  background: var(--bg-card-hover);
}

.ios-table tr:last-child td {
  border-bottom: none;
}

/* Status Badges */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-full);
}

.status-pill.active,
.status-pill.paid,
.status-pill.completed,
.status-pill.success {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.status-pill.pending,
.status-pill.in_progress,
.status-pill.partially_paid,
.status-pill.sent {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--primary-border);
}

.status-pill.overdue,
.status-pill.failed,
.status-pill.cancelled {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.status-pill.draft,
.status-pill.lead,
.status-pill.todo,
.status-pill.skipped {
  background: var(--bg-badge);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Modals & Drawers (iOS Glass & Sheet Style)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: var(--blur-overlay);
  -webkit-backdrop-filter: var(--blur-overlay);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modalFadeIn 180ms ease;
}

.modal-overlay.active {
  display: flex;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-container {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-glass);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalSlideUp 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-container.large {
  max-width: 860px;
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--bg-input);
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.modal-close-btn:hover {
  background: var(--bg-badge);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background: var(--bg-surface);
}

/* Slide-out Drawer (Sheet style) */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: var(--blur-overlay);
  -webkit-backdrop-filter: var(--blur-overlay);
  z-index: 1000;
  display: none;
  justify-content: flex-end;
  animation: modalFadeIn 180ms ease;
}

.drawer-overlay.active {
  display: flex;
}

.drawer-container {
  background: var(--bg-surface);
  width: 100%;
  max-width: 720px;
  height: 100vh;
  box-shadow: var(--shadow-modal);
  border-left: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  animation: drawerSlideIn 260ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes drawerSlideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.drawer-header {
  padding: 20px 26px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-body {
  padding: 24px 26px;
  overflow-y: auto;
  flex: 1;
}

/* Tabs Inside Drawer / Cards */
.drawer-tabs-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 26px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-card);
  overflow-x: auto;
}

.tab-btn {
  padding: 12px 14px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  transition: color var(--transition-fast);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--primary);
  font-weight: 600;
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
  border-radius: var(--radius-full);
}

.tab-content {
  display: none;
  padding-top: 16px;
  animation: fadeIn 180ms ease;
}

.tab-content.active {
  display: block;
}

/* ==========================================================================
   Form Controls & Elements
   ========================================================================== */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px 13px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: all var(--transition-fast);
}

.form-control:focus {
  background: var(--bg-surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.form-row.three {
  grid-template-columns: repeat(3, 1fr);
}

.form-helper {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* Button System */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-badge);
  color: var(--text-primary);
}

.btn-success {
  background: var(--success);
  color: #FFFFFF;
}

.btn-success:hover {
  background: #15803D;
}

.btn-danger {
  background: var(--danger);
  color: #FFFFFF;
}

.btn-danger:hover {
  background: #B91C1C;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   Communications Hub (WhatsApp Style Simulator)
   ========================================================================== */
.chat-container {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - 200px);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.chat-sidebar {
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
}

.chat-sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.chat-thread-list {
  overflow-y: auto;
  flex: 1;
}

.chat-thread-item {
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}

.chat-thread-item:hover {
  background: var(--bg-card-hover);
}

.chat-thread-item.active {
  background: var(--primary-soft);
  border-left: 3px solid var(--primary);
}

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: #25D366;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.chat-thread-meta {
  flex: 1;
  overflow: hidden;
}

.chat-thread-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
}

.chat-thread-snippet {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* Chat Main Pane */
.chat-main-pane {
  display: flex;
  flex-direction: column;
  background: var(--bg-input);
}

.chat-pane-header {
  padding: 12px 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-messages-area {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-bubble {
  max-width: 65%;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  line-height: 1.45;
  position: relative;
  word-break: break-word;
}

.chat-bubble.chamber {
  align-self: flex-end;
  background: #DCF8C6;
  color: #0F172A;
  border-bottom-right-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .chat-bubble.chamber {
  background: #056162;
  color: #E2E8F0;
}

.chat-bubble.client {
  align-self: flex-start;
  background: var(--bg-surface);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--border-subtle);
}

.bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 10px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* Chat Composer Bar */
.chat-composer-bar {
  padding: 14px 20px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.template-selector-row {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.template-pill {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.template-pill:hover {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary-border);
}

.composer-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-send-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  background: #25D366;
  border: none;
  color: #FFFFFF;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px rgba(37, 211, 102, 0.35);
}

.chat-send-btn:hover {
  transform: scale(1.05);
}

/* ==========================================================================
   Automation Studio
   ========================================================================== */
.automation-rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.automation-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all var(--transition-fast);
}

.automation-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.auto-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.auto-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.auto-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 14px;
}

.auto-steps-flow {
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 11.5px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.auto-step-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auto-step-pill {
  font-weight: 700;
  font-size: 9.5px;
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  text-transform: uppercase;
}

.auto-step-pill.trigger { background: var(--warning-soft); color: #B45309; }
.auto-step-pill.action { background: var(--success-soft); color: var(--success); }

/* iOS Switch Toggle */
.ios-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.ios-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-round {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--border-strong);
  transition: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 34px;
}

.slider-round:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.ios-switch input:checked + .slider-round {
  background-color: var(--success);
}

.ios-switch input:checked + .slider-round:before {
  transform: translateX(20px);
}

/* ==========================================================================
   Printable Invoice View
   ========================================================================== */
.invoice-print-container {
  background: #FFFFFF;
  color: #0F172A;
  padding: 36px 40px;
  border-radius: var(--radius-lg);
  font-family: 'Inter', sans-serif;
  box-shadow: var(--shadow-sm);
  max-width: 800px;
  margin: 0 auto;
}

.invoice-header-legal {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 2px solid #0F172A;
  padding-bottom: 20px;
  margin-bottom: 24px;
}

.legal-firm-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #0F172A;
}

.legal-firm-meta {
  font-size: 11.5px;
  color: #475569;
  line-height: 1.5;
  margin-top: 4px;
}

.invoice-title-large {
  font-size: 26px;
  font-weight: 800;
  color: #2563EB;
  text-align: right;
}

.invoice-parties-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-bottom: 28px;
}

.invoice-party-box {
  font-size: 12.5px;
  line-height: 1.5;
  color: #334155;
}

.party-heading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748B;
  margin-bottom: 6px;
}

.invoice-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

.invoice-items-table th {
  background: #F8FAFC;
  border-top: 1px solid #CBD5E1;
  border-bottom: 1px solid #CBD5E1;
  padding: 10px 14px;
  font-size: 11.5px;
  font-weight: 700;
  text-align: left;
  color: #334155;
}

.invoice-items-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #E2E8F0;
  font-size: 12.5px;
  color: #1E293B;
}

.invoice-summary-box {
  margin-left: auto;
  width: 280px;
  margin-bottom: 30px;
}

.summary-line-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 12.5px;
  color: #475569;
}

.summary-line-item.total {
  border-top: 2px solid #0F172A;
  border-bottom: 2px solid #0F172A;
  padding: 8px 0;
  margin-top: 6px;
  font-weight: 800;
  font-size: 15px;
  color: #0F172A;
}

.invoice-signatory-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px dashed #CBD5E1;
}

/* Print CSS */
@media print {
  body {
    background: #FFFFFF !important;
    color: #000000 !important;
  }
  .sidebar, .top-header, .quick-actions-bar, .modal-header, .modal-footer, .no-print {
    display: none !important;
  }
  .modal-overlay {
    position: static !important;
    background: transparent !important;
    padding: 0 !important;
  }
  .modal-container {
    box-shadow: none !important;
    border: none !important;
    max-width: 100% !important;
  }
  .invoice-print-container {
    padding: 0 !important;
    box-shadow: none !important;
  }
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 300px;
  max-width: 420px;
  background: var(--bg-surface-glass);
  backdrop-filter: var(--blur-glass);
  -webkit-backdrop-filter: var(--blur-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: toastSlideIn 240ms cubic-bezier(0.16, 1, 0.3, 1);
  color: var(--text-primary);
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--primary); }

.toast-content {
  flex: 1;
}

.toast-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.toast-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .dashboard-grid-main {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: -260px;
    z-index: 1000;
  }
  .sidebar.mobile-open {
    left: 0;
  }
  .top-header {
    padding: 0 16px;
  }
  .content-area {
    padding: 16px 14px 40px;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dashboard-grid-bottom {
    grid-template-columns: 1fr;
  }
  .chat-container {
    grid-template-columns: 1fr;
  }
  .chat-sidebar {
    display: none;
  }
  .chat-sidebar.mobile-visible {
    display: flex;
  }
  .kanban-column {
    flex: 0 0 280px;
  }
}

@media (max-width: 520px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .form-row, .form-row.three {
    grid-template-columns: 1fr;
  }
}
