/* ==========================================================================
   DIALOG SCREEN — Chat-style lesson UI
   Dependencies: lesson/layout.css (shared l_header, l_footer, feedback_overlay)
   ========================================================================== */

/* --- 1. LAYOUT --- */

.dialog_layout {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    background-color: var(--c-bg-body);
    height: 100vh;
    height: 100dvh;
}

/* Width limiter */
.d_content_limit {
    width: 100%;
    max-width: 600px;
    height: 100%;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    position: relative;
    border-left: 1px solid var(--c-border);
    border-right: 1px solid var(--c-border);
}

/* Chat scroll area */
.d_main {
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
    overflow-y: auto;
    padding: 90px 15px 0 15px;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    scroll-behavior: smooth;
}

/* Spacing between chat messages (replaces gap) */
.d_main > * {
    margin-bottom: 20px;
}
.d_main > *:last-child {
    margin-bottom: 0;
}

/* Space at end so footer doesn't cover content */
.d_main::after {
    content: "";
    display: block;
    height: 160px;
    -ms-flex-negative: 0;
    flex-shrink: 0;
    width: 100%;
}

/* Scrollbar */
.d_main::-webkit-scrollbar { width: 4px; }
.d_main::-webkit-scrollbar-thumb { background: #333; border-radius: 10px; }


/* --- 2. MESSAGE ROWS (Left / Right / System) --- */

.d_step_row {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: end;
    -ms-flex-align: end;
    align-items: flex-end;
    max-width: 90%;
    -webkit-animation: dialogSlideIn 0.3s ease-out forwards;
    animation: dialogSlideIn 0.3s ease-out forwards;
}

/* Spacing between avatar and bubble (replaces gap) */
.d_step_row > * {
    margin-right: 10px;
}
.d_step_row > *:last-child {
    margin-right: 0;
}

/* Left side (default) */
.d_step_row.is_left {
    -ms-flex-item-align: start;
    align-self: flex-start;
}

/* Right side */
.d_step_row.is_right {
    -ms-flex-item-align: end;
    align-self: flex-end;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: reverse;
    -ms-flex-direction: row-reverse;
    flex-direction: row-reverse;
}

.d_step_row.is_right > * {
    margin-right: 0;
    margin-left: 10px;
}
.d_step_row.is_right > *:last-child {
    margin-left: 0;
}

/* System / Title */
.d_step_row.is_system {
    -ms-flex-item-align: center;
    align-self: center;
    max-width: 100%;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    text-align: center;
}


/* --- 3. AVATARS & NAMES --- */

.d_avatar_wrap {
    width: 44px;
    height: 44px;
    background: #1a1a1a;
    border: 2px solid var(--c-border);
    border-radius: 12px;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    -ms-flex-negative: 0;
    flex-shrink: 0;
    overflow: hidden;
}

.d_avatar_img {
    width: 32px;
    height: 32px;
    -o-object-fit: contain;
    object-fit: contain;
    border-radius: 10px;
}

.d_char_name {
    font-size: 11px;
    font-weight: 900;
    color: var(--c-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.is_right .d_char_name { text-align: right; }


/* --- 4. BUBBLES --- */

.d_bubble_container {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
}

.d_bubble_wrap {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
}

/* Spacing inside bubble row (replaces gap) */
.d_bubble_wrap > * {
    margin-right: 10px;
}
.d_bubble_wrap > *:last-child {
    margin-right: 0;
}

.d_bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 17px;
    line-height: 1.5;
    color: white;
    position: relative;
}

/* Left bubble */
.is_left .d_bubble {
    background: var(--c-bg-card);
    border: 2px solid var(--c-border);
    border-bottom-left-radius: 4px;
}

/* Right bubble */
.is_right .d_bubble {
    background: var(--c-accent-blue);
    color: white;
    border-bottom-right-radius: 4px;
}

/* System bubble */
.is_system .d_bubble {
    background: transparent;
    border: 1px dashed #444;
    color: var(--c-text-muted);
    font-style: italic;
    border-radius: 12px;
    font-size: 15px;
}

/* Audio button near bubble */
.d_bubble_audio {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #1cb0f6;
    cursor: pointer;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    -ms-flex-negative: 0;
    flex-shrink: 0;
    padding: 0;
    -webkit-transition: background 0.2s;
    transition: background 0.2s;
}

.d_bubble_audio:hover { background: rgba(255, 255, 255, 0.1); }
.d_bubble_audio svg { width: 18px; height: 18px; fill: currentColor; }

/* Right side: reverse bubble + audio order */
.is_right .d_bubble_wrap {
    -webkit-box-orient: horizontal;
    -webkit-box-direction: reverse;
    -ms-flex-direction: row-reverse;
    flex-direction: row-reverse;
}

.is_right .d_bubble_wrap > * {
    margin-right: 0;
    margin-left: 10px;
}


/* --- 5. SPECIAL STEPS (Images, Titles) --- */

.d_step_image_wrap {
    width: 100%;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    margin: 10px 0;
}

.d_step_img {
    width: 100%;
    max-width: 280px;
    height: auto;
    border-radius: 20px;
    -webkit-filter: drop-shadow(0 10px 20px rgba(0,0,0,0.2));
    filter: drop-shadow(0 10px 20px rgba(0,0,0,0.2));
}

.d_step_title {
    text-align: center;
    font-size: 22px;
    font-weight: 900;
    color: #fff;
    margin: 10px 0;
    padding: 10px;
    letter-spacing: -0.5px;
    text-transform: uppercase;
}


/* --- 6. TASKS (Quiz cards inside dialog) --- */

.d_task_card {
    background: #1a1b1c;
    border: 2px solid #333;
    border-radius: 24px;
    padding: 24px;
    margin: 10px 0;
    -webkit-box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    width: 100%;
    -webkit-animation: dialogFadeIn 0.5s ease-in;
    animation: dialogFadeIn 0.5s ease-in;
}

.d_task_question {
    font-size: 19px;
    font-weight: 800;
    color: #fff;
    text-align: center;
    margin-bottom: 20px;
}

.d_task_options {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
}

/* Spacing for options (replaces gap) */
.d_task_options > * {
    margin-bottom: 10px;
}
.d_task_options > *:last-child {
    margin-bottom: 0;
}


/* --- 7. ANIMATIONS --- */

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

@-webkit-keyframes dialogFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes dialogFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@-webkit-keyframes dialogShake {
    0%, 100% { -webkit-transform: translateX(0); }
    25% { -webkit-transform: translateX(-6px); }
    75% { -webkit-transform: translateX(6px); }
}
@keyframes dialogShake {
    0%, 100% { -webkit-transform: translateX(0); transform: translateX(0); }
    25% { -webkit-transform: translateX(-6px); transform: translateX(-6px); }
    75% { -webkit-transform: translateX(6px); transform: translateX(6px); }
}

.shake {
    -webkit-animation: dialogShake 0.4s ease-in-out;
    animation: dialogShake 0.4s ease-in-out;
    border-color: var(--c-accent-red) !important;
}
