/* Health Package Advisor - Frontend Styles */
/* Inspired by Apple's Human Interface Guidelines */

.health-package-advisor {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    max-width: 800px;
    margin: 40px auto;
    padding: 0 20px;
}

/* Hyperlink Styles for Chat */

/* Links in Assistant messages (White background -> Blue/Purple text) */
.assistant-message .message-content a {
    color: #d9c6bc;
    text-decoration: underline;
    word-break: break-all; /* Prevents long URLs from breaking layout */
    font-weight: 500;
}

.assistant-message .message-content a:hover {
    color: #5a67d8;
}

/* Links in User messages (Purple background -> White text) */
.user-message .message-content a {
    color: #ffffff;
    text-decoration: underline;
    word-break: break-all;
}

.user-message .message-content a:hover {
    opacity: 0.8;
}

/* Quick Consultation Form */
.quick-consultation-form {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    padding: 24px;
    margin-bottom: 24px;
}

.quick-consultation-form h4 {
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
}

.form-section {
    margin-bottom: 20px;
}

.form-row {
    display: flex;
    margin-bottom: 16px;
    align-items: center;
    gap: 16px;
}

.radio-group {
    display: flex;
    gap: 20px;
}

.radio-option {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.radio-option input[type="radio"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid #d1d5db;
    border-radius: 50%;
    outline: none;
    margin-right: 8px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.radio-option input[type="radio"]:checked {
    border-color: #d9c6bc;
    background-color: white;
}

.radio-option input[type="radio"]:checked::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #d9c6bc;
}

.radio-option label {
    font-weight: 500;
    font-size: 15px;
    color: #374151;
    cursor: pointer;
}

.age-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.age-input-group input {
    width: 80px;
    padding: 8px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.2s ease;
}

.age-input-group input:focus {
    outline: none;
    border-color: #d9c6bc;
}

.age-input-group span {
    font-weight: 500;
    color: #374151;
}

.items-section {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    background: #f9fafb;
}

.items-section-title {
    font-size: 16px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 16px;
}

.button-group {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.item-button {
    background-color: white;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    font-family: inherit;
    font-weight: 500;
    font-size: 14px;
    color: #374151;
}

.item-button.selected {
    background-color: #d9c6bc;
    color: #ffffff;
    border-color: #d9c6bc;
}

.item-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.supplement-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    transition: all 0.2s ease;
}

.supplement-textarea:focus {
    outline: none;
    border-color: #d9c6bc;
}

.supplement-textarea::placeholder {
    color: #9ca3af;
}

.start-chat-button {
    width: 100%;
    padding: 14px 24px;
    background: #CD907E;
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
}

.start-chat-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(205, 144, 126, 0.4);
}

.start-chat-button:active {
    transform: translateY(0);
}

@media (max-width: 768px) {
    .button-group {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .item-button {
        padding: 8px 10px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .button-group {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .form-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

.advisor-container {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.advisor-header {
    background: linear-gradient(135deg, #d9c6bc 0%, #764ba2 100%);
    color: #ffffff;
    padding: 32px 28px;
    text-align: center;
}

.advisor-header h3 {
    margin: 0 0 8px 0;
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.advisor-header p {
    margin: 0;
    font-size: 14px;
    opacity: 0.95;
    font-weight: 400;
}

.advisor-chat {
    display: flex;
    flex-direction: column;
    height: 1200px;
}

.chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background: #f8f9fa;
    scroll-behavior: smooth;
}

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.message {
    margin-bottom: 20px;
    display: flex;
    animation: fadeIn 0.3s ease-in;
}

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

.message-content {
    padding: 14px 18px;
    border-radius: 12px;
    max-width: 90%;
    line-height: 1.6;
    font-size: 17px;
}

.user-message {
    justify-content: flex-end;
}

.user-message .message-content {
    background: #06C755;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.assistant-message .message-content {
    background: #ffffff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.sources {
    padding: 8px 0;
    margin-top: -12px;
    margin-bottom: 20px;
    font-size: 13px;
    color: #6b7280;
}

.sources small {
    display: block;
}

.chat-input-area {
    padding: 20px 24px 24px;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
}

.chat-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    transition: all 0.2s ease;
    line-height: 1.5;
    min-height: 52px;
    max-height: 120px;
}

.chat-input:focus {
    outline: none;
    border-color: #d9c6bc;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-input::placeholder {
    color: #9ca3af;
}

.chat-submit {
    width: 100%;
    margin-top: 12px;
    padding: 14px 24px;
    background: #d9c6bc;
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: -0.3px;
}

.chat-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(205, 144, 126, 0.4);
}

.chat-submit:active:not(:disabled) {
    transform: translateY(0);
}

.chat-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.button-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.button-loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .health-package-advisor {
        margin: 20px auto;
        padding: 0 16px;
    }
    
    .advisor-header {
        padding: 24px 20px;
    }
    
    .advisor-header h3 {
        font-size: 20px;
    }
    
    .advisor-chat {
        height: 1200px;
    }
    
    .chat-messages {
        padding: 16px;
    }
    
    .message-content {
        max-width: 90%;
        padding: 12px 16px;
    }
    
    .chat-input-area {
        padding: 16px;
    }
    
   
    .chat-submit {
        padding: 12px 20px;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    .advisor-container {
        background: #1f2937;
    }
    
    .chat-messages {
        background: #111827;
    }
    
    .assistant-message .message-content {
        background: #374151;
        color: #f9fafb;
        border-color: #4b5563;
    }
    
    .chat-input-area {
        background: #1f2937;
        border-top-color: #374151;
    }
    
    .chat-input {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .chat-input:focus {
        border-color: #d9c6bc;
    }
    
    .sources {
        color: #9ca3af;
    }
}

/* Print styles */
@media print {
    .chat-input-area {
        display: none;
    }
    
    .advisor-chat {
        height: auto;
    }
    
    .chat-messages {
        overflow: visible;
    }
}

@keyframes blink {
    0% { opacity: .2; }
    20% { opacity: 1; }
    100% { opacity: .2; }
}

.ai-thinking-dots {
    animation: blink 1.4s infinite both;
    font-size: 24px;
    line-height: 12px;
    letter-spacing: 2px;
    margin: 0;
    padding: 0;
}
