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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    overflow-x: hidden;
}

/* Main container - adapts to iframe or standalone */
#main-container {
    width: 100%;
    height: 450px; /* Default for iframe */
    overflow-y: auto;
    overflow-x: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 15px;
    position: relative;
}

/* Detect if opened in new tab - use 90vh */
@media (min-height: 600px) {
    body.standalone #main-container {
        height: 90vh;
    }
}

/* Header tooltip - shows on hover over main container */
#header-tooltip {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
    max-width: 90%;
    text-align: center;
}

#main-container:hover #header-tooltip {
    opacity: 1;
}

/* Content sections */
.content-section {
    background: white;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.content-section:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

/* Introduction section */
.intro-section {
    background: linear-gradient(135deg, #ffffff 0%, #f0f0f0 100%);
}

.intro-text p {
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.5;
}

/* Section titles */
.section-title {
    font-size: 18px;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 10px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 5px;
}

.section-intro {
    font-size: 13px;
    color: #666;
    margin-bottom: 12px;
    font-style: italic;
}

/* Accordion styles - Cognitive load reduction through progressive disclosure */
.accordion-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.accordion-item {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.accordion-item:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

/* Accordion button - optimized for touch and mouse */
.accordion-button {
    width: 100%;
    padding: 12px 15px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    transition: all 0.3s ease;
    text-align: left;
    min-height: 44px; /* Touch-friendly target size */
}

.accordion-button:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.accordion-button:active {
    transform: scale(0.98);
}

.accordion-button.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.accordion-title {
    flex: 1;
}

.accordion-icon {
    font-size: 20px;
    font-weight: bold;
    transition: transform 0.3s ease;
}

.accordion-button.active .accordion-icon {
    transform: rotate(45deg);
}

/* Accordion content - hidden by default */
.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    background: #fafafa;
    padding: 0 15px;
}

.accordion-content.active {
    max-height: 500px;
    padding: 15px;
}

.accordion-content p {
    font-size: 13px;
    line-height: 1.6;
    color: #555;
}

/* Drug grid - responsive card layout */
.drug-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

/* Drug cards - interactive elements with visual feedback */
.drug-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.drug-card:hover {
    transform: translateY(-5px) scale(1.02);
    border-color: #667eea;
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.3);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.drug-card:active {
    transform: translateY(-3px) scale(1);
}

.drug-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.drug-card h3 {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 5px;
    line-height: 1.2;
}

.drug-effect {
    font-size: 11px;
    color: #666;
    line-height: 1.3;
}

.drug-card:hover .drug-effect {
    color: rgba(255, 255, 255, 0.9);
}

/* Modal for drug details - Mayer's modality principle */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 25px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s ease;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

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

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #f44336;
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    line-height: 1;
}

.modal-close:hover {
    background: #d32f2f;
    transform: rotate(90deg);
}

#modal-title {
    font-size: 20px;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 10px;
    padding-right: 30px;
}

.modal-effect {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
    padding: 10px;
    background: #f0f0f0;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

#modal-side-effects {
    margin-top: 15px;
}

#modal-side-effects h3 {
    font-size: 16px;
    font-weight: 700;
    color: #f44336;
    margin-bottom: 10px;
}

#modal-side-effects ul {
    list-style: none;
    padding: 0;
}

#modal-side-effects li {
    padding: 8px 12px;
    margin-bottom: 6px;
    background: #fff3f3;
    border-left: 3px solid #f44336;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.4;
}

#modal-side-effects .gender-specific {
    margin-top: 15px;
    padding: 12px;
    background: #fff9e6;
    border-radius: 8px;
    border: 1px solid #ffc107;
}

#modal-side-effects .gender-specific h4 {
    font-size: 14px;
    font-weight: 700;
    color: #f57c00;
    margin-bottom: 8px;
}

/* Scrollbar styling */
#main-container::-webkit-scrollbar,
.modal-content::-webkit-scrollbar {
    width: 8px;
}

#main-container::-webkit-scrollbar-track,
.modal-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

#main-container::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.5);
    border-radius: 10px;
}

#main-container::-webkit-scrollbar-thumb:hover,
.modal-content::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.8);
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .drug-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .section-title {
        font-size: 16px;
    }
    
    .accordion-button {
        font-size: 13px;
    }
}

/* Accessibility - Focus states */
.accordion-button:focus,
.drug-card:focus,
.modal-close:focus {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    #main-container {
        height: auto;
        background: white;
    }
    
    .modal {
        display: none !important;
    }
}
