/* ==========================================================================
   Design System Luxury — app.css
   Sistema Gestionale Immobiliare
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Google Fonts Import
   -------------------------------------------------------------------------- */
@import url('https://fonts.cdnfonts.com/css/bdo-grotesk');
@import url('https://fonts.googleapis.com/css2?family=Bellefair&display=swap');

/* --------------------------------------------------------------------------
   2. CSS Custom Properties (Brand Palette & Design Tokens)
   -------------------------------------------------------------------------- */
:root {
  /* Brand Colors */
  --primary: #183028;
  --primary-light: #1e3d33;
  --primary-dark: #0f1f1a;
  --white: #ffffff;
  --gray-light: #efefef;
  --gray-medium: #c4c4c4;
  --gray-dark: #6b6b6b;
  --black: #000000;

  /* Semantic Colors */
  --success: #2d6a4f;
  --warning: #e9c46a;
  --danger: #c1121f;
  --info: #457b9d;

  /* Status Badge Colors */
  --status-available: #2d6a4f;
  --status-negotiation: #e9c46a;
  --status-sold: #c1121f;
  --status-rented: #457b9d;
  --status-withdrawn: #6b6b6b;

  /* Typography */
  --font-serif: 'Bellefair', Georgia, 'Times New Roman', serif;
  --font-sans: 'BDO Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Spacing (luxury generous whitespace) */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;
  --space-2xl: 4rem;
  --space-3xl: 6rem;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 50px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.12);
  --shadow-card: 0 2px 16px rgba(24, 48, 40, 0.06);
  --shadow-card-hover: 0 8px 32px rgba(24, 48, 40, 0.12);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.3s ease;
  --transition-slow: 0.5s ease;

  /* Sidebar */
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 72px;
  --navbar-height: 64px;
}

/* --------------------------------------------------------------------------
   3. CSS Reset & Base Typography
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.6;
  color: var(--black);
  background-color: var(--gray-light);
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  font-family: var(--font-serif);
  font-weight: 400;
  line-height: 1.25;
  color: var(--black);
  margin-bottom: var(--space-md);
}

/* Bellefair only has weight 400 — prevent faux bold from Bootstrap .fw-bold */
h1, h2, h3, h4, h5,
.h1, .h2, .h3, .h4, .h5,
.card-title, .modal-title {
  font-weight: 400;
}

/* Higher specificity override: even with .fw-bold, Bellefair stays 400 */
h1.fw-bold, h2.fw-bold, h3.fw-bold, h4.fw-bold, h5.fw-bold,
.card-title.fw-bold, .modal-title.fw-bold {
  font-weight: 400;
}

h1, .h1 { font-size: 2.25rem; letter-spacing: -0.02em; }
h2, .h2 { font-size: 1.75rem; letter-spacing: -0.01em; }
h3, .h3 { font-size: 1.375rem; }
h4, .h4 { font-size: 1.125rem; }
h5, .h5 { font-size: 1rem; }
h6, .h6 { font-size: 0.875rem; font-weight: 700; font-family: var(--font-sans); text-transform: uppercase; letter-spacing: 0.05em; }

p {
  margin-bottom: var(--space-md);
  color: var(--gray-dark);
}

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

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

small, .text-small {
  font-size: 0.8125rem;
}

.text-serif {
  font-family: var(--font-serif);
}

.text-sans {
  font-family: var(--font-sans);
}

/* --------------------------------------------------------------------------
   4. Bootstrap 5 Overrides
   -------------------------------------------------------------------------- */

/* Primary color overrides */
.btn-primary {
  background-color: var(--primary);
  border-color: var(--primary);
  color: var(--white);
  transition: all var(--transition-base);
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: var(--primary-light);
  border-color: var(--primary-light);
  color: var(--white);
  box-shadow: 0 4px 12px rgba(24, 48, 40, 0.25);
}

.btn-primary:active {
  background-color: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary);
  transition: all var(--transition-base);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
  background-color: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

/* Primary luxury button — main CTA */
.btn-primary-luxury {
  background-color: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

.btn-primary-luxury:hover,
.btn-primary-luxury:focus {
  background-color: var(--primary-light);
  border-color: var(--primary-light);
  color: var(--white);
  box-shadow: 0 4px 12px rgba(24, 48, 40, 0.25);
}

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

/* Link color */
.text-primary {
  color: var(--primary) !important;
}

.bg-primary {
  background-color: var(--primary) !important;
}

/* Card overrides */
.card {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  background-color: var(--white);
  transition: box-shadow var(--transition-base), transform var(--transition-base);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-card-hover);
}

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

