/* ==========================================================================
   HL Verwaltung & Service UG - Property Management Dashboard
   Production CSS - Hand-crafted following Tailwind design system aesthetics
   ========================================================================== */

/* --------------------------------------------------------------------------
   FONTS
   -------------------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* --------------------------------------------------------------------------
   CSS CUSTOM PROPERTIES - LIGHT MODE (default)
   -------------------------------------------------------------------------- */
:root {
  /* Background & Surface */
  --bg: #F8FAFC;
  --surface: #FFFFFF;

  /* Sidebar */
  --sidebar-bg: #0F172A;
  --sidebar-text: #CBD5E1;
  --sidebar-active: #4F46E5;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.06);
  --sidebar-border: rgba(255, 255, 255, 0.08);

  /* Brand / Primary */
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-light: #EEF2FF;
  --primary-ring: rgba(79, 70, 229, 0.25);

  /* Semantic Colors */
  --success: #059669;
  --success-light: #ECFDF5;
  --warning: #D97706;
  --warning-light: #FFFBEB;
  --danger: #DC2626;
  --danger-light: #FEF2F2;
  --info: #2563EB;
  --info-light: #EFF6FF;

  /* Text */
  --text: #1E293B;
  --text-secondary: #64748B;
  --text-tertiary: #94A3B8;

  /* Borders & Dividers */
  --border: #E2E8F0;
  --border-hover: #CBD5E1;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);

  /* Sidebar Dimensions */
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 64px;

  /* Header */
  --header-height: 56px;

  /* Spacing Scale (4px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* Border Radius */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  /* Transition */
  --transition: 150ms ease;
  --transition-slow: 250ms ease;

  /* Z-index Scale */
  --z-sidebar: 40;
  --z-header: 30;
  --z-overlay: 50;
  --z-modal: 60;
}

/* --------------------------------------------------------------------------
   CSS CUSTOM PROPERTIES - DARK MODE
   -------------------------------------------------------------------------- */
[data-theme="dark"] {
  --bg: #0F172A;
  --surface: #1E293B;
  --sidebar-bg: #020617;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.04);
  --sidebar-border: rgba(255, 255, 255, 0.06);
  --text: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-tertiary: #64748B;
  --border: #334155;
  --border-hover: #475569;
  --primary-light: rgba(79, 70, 229, 0.15);
  --success-light: rgba(5, 150, 105, 0.15);
  --warning-light: rgba(217, 119, 6, 0.15);
  --danger-light: rgba(220, 38, 38, 0.15);
  --info-light: rgba(37, 99, 235, 0.15);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.25), 0 2px 4px -2px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
}

/* --------------------------------------------------------------------------
   RESET & BASE
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--primary-hover);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* --------------------------------------------------------------------------
   1. LAYOUT
   -------------------------------------------------------------------------- */

/* --- App Shell --- */
.app {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  transition: width var(--transition-slow);
  overflow: hidden;
}

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

/* --- Main Content --- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  transition: margin-left var(--transition-slow);
}

.sidebar-collapsed .main-content {
  margin-left: var(--sidebar-collapsed-width);
}

.main-content-inner {
  padding: var(--space-6) var(--space-8);
  max-width: 1440px;
}

/* --- Header --- */
.header {
  position: sticky;
  top: 0;
  height: var(--header-height);
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-8);
  z-index: var(--z-header);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* Breadcrumbs */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.breadcrumbs a {
  color: var(--text-secondary);
}

.breadcrumbs a:hover {
  color: var(--text);
}

.breadcrumbs .separator {
  color: var(--text-tertiary);
  font-size: 0.75rem;
}

.breadcrumbs .current {
  color: var(--text);
  font-weight: 500;
}

/* Hamburger Menu (mobile) */
.menu-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
  border-radius: var(--radius);
  transition: background-color var(--transition);
}

.menu-toggle:hover {
  background-color: var(--primary-light);
}

/* User area in header */
.header-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius);
  transition: background-color var(--transition);
}

