/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #10b981;
    --accent-color: #f59e0b;
    --text-dark: #1f2937;
    --text-light: #6b7280;
    --bg-light: #f8fafc;
    --bg-white: #ffffff;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: var(--bg-white);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 20px;
}

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

.logo i {
    font-size: 2rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.nav {
    display: flex;
    gap: 2rem;
}

.nav a {
    text-decoration: none;
    color: var(--text-light);
    font-weight: 500;
    transition: var(--transition);
}

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

/* Welcome Section */
.welcome-section {
    padding: 4rem 0;
    text-align: center;
    color: white;
}

.welcome-content h2 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.welcome-content p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    opacity: 0.9;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.cta-button {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-lg);
}

.cta-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.2);
}

.api-key-notice {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin: 1rem 0;
    backdrop-filter: blur(10px);
}

.api-key-notice p {
    margin: 0;
    color: white;
    font-weight: 500;
}

.api-key-notice i {
    margin-right: 0.5rem;
    color: var(--accent-color);
}

/* Body Selection Section */
.body-selection-section,
.symptoms-section,
.chat-section {
    background: var(--bg-white);
    margin: 2rem 20px;
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
}

.body-selection-section h2,
.symptoms-section h2,
.chat-section h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--text-dark);
    font-size: 2rem;
    font-weight: 600;
}

.body-diagram-container {
    display: flex;
    gap: 3rem;
    align-items: flex-start;
    justify-content: center;
    flex-wrap: wrap;
}

.body-diagram {
    flex: 1;
    max-width: 300px;
    min-width: 250px;
}

.body-svg {
    width: 100%;
    height: auto;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-light);
}

.body-part {
    fill: var(--primary-color);
    stroke: white;
    stroke-width: 2;
    cursor: pointer;
    transition: var(--transition);
    opacity: 0.7;
}

.body-part:hover {
    opacity: 1;
    transform: scale(1.05);
    fill: var(--secondary-color);
}

.body-part.selected {
    fill: var(--accent-color);
    opacity: 1;
    animation: pulse 2s infinite;
}

.body-label {
    font-size: 10px;
    font-weight: 600;
    fill: white;
    pointer-events: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes boxPulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: var(--shadow-lg);
    }
    50% { 
        transform: scale(1.02);
        box-shadow: 0 20px 25px -5px rgb(37 99 235 / 0.4), 0 10px 10px -5px rgb(37 99 235 / 0.2);
    }
}

.selected-area {
    flex: 1;
    min-width: 250px;
    background: var(--bg-light);
    padding: 2rem;
    border-radius: var(--border-radius);
    text-align: center;
}

.selected-area h3 {
    margin-bottom: 1rem;
    color: var(--text-dark);
}

.selected-area span {
    color: var(--primary-color);
    font-weight: 600;
}

.continue-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.continue-btn:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.continue-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Symptoms Section */
.symptoms-container {
    max-width: 800px;
    margin: 0 auto;
}

.common-symptoms,
.custom-symptoms,
.severity-scale {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-light);
    border-radius: var(--border-radius);
}

.common-symptoms h3,
.custom-symptoms h3,
.severity-scale h3 {
    margin-bottom: 1rem;
    color: var(--text-dark);
}

.symptom-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.symptom-tag {
    background: var(--bg-white);
    border: 2px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 25px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.symptom-tag:hover {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
}

.symptom-tag.selected {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
    color: white;
}

#symptom-description {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    transition: var(--transition);
}

#symptom-description:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Symptom Photo Section */
.symptom-photo-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.symptom-photo-section h4 {
    margin-bottom: 0.5rem;
    color: var(--text-dark);
    font-size: 1rem;
}

.photo-help-text {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 1rem;
}

.photo-upload-area {
    margin-bottom: 1rem;
}

.photo-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-light);
    color: var(--text-light);
}

.photo-upload-label:hover {
    border-color: var(--primary-color);
    background: #f0f9ff;
    color: var(--primary-color);
}

.photo-upload-label i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.photo-upload-label span {
    font-size: 0.9rem;
    font-weight: 500;
}

.photo-note {
    font-size: 0.85rem;
    color: var(--secondary-color);
    margin-top: 0.5rem;
    font-style: italic;
}

.photo-note i {
    margin-right: 0.25rem;
}

.symptom-photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.symptom-photo-item {
    position: relative;
    border-radius: var(--border-radius);
    overflow: hidden;
    border: 2px solid var(--border-color);
    background: white;
}

.symptom-photo-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

.symptom-photo-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: var(--transition);
}

.symptom-photo-remove:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.scale-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#severity-scale {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: var(--border-color);
    outline: none;
    appearance: none;
}

#severity-scale::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
}

#severity-scale::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
}

.scale-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-light);
}

#severity-value {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    font-weight: 600;
}

