/* Tinreal AI Chat Widget - Glass Effect */
#tinreal-ai-widget {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #1d1d1f;
  -webkit-font-smoothing: antialiased;
}

/* Bubble */
.tinreal-ai-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #11676a;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(17, 103, 106, 0.35);
  z-index: 999999;
  transition: transform 0.2s, box-shadow 0.2s;
}
.tinreal-ai-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(17, 103, 106, 0.45);
}
.tinreal-ai-bubble:active {
  transform: scale(0.95);
}
.tinreal-ai-bubble,
.tinreal-ai-send-btn,
.tinreal-ai-btn,
.tinreal-ai-property-card {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Panel */
.tinreal-ai-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 380px;
  height: 600px;
  max-height: calc(100vh - 48px);
  max-width: calc(100vw - 48px);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 18px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.05);
  z-index: 999999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}
.tinreal-ai-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.tinreal-ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: linear-gradient(135deg, #0d4244 0%, #11676a 100%);
  color: #fff;
  flex-shrink: 0;
}
.tinreal-ai-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.tinreal-ai-avatar {
  font-size: 24px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
}
.tinreal-ai-header-title {
  font-weight: 600;
  font-size: 15px;
}
.tinreal-ai-header-status {
  font-size: 11px;
  opacity: 0.8;
}
.tinreal-ai-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}
.tinreal-ai-close:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* Body */
.tinreal-ai-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
  -webkit-overflow-scrolling: touch;
}
.tinreal-ai-body::-webkit-scrollbar {
  width: 4px;
}
.tinreal-ai-body::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.15);
  border-radius: 4px;
}

/* Messages */
.tinreal-ai-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}
.tinreal-ai-message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  animation: tinrealFadeIn 0.25s ease;
}
.tinreal-ai-message-user {
  align-self: flex-end;
  background: #11676a;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.tinreal-ai-message-ai {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-bottom-left-radius: 4px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.tinreal-ai-message-avatar {
  font-size: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}
.tinreal-ai-message-text {
  flex: 1;
  min-width: 0;
}
.tinreal-ai-message-text code {
  background: rgba(0,0,0,0.06);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 13px;
}

/* Loading dots */
.tinreal-ai-dots {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}
.tinreal-ai-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #11676a;
  animation: tinrealBounce 1.2s infinite;
}
.tinreal-ai-dots span:nth-child(2) { animation-delay: 0.2s; }
.tinreal-ai-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Property cards */
.tinreal-ai-properties {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  animation: tinrealFadeIn 0.3s ease;
}
.tinreal-ai-property-card {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}
.tinreal-ai-property-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.tinreal-ai-property-img {
  width: 80px;
  height: 60px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: #f0f0f0;
}
.tinreal-ai-property-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.tinreal-ai-property-info {
  flex: 1;
  min-width: 0;
}
.tinreal-ai-property-title {
  font-weight: 600;
  font-size: 13px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tinreal-ai-property-details {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: #666;
  margin-top: 4px;
  flex-wrap: wrap;
}
.tinreal-ai-property-meta {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: #999;
  margin-top: 2px;
}

/* Footer / Input */
.tinreal-ai-footer {
  padding: 10px 14px 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.5);
}
.tinreal-ai-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 24px;
  padding: 4px 4px 4px 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.tinreal-ai-input-wrap:focus-within {
  border-color: #11676a;
  box-shadow: 0 0 0 3px rgba(17, 103, 106, 0.15);
}
.tinreal-ai-input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  padding: 8px 0;
  color: #1d1d1f;
}
.tinreal-ai-input-wrap input::placeholder {
  color: #999;
}
.tinreal-ai-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #11676a;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
  flex-shrink: 0;
}
.tinreal-ai-send-btn:hover {
  background: #0d4244;
}
.tinreal-ai-send-btn:active {
  transform: scale(0.9);
}

