/* --- START: Complete Storybook Component Styles --- */

/* Basic Body Styles for the Test Page */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f2f5;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

/* Main Component Container */
#storybook-root {
    width: 100%;
    max-width: 1140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    box-sizing: border-box;
}

/* Styles for the two main content cards */
#storybook-root .storybook-wrapper,
#storybook-root #ai-section-wrapper {
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
    width: 100%;
    padding: 32px;
    text-align: center;
    border: 1px solid #ddd;
    box-sizing: border-box;
}

/* Storybook Content */
#storybook-root .storybook-title {
    font-size: 32px;
    font-weight: 700;
    color: #1c1e21;
    margin-top: 0;
    margin-bottom: 24px;
}

#storybook-root .storybook-image {
    width: 100%;
    aspect-ratio: 16 / 9; 
    background-color: #e9ecef;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 24px;
    overflow: hidden;
}

#storybook-root .storybook-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#storybook-root .storybook-text {
    min-height: 120px;
}

#storybook-root .idiom-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 12px;
}

#storybook-root .storybook-idiom {
    font-size: 28px;
    font-weight: 600;
    color: #0056b3;
    margin: 0;
}

#storybook-root .play-audio-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    color: #555;
    transition: transform 0.2s;
}

#storybook-root .storybook-explanation {
    font-size: 18px;
    color: #333;
    line-height: 1.6;
    margin: 0;
}

/* Recording Controls */
#storybook-root .recording-controls {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

#storybook-root .record-btn,
#storybook-root .stop-btn {
    border: none;
    color: white;
    padding: 10px 18px;
    font-size: 16px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: 500;
}

#storybook-root .record-btn { background-color: #007bff; }
#storybook-root .stop-btn { background-color: #dc3545; }

#storybook-root #playbackAudio {
    width: 100%;
    max-width: 400px;
}

/* Navigation Controls */
#storybook-root .storybook-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
}

#storybook-root .storybook-nav button {
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

#storybook-root .storybook-nav button:disabled {
    background-color: #cdd2d8;
    cursor: not-allowed;
}

#storybook-root .page-jump {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #555;
    font-size: 16px;
}

#storybook-root .page-input {
    width: 60px;
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #ccc;
    text-align: center;
    font-size: 16px;
}

#storybook-root .storybook-end {
    margin-top: 24px;
    padding: 14px;
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-radius: 6px;
    font-weight: 500;
    font-size: 16px;
}

/* AI Explanation Section */
#storybook-root #ai-section-wrapper {
    margin-top: 0; 
}

#storybook-root #aiExplainBtn {
    padding: 18px 36px;
    font-size: 20px;
    gap: 12px;
    background-image: linear-gradient(45deg, #5f72be 0%, #9d50bb 100%);
    color: white;
    border: none;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    box-shadow: 0 6px #7c3d9d;
    transition: all 0.15s ease-out;
}

#storybook-root #aiExplainBtn:hover {
    transform: translateY(-3px);
    box-shadow: 0 9px #7c3d9d;
}

#storybook-root #aiExplainBtn:active {
    transform: translateY(2px);
    box-shadow: 0 4px #7c3d9d;
}

#storybook-root #aiExplainBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 6px #7c3d9d;
}

#storybook-root #ai-explanation-output {
    display: none;
    text-align: left;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 25px;
    margin-top: 25px;
    line-height: 1.7;
    font-size: 17px;
    color: #343a40;
}

/* --- FORCEFUL Responsive Styles for Mobile Devices --- */
@media (max-width: 768px) {
    #storybook-root {
        gap: 20px;
    }

    #storybook-root .storybook-wrapper,
    #storybook-root #ai-section-wrapper {
        padding: 20px; 
    }

    #storybook-root .storybook-title {
        font-size: 22px;
    }

    #storybook-root .storybook-idiom {
        font-size: 20px;
    }

    #storybook-root .storybook-explanation {
        font-size: 15px;
    }
    
    #storybook-root .storybook-nav {
        flex-direction: column !important;
        gap: 20px;
    }
    
    #storybook-root .recording-controls {
        flex-direction: column !important;
        gap: 15px;
    }

    #storybook-root #playbackAudio {
        width: 100%;
        max-width: none;
    }

    #storybook-root .page-jump {
        order: -1; 
    }

    #storybook-root #aiExplainBtn {
        padding: 16px 30px;
        font-size: 16px;
    }

    #storybook-root #ai-explanation-output {
        padding: 20px;
        font-size: 16px;
    }
}
/* --- END: Storybook Component Styles --- */