.card-title {
  font-family: var(--font-serif);
  font-weight: 400;
}

/* Form overrides */
.form-control,
.form-select {
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-medium);
  padding: 0.625rem 1rem;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(24, 48, 40, 0.1);
}

.form-label {
  font-weight: 500;
  font-size: 0.875rem;
  margin-bottom: 0.375rem;
  color: var(--black);
}

/* Badge overrides */
.badge {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  padding: 0.35em 0.75em;
  border-radius: var(--radius-pill);
}

/* Table overrides */
.table {
  font-size: 0.875rem;
}

.table thead th {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-dark);
  border-bottom: 2px solid var(--gray-light);
  padding: var(--space-md);
}

.table tbody td {
  padding: var(--space-md);
  vertical-align: middle;
  border-bottom: 1px solid var(--gray-light);
}

/* Nav tabs: override Bootstrap defaults for <a>-based tabs */
.nav-tabs {
  --bs-nav-tabs-border-width: 0;
  --bs-nav-tabs-border-color: transparent;
  --bs-nav-tabs-link-active-bg: transparent;
  --bs-nav-tabs-link-active-border-color: transparent;
  --bs-nav-tabs-link-active-color: var(--primary);
  --bs-nav-tabs-link-hover-border-color: transparent;
  border-bottom: 2px solid var(--gray-light);
}
.nav-tabs .nav-item .nav-link {
  color: var(--gray-dark);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  margin-bottom: -2px;
  padding: 0.6rem 1rem;
  background: none;
  transition: color 0.2s, border-color 0.2s;
}
.nav-tabs .nav-item .nav-link:hover,
.nav-tabs .nav-item .nav-link:focus {
  color: var(--primary);
  border-bottom-color: var(--gray-medium);
  background: none;
  isolation: auto;
}
.nav-tabs .nav-item .nav-link.active {
  color: var(--primary);
  font-weight: 600;
  border: none;
  border-bottom: 2px solid var(--primary);
  background: none;
}

/* List group overrides */
.list-group-item-action {
  color: var(--gray-dark);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}
.list-group-item-action:hover,
.list-group-item-action:focus {
  color: var(--primary);
  background-color: rgba(24, 48, 40, 0.04);
}
.list-group-item-action.active {
  background-color: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

/* Modal overrides */
.modal-content {
  border: none;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

.modal-header {
  border-bottom: 1px solid var(--gray-light);
  padding: var(--space-lg);
}

.modal-body {
  padding: var(--space-xl);
}

.modal-footer {
  border-top: 1px solid var(--gray-light);
  padding: var(--space-lg);
}

.modal-title {
  font-family: var(--font-serif);
  font-weight: 400;
  color: inherit;
}

/* Dropdown overrides */
.dropdown-menu {
  border: none;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-sm);
}

.dropdown-item {
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  transition: background-color var(--transition-fast);
}

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

/* Pagination overrides */
.page-link {
  color: var(--primary);
  border-color: var(--gray-light);
  transition: all var(--transition-base);
}

.page-item.active .page-link {
  background-color: var(--primary);
  border-color: var(--primary);
}

/* Generous spacing overrides */
.container-fluid {
  padding-left: var(--space-xl);
  padding-right: var(--space-xl);
}

section {
  margin-bottom: var(--space-2xl);
}

/* --------------------------------------------------------------------------
   5. Sidebar Navigation (Desktop)
   -------------------------------------------------------------------------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background-color: var(--primary);
  color: var(--white);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: width var(--transition-base);
  overflow: hidden;
}

.sidebar-brand {
  padding: var(--space-lg) var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  min-height: var(--navbar-height);
}

.sidebar-brand img {
  height: 32px;
  width: auto;
}

.sidebar-brand-logo {
  height: 28px;
  width: auto;
  filter: brightness(0) invert(1);
}

.sidebar-brand-icon {
  display: none;
  height: 32px;
  width: 32px;
  filter: brightness(0) invert(1);
  border-radius: 6px;
}

/* Collapsed sidebar: show icon, hide full logo */
.sidebar.collapsed .sidebar-brand-logo {
  display: none;
}

.sidebar.collapsed .sidebar-brand-icon {
  display: block;
}

.sidebar-brand span {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  font-weight: 400;
  white-space: nowrap;
  opacity: 1;
  transition: opacity var(--transition-base);
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-md) 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 0.75rem var(--space-lg);
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  position: relative;
  transition: color var(--transition-base), background-color var(--transition-base);
  white-space: nowrap;
}

