/* BBL GIS Immobilienportfolio - Design Tokens & Base Styles */

/* ===== CSS CUSTOM PROPERTIES ===== */
:root {
  /* Grey Scale - Cold blue-grey */
  --grey-900: #2D3236;
  --grey-800: #3D4347;
  --grey-700: #4E555A;
  --grey-600: #5E666B;
  --grey-500: #6C757D;
  --grey-400: #A0A8AE;
  --grey-300: #C5CCD1;
  --grey-200: #DDE2E6;
  --grey-100: #F3F5F7;
  --grey-50: #F9FAFB;

  /* Brand Colors */
  --accent-panel: #6C757D;
  --primary-red: #c00;
  --primary-red-dark: #a00;
  --primary-red-tint: rgba(204, 0, 0, 0.06);
  --white: #ffffff;

  /* Interactive Blue */
  --interactive-blue: #005ea8;
  --focus-ring: var(--interactive-blue);

  /* Status Colors */
  --status-active: #2e7d32;
  --status-active-bg: #e8f5e9;
  --status-active-text: #1b5e20;

  --status-renovation: #ef6c00;
  --status-renovation-bg: #fff3e0;
  --status-renovation-text: #e65100;

  --status-planning: #1976d2;
  --status-planning-bg: #e3f2fd;
  --status-planning-text: #0d47a1;

  --status-inactive: #6C757D;
  --status-inactive-bg: var(--grey-100);
  --status-inactive-text: #5E666B;

  --status-error: #d32f2f;
  --status-error-bg: #ffebee;
  --status-error-text: #c62828;

  --status-warning: #f57c00;
  --status-warning-bg: #fff3e0;
  --status-warning-text: #e65100;

  /* ===== TYPOGRAPHY SYSTEM ===== */
  --text-xs: 0.75rem;     /* 12px */
  --text-sm: 0.875rem;    /* 14px */
  --text-base: 1rem;      /* 16px */
  --text-lg: 1.125rem;    /* 18px */
  --text-xl: 1.25rem;     /* 20px */
  --text-2xl: 1.5rem;     /* 24px */

  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  --tracking-wide: 0.05em;
  --tracking-wider: 0.08em;

  --font-mono: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;

  /* ===== SPACING SYSTEM ===== */
  --space-0: 0;
  --space-1: 0.25rem;     /* 4px */
  --space-2: 0.5rem;      /* 8px */
  --space-3: 0.75rem;     /* 12px */
  --space-4: 1rem;        /* 16px */
  --space-5: 1.25rem;     /* 20px */
  --space-6: 1.5rem;      /* 24px */
  --space-8: 2rem;        /* 32px */
  --space-10: 2.5rem;     /* 40px */
  --space-12: 3rem;       /* 48px */
  --space-16: 4rem;       /* 64px */

  /* ===== COMPONENT TOKENS ===== */
  --radius-sm: 0.25rem;   /* 4px */
  --radius-md: 0.5rem;    /* 8px */
  --radius-lg: 0.75rem;   /* 12px */
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-xl: 0 4px 16px rgba(0, 0, 0, 0.2);

  --touch-target-min: 44px;

  /* ===== ICON SIZE SYSTEM ===== */
  --icon-xs: 14px;
  --icon-sm: 16px;
  --icon-md: 18px;
  --icon-lg: 20px;
  --icon-xl: 24px;
  --icon-2xl: 36px;
  --icon-display: 48px;
  --icon-hero: 64px;

  /* ===== TRANSITION SYSTEM ===== */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.2s ease;
  --transition-slow: 0.3s ease;

  /* ===== LAYOUT SYSTEM ===== */
  --header-main-height: 90px;
  --header-detail-height: 124px;
  --footer-height: 27px;
  --header-total-height: calc(var(--header-main-height) + var(--header-detail-height));

  --drawer-width: 450px;
  --drawer-min-width: 300px;
  --drawer-max-width: 800px;

  /* ===== CHECKBOX ACCENT ===== */
  --checkbox-accent: var(--primary-red);

  /* ===== PILL COLOR TOKENS (status + role pills used in the admin shell) ===== */
  --pill-live-bg: #d1fae5;
  --pill-live-text: #065f46;
  --pill-staging-bg: #fef3c7;
  --pill-staging-text: #92400e;
  --pill-archived-bg: var(--grey-100);
  --pill-archived-text: var(--grey-600);

  --role-admin-bg: #fee2e2;
  --role-admin-text: #991b1b;
  --role-editor-bg: #dbeafe;
  --role-editor-text: #1e40af;
  --role-viewer-bg: var(--grey-100);
  --role-viewer-text: var(--grey-700);

  /* ===== MODAL SCRIM ===== */
  --modal-scrim: rgba(45, 50, 54, 0.5);
  --scrim-soft: rgba(45, 50, 54, 0.4);
}

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