.header-user:hover {
  background-color: var(--primary-light);
}

.header-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background-color: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 600;
}

.header-user-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
}

/* --------------------------------------------------------------------------
   2. SIDEBAR COMPONENTS
   -------------------------------------------------------------------------- */

/* --- Logo Area --- */
.sidebar-logo {
  padding: var(--space-6);
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 72px;
  flex-shrink: 0;
}

.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  background-color: var(--primary);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #F1F5F9;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-collapsed .sidebar-logo-text {
  opacity: 0;
  width: 0;
}

/* --- Navigation --- */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-3) var(--space-3);
}

/* Scrollbar styling for sidebar */
.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
}

/* Nav Item */
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-size: 0.8125rem;
  font-weight: 450;
  cursor: pointer;
  transition: background-color var(--transition), color var(--transition);
  position: relative;
  white-space: nowrap;
  margin-bottom: 2px;
  text-decoration: none;
}

.nav-item:hover {
  background-color: var(--sidebar-hover-bg);
  color: #F1F5F9;
}

.nav-item.active {
  background-color: rgba(79, 70, 229, 0.12);
  color: #A5B4FC;
  border-left: 3px solid var(--sidebar-active);
  padding-left: 11px;
}

.nav-item.active .nav-icon {
  color: #A5B4FC;
}

/* Disabled / Coming Soon */
.nav-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.nav-item .badge-soon {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--sidebar-text);
  background-color: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: var(--radius-full);
  margin-left: auto;
  white-space: nowrap;
}

/* Nav Icon */
.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sidebar-text);
  transition: color var(--transition);
}

/* Nav Label */
.nav-label {
  overflow: hidden;
  transition: opacity var(--transition-slow), width var(--transition-slow);
}

.sidebar-collapsed .nav-label,
.sidebar-collapsed .badge-soon {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

/* Section Divider */
.nav-divider {
  padding: var(--space-4) var(--space-4) var(--space-2);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.nav-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background-color: var(--sidebar-border);
}

.sidebar-collapsed .nav-divider {
  padding: var(--space-3) 0;
  justify-content: center;
}

.sidebar-collapsed .nav-divider span {
  display: none;
}

.sidebar-collapsed .nav-divider::after {
  flex: none;
  width: 24px;
}

/* --- Sidebar Bottom --- */
.sidebar-bottom {
  padding: var(--space-4);
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: var(--space-2);
  border: none;
  background: none;
  color: var(--sidebar-text);
  cursor: pointer;
  border-radius: var(--radius);
  transition: background-color var(--transition);
}

.sidebar-toggle-btn:hover {
  background-color: var(--sidebar-hover-bg);
}

/* Theme Toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  border-radius: var(--radius);
  border: none;
  background: none;
  color: var(--sidebar-text);
  font-size: 0.8125rem;
  width: 100%;
  transition: background-color var(--transition);
}

.theme-toggle:hover {
  background-color: var(--sidebar-hover-bg);
}

/* --------------------------------------------------------------------------
   3. KPI CARDS
   -------------------------------------------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-6);
}

.kpi-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}

.kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.kpi-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

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

.kpi-icon-primary {
  background-color: var(--primary-light);
  color: var(--primary);
}

.kpi-icon-success {
  background-color: var(--success-light);
  color: var(--success);
}

.kpi-icon-warning {
  background-color: var(--warning-light);
  color: var(--warning);
}

.kpi-icon-danger {
  background-color: var(--danger-light);
  color: var(--danger);
}

.kpi-icon-info {
  background-color: var(--info-light);
  color: var(--info);
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: var(--space-1);
}

.kpi-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  margin-top: var(--space-2);
}

.kpi-trend-up {
  color: var(--success);
}

.kpi-trend-down {
  color: var(--danger);
}

.kpi-trend-neutral {
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   4. DATA TABLE
   -------------------------------------------------------------------------- */
.table-container {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.table-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.table-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead th {
  background-color: var(--bg);
  padding: var(--space-3) var(--space-4);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  text-align: left;
  white-space: nowrap;
  position: sticky;
  top: 0;
  border-bottom: 1px solid var(--border);
}

.data-table thead th.text-right {
  text-align: right;
}

.data-table tbody tr {
  transition: background-color var(--transition);
  cursor: pointer;
}

.data-table tbody tr:hover {
  background-color: rgba(79, 70, 229, 0.04);
}

[data-theme="dark"] .data-table tbody tr:hover {
  background-color: rgba(79, 70, 229, 0.08);
}

.data-table tbody tr:nth-child(even) {
  background-color: rgba(248, 250, 252, 0.5);
}

[data-theme="dark"] .data-table tbody tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.02);
}