.sidebar-link i {
  font-size: 1.125rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-link:hover {
  color: var(--white);
  background-color: rgba(255, 255, 255, 0.08);
}

.sidebar-link.active {
  color: var(--white);
  background-color: rgba(255, 255, 255, 0.1);
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background-color: var(--white);
  border-radius: 0 2px 2px 0;
}

.sidebar-section-title {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.4);
  padding: var(--space-lg) var(--space-lg) var(--space-sm);
  white-space: nowrap;
}

.sidebar-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Sidebar collapsed (medium screens) */
.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .sidebar-brand span,
.sidebar.collapsed .sidebar-link span,
.sidebar.collapsed .sidebar-section-title {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar.collapsed .sidebar-link {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

/* --------------------------------------------------------------------------
   6. Top Navbar
   -------------------------------------------------------------------------- */
.top-navbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--navbar-height);
  background-color: var(--white);
  border-bottom: 1px solid var(--gray-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-xl);
  z-index: 1030;
  transition: left var(--transition-base);
}

.sidebar.collapsed ~ .top-navbar,
.sidebar.collapsed ~ .main-content .top-navbar {
  left: var(--sidebar-collapsed-width);
}

.navbar-search {
  position: relative;
  width: 100%;
  max-width: 400px;
}

.navbar-search .form-control {
  padding-left: 2.5rem;
  background-color: var(--gray-light);
  border: none;
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
}

.navbar-search .form-control:focus {
  background-color: var(--white);
  border: 1px solid var(--primary);
}

.navbar-search .search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-dark);
  font-size: 0.875rem;
}

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

/* Action buttons (search, bell) — clean circular buttons */
.navbar-action-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--gray-light);
  background-color: var(--white);
  color: var(--gray-dark);
  font-size: 1.125rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-base);
  padding: 0;
}

.navbar-action-btn:hover {
  background-color: var(--gray-light);
  color: var(--primary);
  border-color: var(--gray-medium);
}

/* Hide Bootstrap caret on navbar action buttons */
.navbar-action-btn.dropdown-toggle::after {
  display: none;
}

/* Notification badge — small red dot */
.navbar-action-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background-color: var(--danger);
  color: var(--white);
  font-family: var(--font-sans);
  font-size: 0.625rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
  border: 2px solid var(--white);
}

/* User button — avatar + name */
.navbar-user-btn {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 4px 12px 4px 4px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--gray-light);
  background-color: var(--white);
  cursor: pointer;
  transition: all var(--transition-base);
}

.navbar-user-btn:hover {
  background-color: var(--gray-light);
  border-color: var(--gray-medium);
}

/* Hide Bootstrap caret on user button */
.navbar-user-btn.dropdown-toggle::after {
  display: none;
}

.navbar-user-name {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--black);
}

.navbar-user-chevron {
  font-size: 0.625rem;
  color: var(--gray-dark);
  margin-left: 2px;
  transition: transform var(--transition-base);
}

.navbar-user-btn[aria-expanded="true"] .navbar-user-chevron {
  transform: rotate(180deg);
}

.navbar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--primary);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.75rem;
  flex-shrink: 0;
}

/* Navbar dropdown — shared style for notifications & user menu */
.navbar-dropdown {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 0;
  overflow: hidden;
  min-width: 240px;
}

/* Notification dropdown specific width */
#notificationDropdown .navbar-dropdown {
  width: 360px;
  max-height: 420px;
  overflow-y: auto;
}

.navbar-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--gray-light);
}

.navbar-dropdown-header h6 {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-dark);
}

/* User info block in dropdown */
.navbar-dropdown-user-info {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
}

.navbar-dropdown-user-info .navbar-user-avatar {
  width: 40px;
  height: 40px;
  font-size: 0.875rem;
}

.navbar-dropdown .dropdown-item {
  padding: 0.625rem var(--space-lg);
  font-size: 0.875rem;
}

.navbar-dropdown .dropdown-divider {
  margin: 0;
}

/* Mobile brand in navbar (hidden on md+ via Bootstrap d-md-none) */
.navbar-mobile-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.navbar-mobile-logo {
  height: 20px;
  width: auto;
}

/* --------------------------------------------------------------------------
   7. Main Content Area
   -------------------------------------------------------------------------- */