/* Chat Section */
.chat-container {
    max-width: 800px;
    margin: 0 auto;
    height: 600px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.chat-header {
    background: var(--primary-color);
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.doctor-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.doctor-avatar {
    width: 50px;
    height: 50px;
    background: var(--secondary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.doctor-details h3 {
    margin: 0;
    font-size: 1.1rem;
}

.status {
    font-size: 0.9rem;
    opacity: 0.8;
}

.restart-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.restart-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    background: var(--bg-light);
}

.message {
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

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

.message-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.message.ai .message-avatar {
    background: var(--primary-color);
    color: white;
}

.message.user .message-avatar {
    background: var(--secondary-color);
    color: white;
}

.message-content {
    max-width: 70%;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    line-height: 1.5;
}

.message.ai .message-content {
    background: white;
    border: 1px solid var(--border-color);
}

.message.user .message-content {
    background: var(--primary-color);
    color: white;
}

/* AI Response Formatting */
.message.ai .message-content h4.response-header {
    color: var(--primary-color);
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    font-weight: 600;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.25rem;
}

.message.ai .message-content h5.response-subheader {
    color: var(--secondary-color);
    margin: 1rem 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 500;
}

.message.ai .message-content p {
    margin: 0.75rem 0;
    line-height: 1.6;
}

.message.ai .message-content ul.response-list {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
}

.message.ai .message-content ul.response-list li {
    margin: 0.5rem 0;
    line-height: 1.5;
    color: var(--text-color);
}

.message.ai .message-content strong {
    color: var(--primary-color);
    font-weight: 600;
}

.message.ai .message-content em {
    font-style: italic;
    color: var(--secondary-color);
}

.chat-input-container {
    padding: 1rem;
    background: white;
    border-top: 1px solid var(--border-color);
}

.chat-input {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.photo-upload-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.photo-upload-btn:hover {
    background: #059669;
    transform: scale(1.05);
}

.photo-preview {
    margin-top: 0.5rem;
    position: relative;
    display: inline-block;
    max-width: 200px;
}

.photo-preview img {
    width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    border: 2px solid var(--border-color);
}

.remove-photo-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ef4444;
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: var(--transition);
}

.remove-photo-btn:hover {
    background: #dc2626;
    transform: scale(1.1);
}

#user-message {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

#user-message:focus {
    border-color: var(--primary-color);
}

#send-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

#send-btn:hover {
    background: var(--primary-dark);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    max-width: 500px;
    width: 90%;
    text-align: center;
}

.modal-content h3 {
    margin-bottom: 1rem;
    color: var(--text-dark);
}

.modal-content p {
    margin-bottom: 1rem;
    color: var(--text-light);
}

#api-key-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    font-size: 1rem;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.modal-buttons button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.modal-buttons button:first-child {
    background: var(--primary-color);
    color: white;
}

.modal-buttons button:last-child {
    background: var(--border-color);
    color: var(--text-dark);
}

.api-note {
    font-size: 0.9rem;
    color: var(--text-light);
}

.api-note a {
    color: var(--primary-color);
    text-decoration: none;
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .welcome-content h2 {
        font-size: 2rem;
    }
    
    .body-diagram-container {
        flex-direction: column;
        align-items: center;
    }
    
    .nav {
        display: none;
    }
    
    .chat-container {
        height: 500px;
    }
    
    .symptoms-section,
    .body-selection-section,
    .chat-section {
        margin: 1rem 10px;
        padding: 1rem;
    }
    
    .message-content {
        max-width: 85%;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }
    
    .welcome-content h2 {
        font-size: 1.5rem;
    }
    
    .welcome-content p {
        font-size: 1rem;
    }
}

/* API Status Box */
.api-status-box {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 300px;
    background: var(--bg-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.api-status-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--primary-color);
    color: white;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    cursor: pointer;
}

.api-status-header i {
    margin-right: 0.5rem;
}

.api-status-toggle {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: var(--transition);
}

.api-status-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

.api-status-content {
    padding: 1rem;
    max-height: 300px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.api-status-content.collapsed {
    max-height: 0;
    padding: 0 1rem;
}

.api-status-indicator {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: var(--bg-light);
    border-radius: var(--border-radius);
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 0.75rem;
    background: #ef4444;
    transition: var(--transition);
}

.status-dot.connected {
    background: var(--secondary-color);
}

.status-dot.loading {
    background: var(--accent-color);
    animation: pulse 1.5s infinite;
}

.api-key-input-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

#api-key-input-persistent {
    flex: 1;
    padding: 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

#api-key-input-persistent:focus {
    border-color: var(--primary-color);
}

.save-api-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.save-api-btn:hover {
    background: #059669;
    transform: scale(1.05);
}

.api-key-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.test-api-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.test-api-btn:hover {
    background: #d97706;
    transform: scale(1.05);
}

.debug-api-btn {
    background: #8b5cf6;
    color: white;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.debug-api-btn:hover {
    background: #7c3aed;
    transform: scale(1.05);
}

.clear-api-btn {
    background: #ef4444;
    color: white;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.clear-api-btn:hover {
    background: #dc2626;
    transform: scale(1.05);
}

.get-api-link {
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.get-api-link:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

/* Responsive adjustments for API status box */
@media (max-width: 768px) {
    .api-status-box {
        width: calc(100vw - 40px);
        left: 20px;
        right: 20px;
    }
}

/* Utility Classes */
.hidden {
    display: none;
}

.text-center {
    text-align: center;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mt-2 {
    margin-top: 1rem;
} 