.data-table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--text);
  vertical-align: middle;
}

.data-table tbody td.text-right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table tbody td.text-mono {
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', monospace;
  font-size: 0.8125rem;
}

/* Empty state */
.table-empty {
  padding: var(--space-8);
  text-align: center;
  color: var(--text-secondary);
}

.table-empty-icon {
  font-size: 2rem;
  margin-bottom: var(--space-3);
  opacity: 0.4;
}

/* Pagination */
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.table-pagination-controls {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.table-pagination-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background-color: var(--surface);
  color: var(--text-secondary);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.8125rem;
}

.table-pagination-btn:hover {
  background-color: var(--bg);
  color: var(--text);
  border-color: var(--border-hover);
}

.table-pagination-btn.active {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
}

.table-pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   5. STATUS BADGES
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 0.6875rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  white-space: nowrap;
  line-height: 1;
}

.badge-offen {
  background-color: var(--primary-light);
  color: var(--primary);
}

.badge-bearbeitung {
  background-color: var(--warning-light);
  color: var(--warning);
}

.badge-warte-gegenseite {
  background-color: rgba(100, 116, 139, 0.1);
  color: #64748B;
}

[data-theme="dark"] .badge-warte-gegenseite {
  background-color: rgba(148, 163, 184, 0.12);
  color: #94A3B8;
}

.badge-warte-gericht {
  background-color: var(--info-light);
  color: var(--info);
}

.badge-erledigt {
  background-color: var(--success-light);
  color: var(--success);
}

.badge-ueberfaellig {
  background-color: var(--danger-light);
  color: var(--danger);
  animation: pulse-badge 2s ease-in-out infinite;
}

.badge-archiviert {
  background-color: rgba(100, 116, 139, 0.08);
  color: var(--text-tertiary);
}

/* --------------------------------------------------------------------------
   6. BUTTONS
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 18px;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Primary */
.btn-primary {
  background-color: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-primary:active:not(:disabled) {
  background-color: #3730A3;
}

/* Secondary */
.btn-secondary {
  background-color: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--bg);
  border-color: var(--border-hover);
}

/* Danger */
.btn-danger {
  background-color: var(--danger);
  color: #FFFFFF;
  border-color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background-color: #B91C1C;
  border-color: #B91C1C;
}

/* Ghost */
.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background-color: var(--bg);
  color: var(--text);
}

/* Size Variants */
.btn-sm {
  padding: 6px 12px;
  font-size: 0.75rem;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 0.875rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
}

.btn-icon.btn-sm {
  width: 30px;
  height: 30px;
}

/* --------------------------------------------------------------------------
   7. FORMS
   -------------------------------------------------------------------------- */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: var(--space-2);
}

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

.form-input,
.form-select,
.form-textarea {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-tertiary);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
  border-color: var(--border-hover);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

/* Input Error State */
.form-input.is-error,
.form-select.is-error,
.form-textarea.is-error {
  border-color: var(--danger);
}

.form-input.is-error:focus,
.form-select.is-error:focus,
.form-textarea.is-error:focus {
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
}

.form-error {
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: var(--space-1);
}

/* Select with custom arrow */
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6L8 10L12 6' stroke='%2364748B' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

