/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', 'SimHei', Arial, sans-serif;
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    color: #333;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Container adapts to iframe or full screen */
.container {
    width: 100%;
    height: 100vh;
    max-width: 100%;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
}

/* Check if in iframe and adjust height */
@media screen and (max-height: 500px) {
    .container {
        height: 450px;
    }
}

/* Header with tooltip functionality */
.header {
    background: linear-gradient(135deg, #4fc3f7 0%, #29b6f6 100%);
    color: white;
    text-align: center;
    padding: 8px 15px;
    border-radius: 12px;
    font-size: 18px;
    font-weight: bold;
    cursor: help;
    box-shadow: 0 2px 8px rgba(79, 195, 247, 0.3);
    transition: transform 0.2s ease;
}

.header:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 195, 247, 0.4);
}

/* Doctor panel */
.doctor-panel {
    background: white;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 4px solid #4fc3f7;
}

.doctor-avatar {
    font-size: 32px;
    flex-shrink: 0;
}

.welcome-message {
    font-size: 14px;
    color: #555;
    flex: 1;
}

/* Input section */
.input-section {
    background: white;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#sentenceInput {
    width: 100%;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 60px;
    transition: border-color 0.3s ease;
}

#sentenceInput:focus {
    outline: none;
    border-color: #4fc3f7;
    box-shadow: 0 0 0 3px rgba(79, 195, 247, 0.1);
}

.diagnose-btn, .clear-btn {
    background: linear-gradient(135deg, #66bb6a 0%, #4caf50 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px; /* Touch-friendly size */
}

.diagnose-btn:hover, .clear-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.diagnose-btn:active, .clear-btn:active {
    transform: translateY(0);
}

.clear-btn {
    background: linear-gradient(135deg, #ff7043 0%, #f4511e 100%);
}

.clear-btn:hover {
    box-shadow: 0 4px 12px rgba(255, 112, 67, 0.3);
}

/* Result panel */
.result-panel {
    background: white;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.5s ease;
}

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

.diagnosis-section, .treatment-section, .explanation-section, .encouragement-section {
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 8px;
    border-left: 4px solid transparent;
}

.diagnosis-section {
    background: #fff3e0;
    border-left-color: #ff9800;
}

.treatment-section {
    background: #e8f5e8;
    border-left-color: #4caf50;
}

.explanation-section {
    background: #e3f2fd;
    border-left-color: #2196f3;
}

.encouragement-section {
    background: #fce4ec;
    border-left-color: #e91e63;
}

.section-title {
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 8px;
    color: #333;
}

.section-content {
    font-size: 13px;
    color: #555;
    line-height: 1.5;
}

/* Examples panel */
.examples-panel {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.examples-title {
    background: linear-gradient(135deg, #ab47bc 0%, #8e24aa 100%);
    color: white;
    padding: 12px 15px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.3s ease;
}

.examples-title:hover {
    background: linear-gradient(135deg, #8e24aa 0%, #7b1fa2 100%);
}

.toggle-icon {
    transition: transform 0.3s ease;
}

.examples-title.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.examples-content {
    padding: 15px;
    max-height: 200px;
    overflow-y: auto;
    transition: max-height 0.3s ease;
}

.examples-content.collapsed {
    max-height: 0;
    padding: 0 15px;
    overflow: hidden;
}

.example-category {
    margin-bottom: 15px;
}

.example-category h4 {
    color: #666;
    font-size: 13px;
    margin-bottom: 8px;
    border-bottom: 1px solid #eee;
    padding-bottom: 4px;
}

.example-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.example-item:hover {
    background: #e3f2fd;
    border-color: #4fc3f7;
    transform: translateX(4px);
}

.example-item:active {
    transform: translateX(2px);
}

/* Action buttons */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    max-width: 250px;
    word-wrap: break-word;
}

.tooltip.show {
    opacity: 1;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .container {
        padding: 8px;
        gap: 8px;
    }
    
    .header {
        font-size: 16px;
        padding: 6px 12px;
    }
    
    .doctor-panel, .input-section, .result-panel, .examples-panel {
        padding: 12px;
    }
    
    .doctor-avatar {
        font-size: 28px;
    }
    
    .welcome-message {
        font-size: 13px;
    }
    
    #sentenceInput {
        font-size: 16px; /* Prevent zoom on iOS */
        min-height: 50px;
    }
    
    .diagnose-btn, .clear-btn {
        padding: 14px 20px;
        font-size: 16px;
        min-height: 48px;
    }
    
    .example-item {
        padding: 10px 12px;
        font-size: 13px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .container {
        background: white;
    }
    
    .header {
        background: #000;
        color: #fff;
    }
    
    .doctor-panel, .input-section, .result-panel, .examples-panel {
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}