:root {
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.12);
  --radius-lg: 32px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --golden-l: rgb(242, 192, 113);
  --golden-d: rgb(175, 130, 55);
  --turq: rgb(0, 184, 182);
  --accent: rgb(118, 167, 246);
  --accent1: rgb(62, 106, 177);
  --fs-base: 1.05rem;
}

body.light {
  --bg-sefid: #f8faff;
  --bg-khak: #f0f7ff;
  --bg-card: rgba(255, 255, 255, 0.7);
  --border-light: rgba(0, 0, 0, 0.06);
  --text-primary: #0a0a1a;
  --text-secondary: #4a4a6a;
  --shadow-color: rgba(0, 20, 80, 0.08);
  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-border: rgba(255, 255, 255, 0.25);
  --message-user: #eef5ff;
  --message-ai: #ffffff;
  --bg-khak2: #dcebf9;
}

body.dark {
  --bg-sefid: #0c0e1a;
  --bg-khak: #161b2e;
  --bg-card: rgba(20, 25, 45, 0.75);
  --border-light: rgba(255, 255, 255, 0.06);
  --text-primary: #f0f2ff;
  --text-secondary: #a8b0d0;
  --shadow-color: rgba(0, 0, 0, 0.4);
  --glass-bg: rgba(15, 20, 40, 0.6);
  --glass-border: rgba(255, 255, 255, 0.08);
  --message-user: #1e2648;
  --message-ai: #161b2e;
  --bg-khak2: #112240;
}

.ai-container {
  padding: 20px;
  max-width: 1300px;
  width: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  min-height: 85vh;
  align-items: start;
}

.profile-section {
  background: var(--bg-khak);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: 0 0 1px var(--black-hover);
  transition: var(--transition);
  position: sticky;
  top: 20px;
}

.input-group-modern {
  margin-bottom: 18px;
}

.input-group-modern label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  color: var(--black);
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.input-group-modern label i {
  color: var(--accent);
  width: 20px;
}

.slider-wrapper {
  display: flex;
  align-items: center;
  gap: 14px;
}

.slider-wrapper input[type="range"] {
  flex: 1;
  height: 5px;
  -webkit-appearance: none;
  background: linear-gradient(to left, #10b981, #f59e0b, #ef4444);
  border-radius: 4px;
  outline: none;
  transition: opacity 0.2s;
}

.slider-wrapper input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  border: 2px solid var(--accent);
  transition: 0.15s;
}

.slider-wrapper input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.12);
}

.age-risk-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--text-secondary);
  font-size: 0.73rem;
  line-height: 1.8;
}

.age-risk-note i {
  color: var(--accent);
  margin-top: 3px;
  flex: 0 0 auto;
}

.slider-value {
  min-width: 48px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-card);
  padding: 2px 10px;
  border-radius: 30px;
  text-align: center;
  font-size: 0.95rem;
  border: 1px solid var(--border-light);
}

.input-group {
  margin-bottom: 1.4rem;
}

.input-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.input-label-text {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.87rem;
  font-weight: 500;
  color: var(--black-hover);
}

.input-label-text i {
  color: var(--accent);
  width: 16px;
  text-align: center;
}

input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(
    to left,
    var(--accent),
    var(--accent1),
    var(--golden-d)
  );
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  position: relative;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  border: 2px solid var(--accent);
  transition: transform 0.15s;
}

input[type="range"]::-webkit-slider-thumb:active {
  transform: scale(1.2);
  border-color: var(--golden-l);
}

.radio-group {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.4rem;
}

.radio-option {
  flex: 1;
  position: relative;
}

.radio-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.radio-label {
  display: block;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--black-hover);
  border-radius: 8px;
  text-align: center;
  font-size: 0.82rem;
  cursor: pointer;
  transition: var(--transition);
  color: var(--black-hover);
  font-weight: 500;
  background: var(--bg-sefid);
}

.radio-option input[type="radio"]:checked + .radio-label {
  border-color: var(--accent);
  background: rgba(118, 167, 246, 0.12);
  color: var(--accent);
}

.chat-section {
  position: sticky;
  top: 20px;
  background: var(--bg-khak2);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 0 1px var(--black-hover);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 40px);
  overflow: hidden;
  transition: var(--transition);
}

