/**
 * Modern UI Components - Dubai Real Estate
 * کامپوننت‌های UI مدرن - املاک دبی
 * Premium components inspired by Apple, Linear, and top design systems
 */

/* ============================================
   BUTTON SYSTEM - سیستم دکمه‌ها
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--duration-200) var(--ease-out);
  text-decoration: none;
  outline: none;
  position: relative;
  overflow: hidden;
  
  /* Focus state */
  &:focus-visible {
    box-shadow: var(--focus-ring);
  }
  
  /* Disabled state */
  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
  }
  
  /* Loading state */
  &.loading {
    color: transparent;
    pointer-events: none;
    
    &::after {
      content: '';
      position: absolute;
      width: 16px;
      height: 16px;
      border: 2px solid transparent;
      border-top: 2px solid currentColor;
      border-radius: 50%;
      animation: spin var(--duration-1000) linear infinite;
      opacity: 0.6;
    }
  }
}

/* Button Sizes */
.btn-sm {
  height: 32px;
  padding: 0 var(--spacing-3);
  font-size: var(--text-xs);
  gap: var(--spacing-1);
}

.btn-md {
  height: 40px;
  padding: 0 var(--spacing-4);
  font-size: var(--text-sm);
  gap: var(--spacing-2);
}

.btn-lg {
  height: 48px;
  padding: 0 var(--spacing-6);
  font-size: var(--text-base);
  gap: var(--spacing-2);
}

.btn-xl {
  height: 56px;
  padding: 0 var(--spacing-8);
  font-size: var(--text-lg);
  gap: var(--spacing-3);
}

/* Button Variants */
.btn-primary {
  background-color: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
  
  &:hover:not(:disabled) {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
  }
  
  &:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
  }
}

.btn-secondary {
  background-color: var(--secondary);
  color: var(--secondary-foreground);
  border-color: var(--border);
  
  &:hover:not(:disabled) {
    background-color: var(--secondary-hover);
    border-color: var(--border);
  }
}

.btn-ghost {
  background-color: transparent;
  color: var(--foreground);
  border-color: transparent;
  
  &:hover:not(:disabled) {
    background-color: var(--secondary);
    color: var(--secondary-foreground);
  }
}

.btn-outline {
  background-color: transparent;
  color: var(--primary);
  border-color: var(--primary);
  
  &:hover:not(:disabled) {
    background-color: var(--primary);
    color: var(--primary-foreground);
  }
}

.btn-destructive {
  background-color: var(--destructive);
  color: var(--destructive-foreground);
  border-color: var(--destructive);
  
  &:hover:not(:disabled) {
    background-color: var(--error-600);
    border-color: var(--error-600);
  }
}

/* Icon buttons */
.btn-icon {
  padding: 0;
  width: 40px;
  height: 40px;
  
  &.btn-sm {
    width: 32px;
    height: 32px;
  }
  
  &.btn-lg {
    width: 48px;
    height: 48px;
  }
}

/* Button with icon */
.btn .icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ============================================
   CARD SYSTEM - سیستم کارت‌ها
   ============================================ */

.card {
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background-color: var(--card);
  color: var(--card-foreground);
  box-shadow: var(--shadow-sm);
  transition: all var(--duration-300) var(--ease-out);
  overflow: hidden;
  position: relative;
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: var(--border);
}

.card-header {
  padding: var(--spacing-6);
  border-bottom: 1px solid var(--border);
  background-color: var(--card);
}

.card-content {
  padding: var(--spacing-6);
}

.card-footer {
  padding: var(--spacing-6);
  border-top: 1px solid var(--border);
  background-color: var(--muted);
}

/* Card variants */
.card-elevated {
  box-shadow: var(--shadow-md);
  border: none;
  
  &:hover {
    box-shadow: var(--shadow-xl);
    transform: translateY(-4px);
  }
}

.card-interactive {
  cursor: pointer;
  user-select: none;
  
  &:active {
    transform: translateY(-1px) scale(0.98);
  }
}

