/* ============================================
   IMMO360 - Design System
   ============================================ */

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --secondary: #ec4899;
  --accent: #8b5cf6;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  --bg: #fafafa;
  --bg-alt: #f4f4f5;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e4e4e7;
  --border-light: #f1f5f9;

  --text: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
  --gradient-soft: linear-gradient(135deg, #eef2ff 0%, #fdf2f8 100%);
  --gradient-hero: linear-gradient(135deg, #6366f1 0%, #ec4899 100%);
  --gradient-mesh: radial-gradient(at 0% 0%, #818cf833 0px, transparent 50%),
                   radial-gradient(at 100% 0%, #f472b633 0px, transparent 50%),
                   radial-gradient(at 100% 100%, #c084fc33 0px, transparent 50%),
                   radial-gradient(at 0% 100%, #60a5fa33 0px, transparent 50%);

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.07), 0 1px 2px -1px rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
  --shadow-lg: 0 10px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.05);
  --shadow-xl: 0 25px 50px -12px rgb(0 0 0 / 0.18);
  --shadow-glow: 0 0 0 1px rgb(99 102 241 / 0.1), 0 10px 30px -10px rgb(99 102 241 / 0.4);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
  --bounce: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

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

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

/* ============================================
   TOP NAVIGATION
   ============================================ */
.topnav {
  height: 64px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
  color: var(--text);
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--gradient-primary);
  display: grid;
  place-items: center;
  color: white;
  box-shadow: var(--shadow-glow);
  position: relative;
  overflow: hidden;
}

.brand-logo::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.3) 50%, transparent 60%);
  animation: shimmer 3s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.brand-logo svg {
  width: 18px;
  height: 18px;
  z-index: 1;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 14px;
  transition: all var(--transition);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(99, 102, 241, 0.1);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(99, 102, 241, 0.2), 0 0 24px rgba(99, 102, 241, 0.3);
}

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

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
  transition: left var(--transition-slow);
}

.btn-primary:hover::before { left: 100%; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--surface);
  border-color: var(--text-light);
}

.btn-soft {
  background: var(--bg-alt);
  color: var(--text);
}

.btn-soft:hover {
  background: #e7e7ea;
}

.btn-danger {
  background: #fef2f2;
  color: var(--danger);
}

.btn-danger:hover { background: #fee2e2; }

.btn-lg {
  height: 48px;
  padding: 0 24px;
  font-size: 15px;
  border-radius: var(--radius-md);
}

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

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

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

/* ============================================
   CARDS
   ============================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  transition: all var(--transition);
}

.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border);
}

/* ============================================
   INPUTS
   ============================================ */
.input, .textarea {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: all var(--transition);
  outline: none;
}

.textarea {
  height: auto;
  padding: 12px 14px;
  resize: vertical;
  min-height: 80px;
}

.input:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.label-muted {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* ============================================
   BADGE / PILL
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-primary {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
}

.badge-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.1);
  color: #b45309;
}

.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============================================
   ANIMATIONS UTILS
   ============================================ */
.fade-in {
  animation: fadeIn 400ms ease-out;
}

.slide-up {
  animation: slideUp 500ms cubic-bezier(0.16, 1, 0.3, 1);
}

.pop-in {
  animation: popIn var(--bounce);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes popIn {
  0% { opacity: 0; transform: scale(0.85); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   TOASTS
   ============================================ */
.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px 12px 14px;
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
  max-width: 380px;
  font-size: 13px;
  pointer-events: auto;
  animation: toastIn 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.removing {
  animation: toastOut 250ms ease-in forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(120%); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(120%); }
}

.toast-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.toast-success .toast-icon { background: rgba(16, 185, 129, 0.12); color: var(--success); }
.toast-error .toast-icon { background: rgba(239, 68, 68, 0.12); color: var(--danger); }
.toast-info .toast-icon { background: rgba(99, 102, 241, 0.12); color: var(--primary); }
.toast-warning .toast-icon { background: rgba(245, 158, 11, 0.12); color: var(--warning); }

.toast-icon svg { width: 16px; height: 16px; }

.toast-msg {
  flex: 1;
  color: var(--text);
}

.toast-title { font-weight: 600; }
.toast-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ============================================
   MODAL
   ============================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  z-index: 1000;
  animation: fadeIn 200ms ease-out;
  padding: 24px;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 460px;
  overflow: hidden;
  animation: modalPop 350ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-header {
  padding: 20px 24px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.modal-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.modal-body { padding: 16px 24px 4px; }

.modal-footer {
  padding: 16px 24px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  transition: all var(--transition);
}

.modal-close:hover { background: var(--bg-alt); color: var(--text); }

/* ============================================
   SPINNER
   ============================================ */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.spinner-dark {
  border-color: rgba(15, 23, 42, 0.15);
  border-top-color: var(--text);
}

/* ============================================
   PROGRESS BAR
   ============================================ */
.progress {
  height: 6px;
  background: var(--bg-alt);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 999px;
  transition: width 300ms ease;
  position: relative;
  overflow: hidden;
}

.progress-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  animation: shimmer 1.4s infinite;
}

/* ============================================
   EMPTY STATES
   ============================================ */
.empty {
  text-align: center;
  padding: 60px 24px;
}

.empty-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--gradient-soft);
  display: grid;
  place-items: center;
  margin: 0 auto 20px;
  color: var(--primary);
  animation: float 4s ease-in-out infinite;
}

.empty-icon svg { width: 32px; height: 32px; }

.empty-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.empty-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

/* ============================================
   CONFETTI CANVAS (lock to top layer)
   ============================================ */
#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3000;
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #e4e4e7; border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #d4d4d8; }