.chat-header {
  padding: 20px 28px;
  background-color: var(--accent);
  box-shadow: 0 10px 20px rgba(126, 126, 126, 0.4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.chat-header-left .ai-badge {
  background: linear-gradient(135deg, var(--golden-d), var(--golden-l));
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 14px;
  border-radius: 30px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.chat-header-left h3 {
  font-size: 1.2rem;
  font-weight: 600;
}

.chat-header .status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: white;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10b981;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.5;
    transform: scale(0.85);
  }
}

.chat-messages {
  flex: 1;
  padding: 24px 28px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 10px;
}

.message {
  max-width: 88%;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  animation: msgIn 0.4s ease;
  line-height: 1.7;
  font-size: 0.98rem;
  box-shadow: var(--shadow-sm);
}

@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.message.user {
  align-self: flex-end;
  background: var(--message-user);
  border-bottom-left-radius: 6px;
  border: 1px solid var(--border-light);
  color: var(--text-primary);
}

.message.ai {
  align-self: flex-start;
  background: var(--message-ai);
  border-bottom-right-radius: 6px;
  border: 1px solid var(--border-light);
  color: var(--text-primary);
}

.message.ai .typing-cursor {
  display: inline-block;
  width: 3px;
  height: 1.1em;
  background: var(--accent);
  margin-right: 4px;
  animation: blink 1s infinite;
  vertical-align: text-bottom;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0;
  }
}

.message .msg-time {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 6px;
  opacity: 0.6;
}

.risk-result-badge {
  background: linear-gradient(135deg, var(--bg-khak), var(--bg-card));
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  margin-top: 10px;
  border-right: 4px solid var(--accent);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
}

.risk-result-badge .risk-stats {
  flex: 1;
}

.risk-stats .risk-percent-big {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.risk-stats .risk-label {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.risk-level-tag {
  display: inline-block;
  padding: 4px 16px;
  border-radius: 40px;
  font-weight: 600;
  font-size: 0.85rem;
  margin-top: 4px;
}

.risk-level-tag.low {
  background: #10b981;
  color: #fff;
}

.risk-level-tag.moderate {
  background: #f59e0b;
  color: #fff;
}

.risk-level-tag.high {
  background: #ef4444;
  color: #fff;
}

.heart-age-card {
  margin-top: 12px;
  padding: 18px 20px;
  border-radius: var(--radius-sm);
  background: linear-gradient(
    135deg,
    rgba(118, 167, 246, 0.1),
    rgba(242, 192, 113, 0.1)
  );
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 18px;
}

.heart-age-number {
  min-width: 96px;
  height: 96px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 3px solid var(--accent);
  box-shadow: var(--shadow-sm);
}

.heart-age-number strong {
  font-size: 1.7rem;
  line-height: 1.1;
}

.heart-age-number span {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.heart-age-title {
  font-weight: 800;
  font-size: 1rem;
  margin-bottom: 3px;
}

.heart-age-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

@media (max-width: 600px) {
  .heart-age-card {
    flex-direction: column;
    text-align: center;
  }
}

.chat-input-area {
  padding: 18px 28px 22px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 12px;
  flex-shrink: 0;
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
}

.chat-input-area input {
  flex: 1;
  padding: 14px 20px;
  border-radius: 60px;
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.chat-input-area input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(118, 167, 246, 0.15);
}

.chat-input-area input::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

.chat-input-area button {
  padding: 12px 26px;
  border-radius: 60px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent1));
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(118, 167, 246, 0.25);
}

.chat-input-area button:hover {
  transform: scale(0.97);
  box-shadow: 0 6px 20px rgba(118, 167, 246, 0.35);
}

.chat-input-area button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.calc-trigger-btn {
  width: 100%;
  padding: 16px;
  margin-top: 18px;
  border: none;
  border-radius: 60px;
  background: linear-gradient(135deg, var(--golden-d), var(--golden-l));
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 16px rgba(175, 130, 55, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.calc-trigger-btn:hover {
  transform: scale(0.98);
  box-shadow: 0 6px 24px rgba(175, 130, 55, 0.3);
}

@media (max-width: 1024px) {
  .ai-container {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .profile-section {
    position: static;
  }

  .chat-section {
    height: 70vh;
    min-height: 500px;
  }
}

@media (max-width: 600px) {
  .chat-messages {
    padding: 16px;
  }

  .message {
    max-width: 96%;
  }

  .chat-input-area {
    flex-wrap: wrap;
  }

  .chat-input-area button {
    width: 100%;
    justify-content: center;
  }

  .risk-result-badge {
    flex-direction: column;
    align-items: stretch;
  }
}

.float-animation {
  animation: floatY 4s ease-in-out infinite alternate;
}

@keyframes floatY {
  0% {
    transform: translateY(0);
  }

  100% {
    transform: translateY(-10px);
  }
}

html {
  scroll-behavior: smooth;
}