/* Textarea */
.form-textarea {
  min-height: 80px;
  resize: vertical;
}

/* Checkbox & Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.form-check-label {
  font-size: 0.8125rem;
  color: var(--text);
  cursor: pointer;
}

/* Search Input */
.form-search {
  position: relative;
}

.form-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}

.form-search .form-input {
  padding-left: 38px;
}

/* --------------------------------------------------------------------------
   8. CARDS
   -------------------------------------------------------------------------- */
.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

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

.card-header-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.card-body {
  padding: var(--space-5);
}

.card-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  background-color: var(--bg);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* --------------------------------------------------------------------------
   9. CHAT (Case Detail)
   -------------------------------------------------------------------------- */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 400px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background-color: var(--surface);
}

.chat-header {
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}

/* Chat Bubbles */
.chat-bubble {
  max-width: 75%;
  padding: var(--space-3) var(--space-4);
  font-size: 0.8125rem;
  line-height: 1.6;
  word-wrap: break-word;
}

.chat-bubble-user {
  align-self: flex-end;
  background-color: var(--primary);
  color: #FFFFFF;
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg);
}

.chat-bubble-ai {
  align-self: flex-start;
  background-color: var(--bg);
  color: var(--text);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-sm);
}

[data-theme="dark"] .chat-bubble-ai {
  background-color: rgba(255, 255, 255, 0.06);
}

.chat-bubble-meta {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

.chat-bubble-user .chat-bubble-meta {
  color: rgba(255, 255, 255, 0.7);
}

/* Chat Input */
.chat-input-area {
  padding: var(--space-4);
  border-top: 1px solid var(--border);
  background-color: var(--surface);
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
}

.chat-input-area .form-textarea {
  min-height: 42px;
  max-height: 120px;
  resize: none;
}

/* --------------------------------------------------------------------------
   10. FILE UPLOAD ZONE
   -------------------------------------------------------------------------- */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}

.upload-zone:hover {
  border-color: var(--border-hover);
  background-color: var(--bg);
}

.upload-zone.dragover {
  border-color: var(--primary);
  background-color: var(--primary-light);
}

.upload-zone-icon {
  font-size: 2rem;
  color: var(--text-tertiary);
  margin-bottom: var(--space-3);
}

.upload-zone-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.upload-zone-text strong {
  color: var(--primary);
}

.upload-zone-hint {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: var(--space-2);
}

/* File Cards */
.file-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.file-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--surface);
  transition: background-color var(--transition);
}

.file-card:hover {
  background-color: var(--bg);
}

.file-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.file-card-icon-pdf {
  background-color: #FEF2F2;
  color: #DC2626;
}

.file-card-icon-docx {
  background-color: #EFF6FF;
  color: #2563EB;
}

.file-card-icon-xlsx {
  background-color: #ECFDF5;
  color: #059669;
}

.file-card-icon-audio {
  background-color: #F5F3FF;
  color: #7C3AED;
}

.file-card-icon-image {
  background-color: #FFF7ED;
  color: #EA580C;
}

.file-card-info {
  flex: 1;
  min-width: 0;
}