.card-gradient {
  background: linear-gradient(135deg, var(--card) 0%, var(--muted) 100%);
}

/* ============================================
   PROPERTY CARD - کارت املاک
   ============================================ */

.property-card {
  /* .card styles */
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background-color: var(--card);
  color: var(--card-foreground);
  box-shadow: var(--shadow-sm);
  transition: all var(--duration-300) var(--ease-out);
  overflow: hidden;
  position: relative;

  /* .card-interactive styles */
  cursor: pointer;
  user-select: none;

  /* property-card specific styles */
  display: flex;
  flex-direction: column;
  width: 250px !important;
  height: 400px !important;
  min-height: 400px;
  max-height: 400px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  overflow: hidden;
  transition: all var(--duration-300) var(--ease-apple);
}

.property-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-2xl);
  border-color: rgba(220, 38, 38, 0.2);
}

.property-image {
  position: relative;
  height: 200px !important;
  min-height: 200px;
  max-height: 200px;
  overflow: hidden;
  background: var(--muted);
  flex-shrink: 0;
  
  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--duration-500) var(--ease-out);
  }
}

.property-card:hover .property-image img {
  transform: scale(1.05);
}

.property-price {
  position: absolute;
  top: var(--spacing-4);
  right: var(--spacing-4);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  color: var(--primary);
  padding: var(--spacing-2) var(--spacing-3);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .property-price {
  background: rgba(31, 41, 55, 0.95);
  color: var(--primary);
  border-color: rgba(55, 65, 81, 0.3);
}

.property-badges {
  position: absolute;
  top: var(--spacing-4);
  left: var(--spacing-4);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--spacing-1) var(--spacing-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.badge-category {
  background: rgba(239, 68, 68, 0.9);
  color: white;
}

.badge-transaction {
  background: rgba(16, 185, 129, 0.9);
  color: white;
}

.badge-featured {
  background: rgba(245, 158, 11, 0.9);
  color: white;
}

.property-content {
  padding: var(--spacing-6);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-4);
}

.property-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--foreground);
  margin: 0;
  line-height: var(--leading-tight);
  
  /* Clamp to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.property-location {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  color: var(--muted-foreground);
  font-size: var(--text-sm);
  
  .icon {
    width: 14px;
    height: 14px;
    color: var(--primary);
  }
}

.property-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-2);
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  
  .property-subcategory {
    background: var(--muted);
    color: var(--muted-foreground);
    padding: var(--spacing-1) var(--spacing-2);
    border-radius: var(--radius);
    font-weight: 500;
  }
}

.property-features {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-4);
  margin-top: auto;
  padding-top: var(--spacing-4);
  border-top: 1px solid var(--border);
  
  span {
    display: flex;
    align-items: center;
    gap: var(--spacing-1);
    color: var(--muted-foreground);
    font-size: var(--text-sm);
    
    .icon {
      width: 14px;
      height: 14px;
      color: var(--primary);
    }
  }
}

.property-description {
  color: var(--muted-foreground);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  
  /* Clamp to 3 lines */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================
   INPUT SYSTEM - سیستم ورودی‌ها
   ============================================ */

.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
}

.input-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--foreground);
}

.input {
  display: flex;
  height: 48px;
  width: 100%;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background-color: var(--input);
  padding: 0 var(--spacing-4);
  font-size: var(--text-sm);
  transition: all var(--duration-200) var(--ease-out);
  color: var(--foreground);
  
  &::placeholder {
    color: var(--muted-foreground);
  }
  
  &:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
    background-color: var(--background);
  }
  
  &:disabled {
    cursor: not-allowed;
    opacity: 0.5;
  }
  
  &.error {
    border-color: var(--destructive);
    
    &:focus {
      border-color: var(--destructive);
      box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
    }
  }
}