/* ===== BASE ===== */
/* Default to a document-scroll shell — the viewport does NOT pin; the
 * window scrolls naturally and topbar/tabs scroll away with the content.
 * Views that need a pinned full-screen canvas (scene viewer) opt in via
 * `.pb-body--fixed-viewport` — see admin.css. */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--grey-900);
}

/* ===== KEYFRAMES ===== */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

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

/* ===== FOCUS & ACCESSIBILITY ===== */
*:focus:not(:focus-visible) {
  outline: none;
}

*:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.view-toggle-btn:focus-visible,
.dropdown-btn:focus-visible,
.header-btn:focus-visible {
  z-index: 1;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--grey-900);
  color: var(--white);
  padding: var(--space-2) var(--space-4);
  z-index: 10000;
  text-decoration: none;
  font-size: var(--text-sm);
}

.skip-link:focus {
  top: 0;
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .loading-spinner {
    animation: none;
    border-top-color: var(--primary-red);
    opacity: 0.7;
  }
}

/* ===== SHARED PRIMITIVES ===== */

/* Text overline — small uppercase label */
.text-overline {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--grey-500);
}

/* Badge — inline status/category label */
.badge {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  line-height: 1;
}

/* Custom select — consistent dropdown appearance */
.custom-select {
  appearance: none;
  padding: var(--space-2) var(--space-8) var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  border: 1px solid var(--grey-300);
  border-radius: var(--radius-sm);
  background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E") no-repeat right var(--space-2) center;
  color: var(--grey-900);
  cursor: pointer;
  min-height: 32px;
}

.custom-select:hover {
  border-color: var(--grey-500);
}

.custom-select:focus {
  outline: none;
  border-color: var(--interactive-blue);
}

/* Base table */
.base-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.base-table th {
  padding: var(--space-2) var(--space-4);
  text-align: left;
  font-weight: var(--font-medium);
  color: var(--grey-700);
  border-bottom: 1px solid var(--grey-300);
  white-space: nowrap;
}

.base-table td {
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--grey-100);
  color: var(--grey-800);
}

.base-table tbody tr:hover td {
  background: var(--grey-50);
}

/* Checkbox — consistent sizing */
input[type="checkbox"] {
  width: var(--icon-sm);
  height: var(--icon-sm);
  cursor: pointer;
  accent-color: var(--checkbox-accent);
}

/* Icon button — circular icon-only interactive element */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  color: var(--grey-600);
  transition: background var(--transition-normal), color var(--transition-normal);
}

.icon-btn:hover {
  background: var(--grey-200);
  color: var(--grey-900);
}

.icon-btn .material-symbols-outlined {
  font-size: var(--icon-lg);
}

.icon-btn--circle {
  border-radius: var(--radius-full);
  width: 40px;
  height: 40px;
}

.icon-btn--bordered {
  border: 1px solid var(--grey-300);
  background: var(--white);
}

.icon-btn--bordered:hover {
  background: var(--grey-100);
}

/* Destructive action variant — subtle at rest, turns red on hover so the
 * user gets an explicit confirmation before clicking something dangerous.
 * Intentionally not red at rest so a grid of delete icons doesn't scream
 * at the user. */