.main-content {
  margin-left: var(--sidebar-width);
  padding-top: var(--navbar-height);
  min-height: 100vh;
  transition: margin-left var(--transition-base);
}

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

.content-wrapper {
  padding: var(--space-xl);
}

/* Ensure first child in content area has no extra top margin */
.content-wrapper > :first-child {
  margin-top: 0;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
  flex-wrap: wrap;
  gap: var(--space-md);
}

.page-header h1 {
  margin-bottom: 0;
}

.page-title {
  font-family: var(--font-serif);
  font-weight: 400;
  color: var(--black);
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  color: var(--gray-dark);
  font-weight: 400;
}

/* --------------------------------------------------------------------------
   8. Property Card — Premium Design (Req 8.10, 8.12)
   -------------------------------------------------------------------------- */
.property-card {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background-color: var(--white);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition-base), transform var(--transition-base);
  animation: fadeInUp 0.5s ease both;
}

.property-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-4px);
}

/* Photo container with 16:9 aspect ratio */
.property-card-photo {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.property-card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.property-card:hover .property-card-photo img {
  transform: scale(1.03);
}

/* Gradient overlay on bottom of photo */
.property-card-photo::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60%;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0) 100%);
  pointer-events: none;
}

/* Title and price overlaid on photo */
.property-card-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-lg);
  z-index: 2;
  color: var(--white);
}

.property-card-overlay .property-title {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  font-weight: 400;
  margin-bottom: var(--space-xs);
  color: var(--white);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.property-card-overlay .property-price {
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 700;
  color: var(--white);
}

/* Status badge on card */
.property-card-badge {
  position: absolute;
  top: var(--space-md);
  left: var(--space-md);
  z-index: 3;
}

.badge-available {
  background-color: var(--status-available);
  color: var(--white);
}

.badge-negotiation {
  background-color: var(--status-negotiation);
  color: var(--black);
}

.badge-sold {
  background-color: var(--status-sold);
  color: var(--white);
}

.badge-rented {
  background-color: var(--status-rented);
  color: var(--white);
}

.badge-withdrawn {
  background-color: var(--status-withdrawn);
  color: var(--white);
}

/* Card body with property details */
.property-card-body {
  padding: var(--space-lg);
}

.property-card-meta {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  font-size: 0.8125rem;
  color: var(--gray-dark);
}

.property-card-meta span {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.property-card-meta i {
  font-size: 0.875rem;
  color: var(--primary);
}

.property-card-location {
  font-size: 0.8125rem;
  color: var(--gray-dark);
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

/* --------------------------------------------------------------------------
   9. Keyframe Animations (Req 8.11)
   -------------------------------------------------------------------------- */

/* Fade in from below */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* Slide in from right (side panels) */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Slide in from left */
@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

/* Scale in (modals alternative) */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Staggered card animation */
.property-card:nth-child(1) { animation-delay: 0s; }
.property-card:nth-child(2) { animation-delay: 0.05s; }
.property-card:nth-child(3) { animation-delay: 0.1s; }
.property-card:nth-child(4) { animation-delay: 0.15s; }
.property-card:nth-child(5) { animation-delay: 0.2s; }
.property-card:nth-child(6) { animation-delay: 0.25s; }
.property-card:nth-child(7) { animation-delay: 0.3s; }
.property-card:nth-child(8) { animation-delay: 0.35s; }
.property-card:nth-child(9) { animation-delay: 0.4s; }

/* --------------------------------------------------------------------------
   10. Transition & Hover Effects (Req 8.11)
   -------------------------------------------------------------------------- */

/* Button hover transitions */
.btn {
  transition: all var(--transition-base);
}

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

.btn:active {
  transform: translateY(0);
}

/* Card hover lift */
.card-hover-lift {
  transition: box-shadow var(--transition-base), transform var(--transition-base);
}

.card-hover-lift:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-4px);
}

/* Link underline animation */
.link-animated {
  position: relative;
  display: inline-block;
}

.link-animated::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background-color: var(--primary);
  transition: width var(--transition-base);
}

.link-animated:hover::after {
  width: 100%;
}

/* --------------------------------------------------------------------------
   11. Side Panel (Slide-in)
   -------------------------------------------------------------------------- */
.side-panel {
  position: fixed;
  top: 0;
  right: -480px;
  width: 480px;
  max-width: 100vw;
  height: 100vh;
  background-color: var(--white);
  box-shadow: var(--shadow-xl);
  z-index: 1050;
  transition: right var(--transition-base);
  overflow-y: auto;
}

