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

:root {
  --primary: #10b981;
  --primary-hover: #059669;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: linear-gradient(180deg, 
    #f6fefb 0%, 
    #f8fafc 30%, 
    #f9fafb 50%, 
    #f7fcfa 70%,
    #f5fdf9 100%
  );
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(90deg, rgba(16, 185, 129, 0.02) 1px, transparent 1px),
    linear-gradient(rgba(16, 185, 129, 0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  top: -50%;
  right: -10%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(5, 150, 105, 0.05) 0%, transparent 70%);
  border-radius: 50%;
  animation: float 20s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes float {
  0%, 100% {
    transform: translate(0, 0) scale(1);
  }
  33% {
    transform: translate(-30px, 50px) scale(1.1);
  }
  66% {
    transform: translate(30px, -30px) scale(0.9);
  }
}

.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile */
  max-width: 100%;
  position: relative;
  z-index: 1;
}

.container::before {
  content: '';
  position: fixed;
  bottom: -20%;
  left: -20%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.04) 0%, transparent 70%);
  border-radius: 50%;
  animation: floatReverse 25s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes floatReverse {
  0%, 100% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(40px, -60px);
  }
}

/* Header */
.header {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  padding: 16px;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  width: 100%;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 100%;
  margin: 0 auto;
}

/* Desktop: centered content in header */
@media (min-width: 1024px) {
  .header-content {
    max-width: 1000px;
    padding: 0 20px;
  }
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--primary);
}

.logo-icon {
  font-size: 24px;
  line-height: 1;
}

.logo h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

@media (max-width: 480px) {
  .logo h1 {
    font-size: 16px;
  }
  
  .logo-icon {
    font-size: 20px;
  }
}

.icon-btn {
  background: transparent;
  border: none;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.icon-btn:active {
  transform: scale(0.95);
}

/* Quick Actions */
.quick-actions {
  display: flex;
  justify-content: center;
  padding: 16px;
  flex: 1 1 0;
  overflow-y: auto;
  overflow-x: hidden;
  align-items: flex-start;
  min-height: 0;
  width: 100%;
  margin: 0 auto;
}

@media (min-width: 1024px) {
  .quick-actions {
    max-width: 1000px;
  }
}

.quick-actions-wrapper {
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (min-width: 768px) {
  .quick-actions-wrapper {
    gap: 20px;
  }
}

.quick-hint {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  padding: 0 16px;
}

.symptoms-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
}

@media (min-width: 768px) {
  .symptoms-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }
}

@media (min-width: 1024px) {
  .symptoms-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
  }
}

.symptom-card {
  background: var(--bg-primary);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 16px 12px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  animation: fadeInCard 0.4s ease backwards;
  min-height: 90px;
}

@media (min-width: 1024px) {
  .symptom-card {
    padding: 20px 16px;
    min-height: 110px;
  }
}

.symptom-card:nth-child(1) { animation-delay: 0.05s; }
.symptom-card:nth-child(2) { animation-delay: 0.1s; }
.symptom-card:nth-child(3) { animation-delay: 0.15s; }
.symptom-card:nth-child(4) { animation-delay: 0.2s; }
.symptom-card:nth-child(5) { animation-delay: 0.25s; }
.symptom-card:nth-child(6) { animation-delay: 0.3s; }
.symptom-card:nth-child(7) { animation-delay: 0.35s; }
.symptom-card:nth-child(8) { animation-delay: 0.4s; }

/* Mobile: show only first 4 symptoms */
@media (max-width: 767px) {
  .symptom-card:nth-child(5),
  .symptom-card:nth-child(6),
  .symptom-card:nth-child(7),
  .symptom-card:nth-child(8) {
    display: none;
  }
}

@keyframes fadeInCard {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.symptom-card:hover {
  border-color: #10b981;
  background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.2);
}

.symptom-card:active {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(16, 185, 129, 0.15);
}

.symptom-icon {
  font-size: 28px;
  line-height: 1;
  transition: transform 0.2s;
}

@media (min-width: 768px) {
  .symptom-icon {
    font-size: 32px;
  }
}

@media (min-width: 1024px) {
  .symptom-icon {
    font-size: 36px;
  }
}

.symptom-card:hover .symptom-icon {
  transform: scale(1.15);
}

.symptom-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

@media (min-width: 768px) {
  .symptom-text {
    font-size: 13px;
  }
}

@media (min-width: 1024px) {
  .symptom-text {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .symptom-card {
    min-height: 75px;
    padding: 12px 10px;
  }
}

.start-custom-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border: none;
  border-radius: 16px;
  padding: 18px 24px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.2s;
  margin-top: 8px;
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35);
  width: 100%;
}

.start-custom-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4);
}

.start-custom-btn:active {
  transform: translateY(0);
  opacity: 0.9;
}

.start-custom-btn svg {
  width: 20px;
  height: 20px;
}

/* Messages Area */
.messages {
  flex: 0 0 auto;
  overflow: visible;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  max-height: none;
  width: 100%;
  margin: 0 auto;
}

@media (min-width: 1024px) {
  .messages {
    max-width: 1000px;
  }
}

