/* CasaRoma AI - Component Library */

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--t-fast);
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  user-select: none;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; pointer-events: none; }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: var(--primary-bg);
  color: var(--primary);
}
.btn-secondary:hover { background: rgba(21, 101, 192, 0.15); }

.btn-accent {
  background: var(--accent);
  color: #fff;
}

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

.btn-sm { padding: 6px 14px; font-size: 0.8125rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }
.btn-icon svg { width: 20px; height: 20px; }

.btn-round {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  padding: 0;
}

/* ============ Cards ============ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: background var(--t-normal), border-color var(--t-normal), box-shadow var(--t-fast);
}

.card:hover { box-shadow: var(--shadow); }
.card--elevated { box-shadow: var(--shadow); border: none; }
.card__body { padding: 16px; }
.card__footer { padding: 12px 16px; border-top: 1px solid var(--border); }

/* Property Card */
.property-card {
  cursor: pointer;
}

.property-card__image {
  width: 100%;
  height: 180px;
  background: var(--divider);
  position: relative;
  overflow: hidden;
}

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

.property-card__badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 10px;
  background: var(--primary);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  letter-spacing: 0.04em;
}

.property-card__fav {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  transition: color var(--t-fast);
}

.property-card__fav.active { color: var(--error); }

.property-card__price {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.property-card__address {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.property-card__tags {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.property-card__tags span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ============ Inputs ============ */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.9375rem;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: none;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

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

.input-search {
  padding-left: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 14px center;
}

textarea.input {
  min-height: 100px;
  resize: vertical;
}

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

/* ============ Tags / Chips ============ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 500;
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}

.chip:active { transform: scale(0.96); }
.chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ============ Badges ============ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-vendita { background: var(--info-bg); color: var(--info); }
.badge-affitto { background: var(--success-bg); color: var(--success); }
.badge-energy { padding: 2px 6px; border-radius: 4px; color: #fff; font-size: 0.625rem; }
.badge-energy.A { background: #10B981; }
.badge-energy.B { background: #34D399; }
.badge-energy.C { background: #FBBF24; }
.badge-energy.D { background: #FB923C; }
.badge-energy.E { background: #F87171; }
.badge-energy.F { background: #EF4444; }
.badge-energy.G { background: #DC2626; }

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

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

.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-text.w-60 { width: 60%; }
.skeleton-text.w-80 { width: 80%; }
.skeleton-image { height: 180px; border-radius: var(--radius) var(--radius) 0 0; }

/* ============ Toast ============ */
.toast-container {
  position: fixed;
  bottom: calc(var(--tab-height) + var(--safe-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  pointer-events: none;
}

.toast {
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff;
  background: var(--text);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(20px);
  transition: all var(--t-normal);
  pointer-events: auto;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ============ Modal / Bottom Sheet ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: none;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(2px);
}

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

.bottom-sheet {
  width: 100%;
  max-width: var(--content-max);
  max-height: 85vh;
  background: var(--bg-card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow-y: auto;
  animation: sheetUp 0.3s ease;
}

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.bottom-sheet__handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 10px auto;
}

.bottom-sheet__header {
  padding: 8px 16px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bottom-sheet__body {
  padding: 0 16px 24px;
}

/* ============ Empty State ============ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.empty-state svg { color: var(--text-tertiary); margin-bottom: 16px; }
.empty-state h3 { margin-bottom: 8px; }
.empty-state p { color: var(--text-secondary); font-size: 0.875rem; margin-bottom: 20px; }

/* ============ Toggle (Dark Mode) ============ */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  border: none;
  padding: 0;
  transition: background var(--t-fast);
}

.toggle.active { background: var(--primary); }

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: var(--radius-full);
  transition: transform var(--t-fast);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle.active::after { transform: translateX(20px); }

/* ============ Section Header ============ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-header h3 { font-size: 1rem; }
.section-header a {
  font-size: 0.8125rem;
  color: var(--primary);
  font-weight: 600;
}

/* ============ Stat Card ============ */
.stat-card {
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  transition: all var(--t-normal);
}

.stat-card__value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-card__label {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

/* ============ Quick Actions ============ */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--t-fast);
  -webkit-tap-highlight-color: transparent;
  border: none;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
}

.quick-action:active { transform: scale(0.96); }

.quick-action__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
}

.quick-action__icon svg {
  width: 22px;
  height: 22px;
  color: #fff;
}

/* ============ Filter Bar ============ */
.filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.filter-bar::-webkit-scrollbar { display: none; }

/* ============ Step Indicator ============ */
.steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-bottom: 20px;
}

.step-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--border);
  transition: all var(--t-fast);
}

.step-dot.active {
  width: 24px;
  background: var(--primary);
}

.step-dot.done { background: var(--success); }

/* ============ Notification Badge ============ */
.notif-btn { position: relative; }

.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--error);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--bg);
}

/* ============ Notification Item ============ */
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--t-fast);
}

.notif-item:active { background: var(--primary-bg); }
.notif-item:last-child { border-bottom: none; }

.notif-item.unread {
  background: var(--primary-bg);
}

.notif-item__icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--primary);
  flex-shrink: 0;
  margin-top: 4px;
}

/* ============ Responsive Components ============ */

/* Tablet */
@media (min-width: 768px) {
  /* Bottom sheet becomes centered dialog */
  .modal-overlay {
    align-items: center;
  }

  .bottom-sheet {
    max-width: 520px;
    border-radius: var(--radius-lg);
    max-height: 80vh;
  }

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

  .bottom-sheet__handle {
    display: none;
  }

  /* Property card image taller */
  .property-card__image {
    height: 220px;
  }

  .skeleton-image {
    height: 220px;
  }

  /* Quick actions 4 cols */
  .quick-actions {
    grid-template-columns: repeat(4, 1fr);
  }

  /* Toast wider */
  .toast {
    min-width: 320px;
  }

  /* Stat card bigger values */
  .stat-card__value {
    font-size: 1.75rem;
  }

  /* Input fields slightly larger padding */
  .input {
    padding: 14px 18px;
  }
}

/* Desktop */
@media (min-width: 1024px) {
  .bottom-sheet {
    max-width: 560px;
  }

  .property-card__image {
    height: 240px;
  }

  .skeleton-image {
    height: 240px;
  }

  .quick-actions {
    grid-template-columns: repeat(6, 1fr);
  }

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

  /* Buttons with hover effects on desktop */
  .btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
  }

  .btn:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
  }

  .profile-menu__item:hover {
    background: var(--primary-bg);
  }
}

/* ============ Offline Banner ============ */
.offline-banner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--error);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}

.offline-banner.show {
  display: flex;
}