.side-panel.open {
  right: 0;
  animation: slideInRight 0.3s ease;
}

.side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--gray-light);
  position: sticky;
  top: 0;
  background-color: var(--white);
  z-index: 1;
}

.side-panel-body {
  padding: var(--space-xl);
}

.side-panel-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.3);
  z-index: 1049;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), visibility var(--transition-base);
}

.side-panel-overlay.visible {
  opacity: 1;
  visibility: visible;
}

/* Modal slide-in animation override */
.modal.fade .modal-dialog {
  transition: transform var(--transition-base), opacity var(--transition-base);
  transform: translateY(20px);
  opacity: 0;
}

.modal.show .modal-dialog {
  transform: translateY(0);
  opacity: 1;
}

/* --------------------------------------------------------------------------
   12. Mobile Navigation (Bottom Bar < 768px)
   -------------------------------------------------------------------------- */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background-color: var(--white);
  border-top: 1px solid var(--gray-light);
  z-index: 1040;
  padding: 0;
}

.mobile-nav-items {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mobile-nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--gray-dark);
  font-size: 0.6875rem;
  font-weight: 500;
  text-decoration: none;
  transition: color var(--transition-base);
}

.mobile-nav-link i {
  font-size: 1.25rem;
}

.mobile-nav-link.active,
.mobile-nav-link:hover {
  color: var(--primary);
}

/* --------------------------------------------------------------------------
   13. Utility Classes
   -------------------------------------------------------------------------- */

/* Luxury spacing */
.luxury-section {
  padding: var(--space-2xl) 0;
}

.luxury-gap {
  gap: var(--space-xl);
}

/* Glassmorphism effect */
.glass {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-xl);
}

.glass-dark {
  background: rgba(24, 48, 40, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-xl);
}

/* Aspect ratio helpers */
.aspect-16-9 {
  aspect-ratio: 16 / 9;
}

.aspect-3-2 {
  aspect-ratio: 3 / 2;
}

.aspect-1-1 {
  aspect-ratio: 1 / 1;
}

.img-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Fade animation utility */
.animate-fade-in {
  animation: fadeIn 0.5s ease both;
}

.animate-fade-in-up {
  animation: fadeInUp 0.5s ease both;
}

.animate-slide-in-right {
  animation: slideInRight 0.3s ease both;
}

.animate-slide-in-left {
  animation: slideInLeft 0.3s ease both;
}

.animate-slide-in-up {
  animation: slideInUp 0.3s ease both;
}

/* Truncate text */
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Divider */
.divider {
  height: 1px;
  background-color: var(--gray-light);
  margin: var(--space-lg) 0;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-xl);
  color: var(--gray-dark);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.4;
}

.empty-state h3 {
  font-family: var(--font-serif);
  color: var(--black);
  margin-bottom: var(--space-sm);
}

/* Stat card (dashboard) */
.stat-card {
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  background-color: var(--white);
  box-shadow: var(--shadow-card);
  animation: fadeInUp 0.5s ease both;
}

.stat-card-value {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 400;
  color: var(--primary);
  line-height: 1;
  margin-bottom: var(--space-xs);
}

.stat-card-label {
  font-size: 0.8125rem;
  color: var(--gray-dark);
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   14. Responsive Breakpoints
   -------------------------------------------------------------------------- */

/* Medium screens: collapse sidebar */
@media (max-width: 1199.98px) {
  .sidebar {
    width: var(--sidebar-collapsed-width);
  }

  .sidebar .sidebar-brand span,
  .sidebar .sidebar-link span,
  .sidebar .sidebar-section-title {
    opacity: 0;
    width: 0;
    overflow: hidden;
  }

  .sidebar .sidebar-brand-logo {
    display: none;
  }

  .sidebar .sidebar-brand-icon {
    display: block;
  }

  .sidebar .sidebar-brand {
    justify-content: center;
  }

  .sidebar .sidebar-link {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }

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

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

/* Tablet and below: hide sidebar, show mobile nav */
@media (max-width: 767.98px) {
  .sidebar {
    display: none;
  }

  .top-navbar {
    left: 0;
    height: 56px;
  }

  .main-content {
    margin-left: 0;
    padding-top: 56px;
    padding-bottom: 72px;
  }

  .mobile-nav {
    display: block;
  }

  .content-wrapper {
    padding: var(--space-md);
  }

  .container-fluid {
    padding-left: var(--space-sm);
    padding-right: var(--space-sm);
  }

  h1, .h1 { font-size: 1.5rem; }
  h2, .h2 { font-size: 1.25rem; }
  h3, .h3 { font-size: 1.0625rem; }
  h4, .h4 { font-size: 1rem; }

  /* Single column card layout on mobile */
  .property-grid {
    grid-template-columns: 1fr;
  }
}

/* Small phones */
@media (max-width: 575.98px) {
  .content-wrapper {
    padding: var(--space-sm);
  }
}

/* --------------------------------------------------------------------------
   15. Property Grid Layout
   -------------------------------------------------------------------------- */
.property-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-xl);
}