.messages.has-chat-history {
  flex: 1 1 0;
  overflow-y: auto;
  padding: 16px;
  max-height: none;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.messages > * {
  position: relative;
  z-index: 1;
}

.welcome-message {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  padding: 16px 20px;
  border-radius: 14px;
  text-align: center;
  width: 100%;
  max-width: none;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.3);
  margin-bottom: 8px;
}

@media (min-width: 768px) {
  .welcome-message {
    padding: 24px 32px;
    border-radius: 16px;
  }
}

.welcome-message::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.3;
  }
}

.welcome-message h2 {
  font-size: 17px;
  margin-bottom: 6px;
  position: relative;
  z-index: 1;
}

.welcome-message p {
  font-size: 13px;
  opacity: 0.95;
  line-height: 1.5;
  position: relative;
  z-index: 1;
}

@media (min-width: 768px) {
  .welcome-message h2 {
    font-size: 20px;
    margin-bottom: 8px;
  }
  
  .welcome-message p {
    font-size: 14px;
    line-height: 1.6;
  }
}

.message {
  display: flex;
  gap: 10px;
  animation: slideInUp 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  width: 100%;
}

.message.user {
  flex-direction: row-reverse;
}

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

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.message-avatar.user-avatar {
  background: #a7f3d0;
  color: #065f46;
}

@media (max-width: 480px) {
  .message-avatar {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
}

.message-content {
  flex: 1;
  max-width: 85%;
  display: flex;
  flex-direction: column;
}

@media (min-width: 1024px) {
  .message-content {
    max-width: 70%;
  }
}

.message.user .message-content {
  align-items: flex-end;
}

.message-bubble {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  padding: 14px 16px;
  border-radius: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  width: fit-content;
  max-width: 100%;
}

.message-bubble.user-bubble {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-color: transparent;
  color: white;
}

.message-bubble strong,
.message-bubble b {
  font-weight: 700;
}

.message-bubble p {
  margin: 0;
}

.streaming-bubble {
  animation: fadeIn 0.3s ease-in;
}

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

.message-time {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  padding: 0 4px;
}

/* Scroll to bottom button */
.scroll-to-bottom {
  padding: 0 16px 12px;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
  animation: slideUp 0.3s ease;
  width: 100%;
  margin: 0 auto;
}

@media (min-width: 1024px) {
  .scroll-to-bottom {
    max-width: 1000px;
  }
}

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

.scroll-btn {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.scroll-btn:hover {
  background: #10b981;
  color: white;
  border-color: #10b981;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

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

.scroll-btn svg {
  animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(3px);
  }
}

/* Typing Indicator */
.typing-indicator {
  padding: 0 16px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  flex-shrink: 0;
  width: 100%;
  margin: 0 auto;
}

@media (min-width: 1024px) {
  .typing-indicator {
    max-width: 1000px;
  }
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

.typing-text {
  font-size: 13px;
}

/* Input Area */
.input-area {
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  flex: 0 0 auto;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
  width: 100%;
}

@media (min-width: 768px) {
  .input-area {
    padding: 16px 20px;
  }
}

/* Desktop: centered input */
.input-area > * {
  max-width: 100%;
  margin: 0 auto;
}

@media (min-width: 1024px) {
  .input-area > * {
    max-width: 1000px;
  }
}

/* Mobile: safe area padding for notch/home indicator */
@supports (padding: max(0px)) {
  .input-area {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}

.input-area::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(16, 185, 129, 0.5), transparent);
}

.input-wrapper {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

#messageInput {
  flex: 1;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 14px;
  resize: none;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.6;
  max-height: 140px;
  overflow-y: auto;
  background: var(--bg-secondary);
  transition: all 0.2s;
  min-height: 52px;
  -webkit-appearance: none;
}

#messageInput:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg-primary);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

#messageInput::placeholder {
  color: var(--text-secondary);
  font-size: 14px;
}

.send-btn {
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.45);
}

.send-btn svg {
  width: 24px;
  height: 24px;
}

.send-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.55);
}

.send-btn:active:not(:disabled) {
  transform: translateY(0);
}

.send-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  opacity: 0.6;
  box-shadow: none;
}

.input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  gap: 12px;
}

.input-hint {
  font-size: 12px;
  color: var(--text-secondary);
  flex: 1;
}

@media (max-width: 480px) {
  .input-hint {
    font-size: 11px;
  }
}

/* Scrollbar */
.messages::-webkit-scrollbar {
  width: 8px;
}

.messages::-webkit-scrollbar-track {
  background: transparent;
}

.messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.messages::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Error State */
.error-message {
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 14px;
  margin: 0 16px;
  animation: slideInUp 0.3s ease;
}

@media (max-width: 480px) {
  .error-message {
    font-size: 13px;
    padding: 12px 14px;
  }
}

/* Touch improvements for mobile */
@media (hover: none) and (pointer: coarse) {
  .symptom-card:hover {
    transform: none;
    box-shadow: none;
  }
  
  .symptom-card:active {
    transform: scale(0.97);
    background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
    border-color: #10b981;
  }
  
  .icon-btn:hover {
    background: transparent;
  }
  
  .icon-btn:active {
    background: var(--bg-tertiary);
  }
}
