/**
 * Interactive Anatomy - Frontend Styles
 */

/* CSS Variables */
.ia-anatomy-wrapper {
    --ia-primary: #e74c3c;
    --ia-secondary: #3498db;
    --ia-modal-bg: #ffffff;
    --ia-modal-text: #333333;
    --ia-hover-opacity: 0.7;
    --ia-animation-speed: 300ms;
    --ia-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --ia-shadow-md: 0 4px 20px rgba(0, 0, 0, 0.12);
    --ia-shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.2);
    --ia-border-radius: 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
}

/* Container */
.ia-anatomy-wrapper { position: relative; width: 100%; padding: 20px; box-sizing: border-box; }
.ia-align-center { display: flex; justify-content: center; }
.ia-align-left { display: flex; justify-content: flex-start; }
.ia-align-right { display: flex; justify-content: flex-end; }
.ia-anatomy-container { position: relative; display: inline-block; }

/* Anatomy Image */
.ia-anatomy-image {
    position: relative;
    display: block;
    line-height: 0;
    border-radius: var(--ia-border-radius);
    overflow: hidden;
    box-shadow: var(--ia-shadow-sm);
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}
.ia-base-image { width: 100%; height: auto; display: block; transition: transform var(--ia-animation-speed) ease; }

/* Hotspots */
.ia-hotspots { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
.ia-hotspot {
    position: absolute;
    cursor: pointer;
    pointer-events: auto;
    border-radius: 8px;
    transition: all var(--ia-animation-speed) cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    outline: none;
}
.ia-hotspot::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--organ-color, var(--ia-primary));
    border-radius: inherit;
    opacity: 0;
    transition: opacity var(--ia-animation-speed) ease;
}
.ia-hotspot:hover::before, .ia-hotspot:focus::before { opacity: var(--ia-hover-opacity); }
.ia-hotspot:hover, .ia-hotspot:focus { transform: scale(1.02); z-index: 20; }

/* Pulse */
.ia-hotspot-pulse {
    position: absolute;
    top: 50%; left: 50%;
    width: 12px; height: 12px;
    margin: -6px 0 0 -6px;
    background: var(--organ-color, var(--ia-primary));
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
    animation: ia-pulse 2s ease-out infinite;
}
.ia-hotspot:hover .ia-hotspot-pulse { animation-play-state: paused; opacity: 0; }
@keyframes ia-pulse {
    0% { opacity: 0.8; transform: scale(0.5); box-shadow: 0 0 0 0 var(--organ-color, var(--ia-primary)); }
    50% { opacity: 0.4; }
    100% { opacity: 0; transform: scale(2); box-shadow: 0 0 0 20px transparent; }
}

/* Labels */
.ia-hotspot-label {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 6px;
    opacity: 0;
    visibility: hidden;
    transition: all var(--ia-animation-speed) ease;
    pointer-events: none;
    z-index: 100;
}
.ia-hotspot-label::after {
    content: '';
    position: absolute;
    top: 100%; left: 50%;
    margin-left: -6px;
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.85);
}
.ia-hotspot:hover .ia-hotspot-label, .ia-hotspot:focus .ia-hotspot-label {
    opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0);
}
.ia-hotspot-label.ia-label-visible { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }

/* Modal */
.ia-modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--ia-animation-speed) ease, visibility var(--ia-animation-speed) ease;
}
.ia-modal[aria-hidden="false"] { opacity: 1; visibility: visible; }
.ia-modal-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.ia-modal-container {
    position: relative;
    width: 100%;
    max-height: 90vh;
    background: var(--ia-modal-bg);
    border-radius: var(--ia-border-radius);
    box-shadow: var(--ia-shadow-lg);
    overflow: hidden;
    transform: scale(0.95) translateY(20px);
    transition: transform var(--ia-animation-speed) cubic-bezier(0.4, 0, 0.2, 1);
}
.ia-modal[aria-hidden="false"] .ia-modal-container { transform: scale(1) translateY(0); }

/* Close Button */
.ia-modal-close {
    position: absolute;
    top: 16px; right: 16px;
    width: 36px; height: 36px;
    padding: 0;
    border: none;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ia-modal-text);
    transition: all 0.2s ease;
    z-index: 10;
}
.ia-modal-close:hover { background: rgba(0, 0, 0, 0.15); transform: rotate(90deg); }
.ia-modal-close:focus { outline: 2px solid var(--ia-primary); outline-offset: 2px; }

/* Modal Content */
.ia-modal-content { max-height: calc(90vh - 40px); overflow-y: auto; overscroll-behavior: contain; }
.ia-modal-content::-webkit-scrollbar { width: 8px; }
.ia-modal-content::-webkit-scrollbar-track { background: #f1f1f1; }
.ia-modal-content::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 4px; }

/* Loading */
.ia-modal-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; color: #666; }
.ia-modal-loading.hidden { display: none; }
.ia-spinner { width: 40px; height: 40px; border: 3px solid #eee; border-top-color: var(--ia-primary); border-radius: 50%; animation: ia-spin 0.8s linear infinite; margin-bottom: 16px; }
@keyframes ia-spin { to { transform: rotate(360deg); } }

.ia-modal-body { display: none; }
.ia-modal-body.loaded { display: block; }

/* Organ Content */
.ia-organ-content { color: var(--ia-modal-text); }
.ia-organ-header { padding: 32px 32px 24px; background: linear-gradient(135deg, var(--accent-color, var(--ia-primary)) 0%, color-mix(in srgb, var(--accent-color, var(--ia-primary)) 80%, black) 100%); color: #fff; }
.ia-organ-title { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.ia-organ-image { padding: 0; line-height: 0; }
.ia-organ-image img { width: 100%; height: auto; max-height: 300px; object-fit: cover; }
.ia-organ-description { padding: 24px 32px; font-size: 16px; line-height: 1.7; }
.ia-organ-description p:first-child { margin-top: 0; }
.ia-organ-description p:last-child { margin-bottom: 0; }
.ia-organ-extra { padding: 0 32px 24px; font-size: 15px; color: #555; border-top: 1px solid #eee; margin-top: -8px; padding-top: 24px; }
.ia-organ-action { padding: 16px 32px 32px; }

/* Button */
.ia-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    background: var(--ia-primary);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.ia-button:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); color: #fff; text-decoration: none; }

/* Tooltip */
.ia-tooltip { position: fixed; padding: 8px 14px; background: rgba(0, 0, 0, 0.9); color: #fff; font-size: 13px; border-radius: 6px; pointer-events: none; z-index: 1000000; opacity: 0; visibility: hidden; transition: opacity 0.2s ease; }
.ia-tooltip[aria-hidden="false"] { opacity: 1; visibility: visible; }

/* Responsive */
@media (max-width: 768px) {
    .ia-anatomy-wrapper { padding: 10px; }
    .ia-modal { padding: 10px; }
    .ia-organ-header { padding: 24px 20px 20px; }
    .ia-organ-title { font-size: 22px; }
    .ia-organ-description, .ia-organ-extra, .ia-organ-action { padding-left: 20px; padding-right: 20px; }
}