.textarea {
  display: flex;
  height: 48px;
  width: 100%;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background-color: var(--input);
  font-size: var(--text-sm);
  transition: all var(--duration-200) var(--ease-out);
  color: var(--foreground);
  min-height: 100px;
  padding: var(--spacing-3) var(--spacing-4);
  resize: vertical;
  height: auto;
}
.textarea::placeholder {
  color: var(--muted-foreground);
}
.textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
  background-color: var(--background);
}
.textarea:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
.textarea.error {
  border-color: var(--destructive);
}
.textarea.error:focus {
  border-color: var(--destructive);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

.select {
  display: flex;
  height: 48px;
  width: 100%;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background-color: var(--input);
  padding: 0 var(--spacing-4);
  font-size: var(--text-sm);
  transition: all var(--duration-200) var(--ease-out);
  color: var(--foreground);
  cursor: pointer;
}

.select::placeholder {
  color: var(--muted-foreground);
}

.select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
  background-color: var(--background);
  cursor: auto;
}

.select:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.select.error {
  border-color: var(--destructive);
}

.select.error:focus {
  border-color: var(--destructive);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

.input-with-icon {
  position: relative;
  
  .input {
    padding-left: var(--spacing-10);
  }
  
  .input-icon {
    position: absolute;
    left: var(--spacing-3);
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--muted-foreground);
    pointer-events: none;
  }
}

.input-error {
  font-size: var(--text-xs);
  color: var(--destructive);
  margin-top: var(--spacing-1);
}

/* ============================================
   SEARCH BAR - نوار جستجو
   ============================================ */

.search-bar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  padding: var(--spacing-8);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
  position: relative;
  overflow: hidden;
}

.search-bar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, 
    transparent 0%, 
    var(--primary) 50%, 
    transparent 100%);
}

.search-row {
  display: flex;
  gap: var(--spacing-4);
  align-items: center;
  flex-wrap: wrap;
  
  &:not(:last-child) {
    margin-bottom: var(--spacing-6);
  }
}

.search-input {
  display: flex;
  height: 48px;
  width: 100%;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background-color: var(--input);
  padding: 0 var(--spacing-4);
  font-size: var(--text-sm);
  transition: all var(--duration-200) var(--ease-out);
  color: var(--foreground);
  flex: 1;
  min-width: 200px;
}
.search-input::placeholder {
  color: var(--muted-foreground);
}
.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
  background-color: var(--background);
}
.search-input:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
.search-input.error {
  border-color: var(--destructive);
}
.search-input.error:focus {
  border-color: var(--destructive);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

.search-select {
  display: flex;
  height: 48px;
  width: 100%;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background-color: var(--input);
  padding: 0 var(--spacing-4);
  font-size: var(--text-sm);
  transition: all var(--duration-200) var(--ease-out);
  color: var(--foreground);
  cursor: pointer;
  min-width: 150px;
}
.search-select::placeholder {
  color: var(--muted-foreground);
}
.search-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
  background-color: var(--background);
  cursor: auto;
}
.search-select:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
.search-select.error {
  border-color: var(--destructive);
}
.search-select.error:focus {
  border-color: var(--destructive);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

.search-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--duration-200) var(--ease-out);
  text-decoration: none;
  outline: none;
  position: relative;
  overflow: hidden;
  background-color: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
  height: 48px;
  padding: 0 var(--spacing-6);
  white-space: nowrap;
}
.search-button:focus-visible {
  box-shadow: var(--focus-ring);
}
.search-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.search-button.loading {
  color: transparent;
  pointer-events: none;
}
.search-button.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin var(--duration-1000) linear infinite;
  opacity: 0.6;
}