.file-card-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-card-size {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.file-card-actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   11. ALERTS / FLASH MESSAGES
   -------------------------------------------------------------------------- */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  border-left: 4px solid transparent;
  font-size: 0.8125rem;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.alert-icon {
  flex-shrink: 0;
  margin-top: 1px;
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.alert-dismiss {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  transition: opacity var(--transition);
  padding: 2px;
}

.alert-dismiss:hover {
  opacity: 1;
}

.alert-success {
  background-color: var(--success-light);
  border-left-color: var(--success);
  color: #065F46;
}

[data-theme="dark"] .alert-success {
  color: #6EE7B7;
}

.alert-error {
  background-color: var(--danger-light);
  border-left-color: var(--danger);
  color: #991B1B;
}

[data-theme="dark"] .alert-error {
  color: #FCA5A5;
}

.alert-warning {
  background-color: var(--warning-light);
  border-left-color: var(--warning);
  color: #92400E;
}

[data-theme="dark"] .alert-warning {
  color: #FCD34D;
}

.alert-info {
  background-color: var(--info-light);
  border-left-color: var(--info);
  color: #1E40AF;
}

[data-theme="dark"] .alert-info {
  color: #93C5FD;
}

/* --------------------------------------------------------------------------
   12. RESPONSIVE BREAKPOINTS
   -------------------------------------------------------------------------- */

/* Tablet: below 1024px - sidebar collapses to icons */
@media (max-width: 1024px) {
  .sidebar {
    width: var(--sidebar-collapsed-width);
  }

  .main-content {
    margin-left: var(--sidebar-collapsed-width);
  }

  .sidebar .nav-label,
  .sidebar .badge-soon,
  .sidebar .sidebar-logo-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
  }

  .sidebar .nav-divider span {
    display: none;
  }

  .sidebar .nav-divider::after {
    flex: none;
    width: 24px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .main-content-inner {
    padding: var(--space-5) var(--space-5);
  }
}

/* Mobile: below 768px - sidebar hidden, hamburger menu */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  /* Restore labels when sidebar is open on mobile */
  .sidebar.mobile-open .nav-label,
  .sidebar.mobile-open .badge-soon,
  .sidebar.mobile-open .sidebar-logo-text {
    opacity: 1;
    width: auto;
  }

  .sidebar.mobile-open .nav-divider span {
    display: inline;
  }

  .main-content {
    margin-left: 0;
  }

  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .main-content-inner {
    padding: var(--space-4);
  }

  .header {
    padding: 0 var(--space-4);
  }

  /* Stack table header actions */
  .table-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }

  .table-actions {
    width: 100%;
  }

  /* Table horizontal scroll */
  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .data-table {
    min-width: 640px;
  }

  /* Chat adjustments */
  .chat-bubble {
    max-width: 90%;
  }
}

/* Mobile overlay backdrop */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: calc(var(--z-sidebar) - 1);
}

@media (max-width: 768px) {
  .sidebar-overlay.active {
    display: block;
  }
}

/* --------------------------------------------------------------------------
   13. ANIMATIONS & KEYFRAMES
   -------------------------------------------------------------------------- */

/* Pulse for overdue badge */
@keyframes pulse-badge {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.65;
  }
}

/* Fade In */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.fade-in {
  animation: fadeIn 300ms ease forwards;
}

/* Slide In from bottom */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.slide-in {
  animation: slideInUp 300ms ease forwards;
}

/* Slide In from left */
@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.slide-in-left {
  animation: slideInLeft 300ms ease forwards;
}

/* Spin (for loading spinners) */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: var(--radius-full);
  animation: spin 600ms linear infinite;
}

.spinner-sm {
  width: 14px;
  height: 14px;
}

/* Staggered entrance for lists */
.stagger-in > * {
  opacity: 0;
  animation: slideInUp 300ms ease forwards;
}

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

/* --------------------------------------------------------------------------
   14. UTILITY CLASSES
   -------------------------------------------------------------------------- */

/* Text Alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Margin Top */
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 20px; }
.mt-6 { margin-top: 24px; }

/* Margin Bottom */
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }
.mb-6 { margin-bottom: 24px; }

/* Padding */
.p-0 { padding: 0; }
.p-2 { padding: 8px; }
.p-4 { padding: 16px; }
.p-6 { padding: 24px; }

/* Flexbox */
.flex {
  display: flex;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

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

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-start {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.flex-wrap {
  flex-wrap: wrap;
}

.flex-1 {
  flex: 1;
}

.items-center {
  align-items: center;
}

.items-start {
  align-items: flex-start;
}

/* Gap */
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }

/* Visibility */
.hidden {
  display: none !important;
}

.visible {
  display: block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Truncate */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Text Sizing */
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.8125rem; }
.text-base { font-size: 0.875rem; }
.text-lg { font-size: 1rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }

/* Font Weight */
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* Text Color */
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-secondary); }