.icon-btn--danger {
  color: var(--grey-500);
}
.icon-btn--danger:hover {
  background: var(--status-error-bg, #fdecec);
  color: var(--status-error, #c62828);
}

/* Primary Button */
.btn-primary {
  background: var(--grey-900);
  color: var(--white);
  border: none;
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  line-height: var(--leading-normal);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  transition: background var(--transition-normal);
  min-height: var(--touch-target-min);
}

.btn-primary:hover { background: var(--grey-700); }
.btn-primary:active { background: var(--grey-900); }

/* Secondary Button */
.btn-secondary {
  background: var(--white);
  color: var(--grey-900);
  border: 1px solid var(--grey-300);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  line-height: var(--leading-normal);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  transition: background var(--transition-normal), border-color var(--transition-normal);
  min-height: var(--touch-target-min);
}

.btn-secondary:hover {
  background: var(--grey-100);
  border-color: var(--grey-500);
}

/* Tertiary Button (text-only) */
.btn-tertiary {
  background: transparent;
  color: var(--grey-700);
  border: none;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  transition: background var(--transition-normal), color var(--transition-normal);
  min-height: var(--touch-target-min);
}

.btn-tertiary:hover {
  background: var(--grey-100);
  color: var(--grey-900);
}

/* Panel header */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--grey-200);
  background: var(--grey-50);
  flex-shrink: 0;
  gap: var(--space-3);
}

.panel-header-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  line-height: 1;
  color: var(--grey-900);
}

.panel-header-title .material-symbols-outlined {
  font-size: var(--icon-sm);
  color: var(--grey-600);
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Empty & Loading States */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-5);
  text-align: center;
  color: var(--grey-600);
}

.empty-state .material-symbols-outlined {
  font-size: var(--icon-hero);
  color: var(--grey-300);
  margin-bottom: var(--space-4);
}

.empty-state-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--grey-900);
  margin-bottom: var(--space-2);
  line-height: var(--leading-snug);
}

.empty-state-description {
  font-size: var(--text-sm);
  color: var(--grey-600);
  max-width: 400px;
  line-height: var(--leading-normal);
}

/* Optional action slot under an empty-state block. Gives the user a way
 * out (back link, retry, create-first-X) so "nothing here" isn't a
 * dead-end. */
.empty-state-cta {
  margin-top: var(--space-4);
  display: flex;
  gap: var(--space-2);
}

.empty-state-action {
  margin-top: var(--space-5);
}

.table-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-10) var(--space-5);
  text-align: center;
  color: var(--grey-500);
}

.table-empty-state .material-symbols-outlined {
  font-size: var(--icon-display);
  color: var(--grey-300);
  margin-bottom: var(--space-3);
}

.table-empty-message {
  font-size: var(--text-sm);
  color: var(--grey-600);
}

.empty-row td {
  padding: 0 !important;
  border: none !important;
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-5);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--grey-200);
  border-top-color: var(--primary-red);
  border-radius: var(--radius-full);
  animation: spin 1s linear infinite;
  will-change: transform;
}

.loading-text {
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  color: var(--grey-600);
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(90deg, var(--grey-100) 25%, var(--grey-200) 50%, var(--grey-100) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  will-change: background-position;
  border-radius: var(--radius-sm);
}

.skeleton-text { height: 14px; margin-bottom: var(--space-2); }
.skeleton-text.short { width: 60%; }
.skeleton-text.medium { width: 80%; }
.skeleton-text.long { width: 100%; }
.skeleton-card { height: 200px; border-radius: var(--radius-md); }
.skeleton-row { display: flex; gap: var(--space-4); padding: var(--space-4); border-bottom: 1px solid var(--grey-100); }
.skeleton-cell { height: 16px; flex: 1; }
.skeleton-cell.small { flex: 0 0 50px; }
.skeleton-cell.medium { flex: 0 0 100px; }

.table-skeleton { padding: 0 var(--space-5); }
.table-skeleton-header { display: flex; gap: var(--space-4); padding: var(--space-3) var(--space-4); background: var(--grey-50); border-bottom: 1px solid var(--grey-200); }
.table-skeleton-header .skeleton-cell { height: 12px; }