/* ============================================
   MODAL SYSTEM - سیستم مودال
   ============================================ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-4);
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-300) var(--ease-out);
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--card);
  border-radius: var(--radius-2xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-2xl);
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  position: relative;
  transform: scale(0.95) translateY(20px);
  transition: all var(--duration-300) var(--ease-out);
}

.modal.active .modal-content {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: var(--spacing-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--foreground);
  margin: 0;
}

.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--duration-200) var(--ease-out);
  text-decoration: none;
  outline: none;
  position: relative;
  overflow: hidden;
  background-color: transparent;
  color: var(--foreground);
  border-color: transparent;
  padding: 0;
  width: 40px;
  height: 40px;
}
.modal-close:hover:not(:disabled) {
  background-color: var(--secondary);
  color: var(--secondary-foreground);
}
.modal-close:focus-visible {
  box-shadow: var(--focus-ring);
}
.modal-close:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.modal-close .icon {
  width: 20px;
  height: 20px;
}

.modal-body {
  padding: var(--spacing-6);
}

.modal-footer {
  padding: var(--spacing-6);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--spacing-3);
}

/* ============================================
   NAVIGATION - ناوبری
   ============================================ */

.navbar {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
  transition: all var(--duration-300) var(--ease-out);
}

[data-theme="dark"] .navbar {
  background: rgba(17, 24, 39, 0.8);
}

.navbar-scrolled {
  box-shadow: var(--shadow-md);
  background: rgba(255, 255, 255, 0.95);
}

[data-theme="dark"] .navbar-scrolled {
  background: rgba(17, 24, 39, 0.95);
}

.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
}

.navbar-brand {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--foreground);
  text-decoration: none;
  transition: color var(--duration-200) var(--ease-out);
}

.navbar-brand:hover {
  color: var(--primary);
}

.navbar-nav {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: var(--spacing-2);
}

.nav-link {
  display: flex;
  align-items: center;
  padding: var(--spacing-2) var(--spacing-4);
  color: var(--muted-foreground);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-lg);
  transition: all var(--duration-200) var(--ease-out);
  position: relative;
}

.nav-link:hover,
.nav-link.active {
  color: var(--primary);
  background-color: var(--primary-50);
}

[data-theme="dark"] .nav-link:hover,
[data-theme="dark"] .nav-link.active {
  background-color: rgba(239, 68, 68, 0.1);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
}

/* ============================================
   HERO SECTION - بخش قهرمان
   ============================================ */

.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, 
    rgba(239, 68, 68, 0.1) 0%, 
    rgba(16, 185, 129, 0.1) 100%);
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('../assets/images/backgrounds/dubai-skyline-hero.svg') center/cover;
  opacity: 0.1;
  z-index: -1;
}

.hero-content {
  text-align: center;
  max-width: 800px;
  padding: 0 var(--spacing-4);
  z-index: 1;
}

.hero-title {
  font-size: var(--text-6xl);
  font-weight: 700;
  color: var(--foreground);
  margin-bottom: var(--spacing-6);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
}

.hero-subtitle {
  font-size: var(--text-xl);
  color: var(--muted-foreground);
  margin-bottom: var(--spacing-8);
  line-height: var(--leading-relaxed);
}

/* Responsive hero */
@media (max-width: 768px) {
  .hero-title {
    font-size: var(--text-4xl);
  }
  
  .hero-subtitle {
    font-size: var(--text-lg);
  }
}

/* ============================================
   RESPONSIVE UTILITIES - ابزار واکنش‌گرا
   ============================================ */

/* Mobile-first approach */
@media (max-width: 640px) {
  .container {
    padding: 0 var(--spacing-4);
  }
  
  .btn-lg {
    height: 44px;
    font-size: var(--text-sm);
  }
  
  .property-card {
    min-height: 350px;
  }
  
  .property-image {
    height: 200px;
  }
  
  .search-bar {
    padding: var(--spacing-4);
  }
  
  .search-row {
    flex-direction: column;
  }
  
  .search-input,
  .search-select {
    width: 100%;
    min-width: auto;
  }
  
  .modal-content {
    max-width: 95vw;
    margin: var(--spacing-4);
  }
  
  .navbar .container {
    height: 64px;
  }
}

@media (max-width: 480px) {
  .property-content {
    padding: var(--spacing-4);
  }
  
  .property-features {
    flex-direction: column;
    gap: var(--spacing-2);
  }
}