/* Background Color */
.bg-primary { background-color: var(--primary); }
.bg-surface { background-color: var(--surface); }

/* Border Radius */
.rounded { border-radius: var(--radius); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

/* Width */
.w-full { width: 100%; }

/* Cursor */
.cursor-pointer { cursor: pointer; }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }

/* Opacity */
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }

/* Divider */
.divider {
  height: 1px;
  background-color: var(--border);
  border: none;
  margin: var(--space-4) 0;
}

/* --------------------------------------------------------------------------
   ADDITIONAL COMPONENTS
   -------------------------------------------------------------------------- */

/* --- Modal / Dialog --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  animation: fadeIn 150ms ease;
}

.modal {
  background-color: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: slideInUp 200ms ease;
}

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

.modal-title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text);
}

.modal-body {
  padding: var(--space-5);
  overflow-y: auto;
}

.modal-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* --- Tooltip (CSS-only) --- */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 10px;
  background-color: var(--sidebar-bg);
  color: #F1F5F9;
  font-size: 0.6875rem;
  font-weight: 500;
  white-space: nowrap;
  border-radius: var(--radius);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  z-index: 100;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* --- Progress Bar --- */
.progress {
  width: 100%;
  height: 8px;
  background-color: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 400ms ease;
}

.progress-bar-primary {
  background-color: var(--primary);
}

.progress-bar-success {
  background-color: var(--success);
}

.progress-bar-warning {
  background-color: var(--warning);
}

.progress-bar-danger {
  background-color: var(--danger);
}

/* --- Tabs --- */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: 0;
}

.tab {
  padding: var(--space-3) var(--space-4);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
}

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

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  padding: var(--space-5) 0;
}

/* --- Dropdown --- */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 180px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-overlay);
  padding: var(--space-1) 0;
  animation: slideInUp 150ms ease;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-4);
  font-size: 0.8125rem;
  color: var(--text);
  border: none;
  background: none;
  cursor: pointer;
  transition: background-color var(--transition);
  text-align: left;
}

.dropdown-item:hover {
  background-color: var(--bg);
}

.dropdown-item-danger {
  color: var(--danger);
}

.dropdown-divider {
  height: 1px;
  background-color: var(--border);
  margin: var(--space-1) 0;
}

/* --- Avatar --- */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8125rem;
  flex-shrink: 0;
}

.avatar-sm {
  width: 24px;
  height: 24px;
  font-size: 0.6875rem;
}

.avatar-lg {
  width: 40px;
  height: 40px;
  font-size: 1rem;
}

.avatar-primary {
  background-color: var(--primary-light);
  color: var(--primary);
}

.avatar-success {
  background-color: var(--success-light);
  color: var(--success);
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: var(--space-8) var(--space-4);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
  opacity: 0.3;
}

.empty-state-title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-2);
}

.empty-state-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
  max-width: 360px;
  margin: 0 auto var(--space-5);
}

/* --- Notification Dot --- */
.notification-dot {
  width: 8px;
  height: 8px;
  background-color: var(--danger);
  border-radius: var(--radius-full);
  display: inline-block;
}

/* --- Tag / Chip --- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  background-color: var(--bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.tag-removable {
  padding-right: 6px;
}

.tag-remove {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-tertiary);
  border-radius: var(--radius-full);
  transition: all var(--transition);
}

.tag-remove:hover {
  background-color: var(--border);
  color: var(--text);
}

/* --------------------------------------------------------------------------
   PRINT STYLES
   -------------------------------------------------------------------------- */
@media print {
  .sidebar,
  .header,
  .sidebar-overlay,
  .menu-toggle,
  .btn,
  .chat-input-area {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
  }

  body {
    background-color: white;
    color: black;
  }

  .card,
  .kpi-card,
  .table-container {
    box-shadow: none;
    border: 1px solid #ddd;
    break-inside: avoid;
  }
}