/* List view */
.property-list .property-card {
  display: flex;
  flex-direction: row;
}

.property-list .property-card-photo {
  width: 280px;
  min-width: 280px;
  aspect-ratio: auto;
  height: 100%;
}

.property-list .property-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media (max-width: 767.98px) {
  .property-list .property-card {
    flex-direction: column;
  }

  .property-list .property-card-photo {
    width: 100%;
    min-width: auto;
    aspect-ratio: 16 / 9;
  }
}

/* --------------------------------------------------------------------------
   16. Scrollbar Styling
   -------------------------------------------------------------------------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--gray-medium);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gray-dark);
}

/* --------------------------------------------------------------------------
   17. Print Styles
   -------------------------------------------------------------------------- */
@media print {
  .sidebar,
  .top-navbar,
  .mobile-nav {
    display: none !important;
  }

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

  .property-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid var(--gray-light);
  }
}

/* --------------------------------------------------------------------------
   18. SPA Page Transitions
   -------------------------------------------------------------------------- */

/* Uscita pagina: fade + slide up */
.main-content.spa-exit > .content-wrapper {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

/* Entrata pagina: fade + slide up dal basso */
.main-content.spa-enter > .content-wrapper {
  animation: spaEnter 0.3s ease forwards;
}

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

/* Stato base: nessun transform per non creare stacking context (modali Bootstrap) */
.main-content > .content-wrapper {
  opacity: 1;
}

/* Loading bar in alto durante navigazione */
.spa-loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  z-index: 9999;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s ease;
  pointer-events: none;
}

.spa-loading-bar.active {
  transform: scaleX(0.7);
  transition: transform 2s cubic-bezier(0.1, 0.5, 0.3, 1);
}

.spa-loading-bar.done {
  transform: scaleX(1);
  transition: transform 0.15s ease;
  opacity: 0;
  transition: transform 0.15s ease, opacity 0.3s ease 0.15s;
}

/* --------------------------------------------------------------------------
   19. PWA Install Banner
   -------------------------------------------------------------------------- */
.pwa-install-banner {
  position: fixed;
  bottom: 80px;
  left: var(--space-md);
  right: var(--space-md);
  z-index: 1080;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}

.pwa-install-banner.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.pwa-install-banner.dismissing {
  opacity: 0;
  transform: translateY(20px);
}

.pwa-install-banner-inner {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(24, 48, 40, 0.08);
}

.pwa-install-banner-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: rgba(24, 48, 40, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pwa-install-banner-icon img {
  width: 32px;
  height: 32px;
}

.pwa-install-banner-text {
  flex: 1;
  min-width: 0;
}

.pwa-install-banner-title {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--black);
  line-height: 1.3;
}

.pwa-install-banner-desc {
  font-size: 0.8125rem;
  color: var(--gray-dark);
  line-height: 1.3;
}

.pwa-install-banner-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.pwa-install-btn {
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-pill);
  border: none;
  background-color: var(--primary);
  color: var(--white);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
}

.pwa-install-btn:hover {
  background-color: var(--primary-light);
  box-shadow: 0 4px 12px rgba(24, 48, 40, 0.25);
}

.pwa-install-dismiss {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--gray-dark);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
  padding: 0;
}

.pwa-install-dismiss:hover {
  background: var(--gray-light);
}

/* Mobile: banner sopra la bottom nav */
@media (max-width: 767.98px) {
  .pwa-install-banner {
    bottom: 72px;
    left: var(--space-sm);
    right: var(--space-sm);
  }

  .pwa-install-banner-inner {
    padding: var(--space-sm) var(--space-md);
  }

  .pwa-install-banner-desc {
    display: none;
  }
}

/* Desktop: banner in basso a destra */
@media (min-width: 768px) {
  .pwa-install-banner {
    bottom: var(--space-lg);
    left: auto;
    right: var(--space-lg);
    max-width: 420px;
  }
}