/* Lead form */
.tinreal-ai-welcome {
  text-align: center;
  padding: 16px 0 8px;
}
.tinreal-ai-welcome-icon {
  font-size: 48px;
  margin-bottom: 8px;
}
.tinreal-ai-welcome h3 {
  margin: 0 0 6px;
  font-size: 18px;
  color: #0d4244;
}
.tinreal-ai-welcome p {
  margin: 0 0 16px;
  color: #666;
  font-size: 13px;
}
.tinreal-ai-lead-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tinreal-ai-field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  font-size: 14px;
  outline: none;
  background: rgba(255, 255, 255, 0.85);
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}
.tinreal-ai-field input:focus {
  border-color: #11676a;
  box-shadow: 0 0 0 3px rgba(17, 103, 106, 0.12);
}
.tinreal-ai-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #11676a 0%, #0d4244 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  margin-top: 4px;
}
.tinreal-ai-btn:hover {
  opacity: 0.9;
}
.tinreal-ai-btn:active {
  transform: scale(0.98);
}
.tinreal-ai-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Animations */
@keyframes tinrealFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes tinrealBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Mobile - optimalizované pre telefóny */
@media (hover: none) and (pointer: coarse) {
  .tinreal-ai-bubble {
    bottom: max(16px, env(safe-area-inset-bottom, 16px));
    right: max(16px, env(safe-area-inset-right, 16px));
    width: 56px;
    height: 56px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .tinreal-ai-send-btn,
  .tinreal-ai-btn,
  .tinreal-ai-close,
  .tinreal-ai-property-card {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
}

@media (max-width: 640px) {
  .tinreal-ai-panel {
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    max-height: 100dvh;
    max-width: 100vw;
    border-radius: 0;
    border: none;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-top: env(safe-area-inset-top, 0px);
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.25s ease;
    opacity: 0;
  }
  .tinreal-ai-panel.open {
    transform: translateY(0);
    opacity: 1;
    height: 100dvh;
  }
  .tinreal-ai-bubble {
    bottom: max(16px, env(safe-area-inset-bottom, 16px));
    right: max(16px, env(safe-area-inset-right, 16px));
    width: 52px;
    height: 52px;
  }
  .tinreal-ai-header {
    padding: 12px 14px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }
  .tinreal-ai-body {
    padding: 12px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: 4px;
  }
  .tinreal-ai-footer {
    padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 8px));
  }
  .tinreal-ai-input-wrap input {
    font-size: 16px;
    padding: 10px 0;
  }
  .tinreal-ai-send-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }
  .tinreal-ai-message {
    max-width: 90%;
    padding: 12px 14px;
    font-size: 15px;
  }
  .tinreal-ai-property-card {
    padding: 12px;
  }
  .tinreal-ai-property-img {
    width: 72px;
    height: 54px;
  }
  .tinreal-ai-welcome-icon {
    font-size: 40px;
  }
  .tinreal-ai-field input {
    padding: 14px;
    font-size: 16px;
  }
  .tinreal-ai-btn {
    padding: 14px;
    font-size: 16px;
  }
  .tinreal-ai-lead-form {
    gap: 12px;
  }
}

@media (max-width: 400px) {
  .tinreal-ai-panel {
    border-radius: 0;
  }
  .tinreal-ai-header {
    padding: 10px 12px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
  }
  .tinreal-ai-header-title {
    font-size: 14px;
  }
  .tinreal-ai-body {
    padding: 8px;
  }
  .tinreal-ai-message {
    max-width: 95%;
    padding: 10px 12px;
    font-size: 14px;
  }
  .tinreal-ai-footer {
    padding: 6px 8px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 6px));
  }
  .tinreal-ai-property-card {
    flex-direction: column;
  }
  .tinreal-ai-property-img {
    width: 100%;
    height: 100px;
  }
  .tinreal-ai-input-wrap input {
    font-size: 16px;
  }
}

/* iOS Safari notch + dynamic island bezpečná zóna */
@supports (padding-top: env(safe-area-inset-top)) {
  .tinreal-ai-panel.open {
    padding-top: 0;
    padding-bottom: 0;
  }
}

/* Redukcia motion pre používateľov čo preferujú */
@media (prefers-reduced-motion: reduce) {
  .tinreal-ai-panel,
  .tinreal-ai-bubble,
  .tinreal-ai-message {
    transition: none !important;
    animation: none !important;
  }
}
