/* Curiosity Kairos Moodle Runtime 0.3.0 */

:root {
    --ck-ink: #011622;
    --ck-deep: #011E32;
    --ck-blue: #012B46;
    --ck-cyan: #00D4FF;
    --ck-cyan2: #00B4D8;
    --ck-mint: #2EC4B6;
    --ck-orange: #FF9F00;
    --ck-white: #FFFFFF;
    --ck-danger: #EF4444;
    --ck-success: #10B981;
}

body.ck-mcaa-focus-active .navbar,
body.ck-mcaa-focus-active .fixed-top.navbar,
body.ck-mcaa-focus-active .navbar.bg-white,
body.ck-mcaa-focus-active .bg-white.navbar {
    background: #111622 !important;
    border-bottom: 3px solid var(--ck-orange) !important;
    color: #fff !important;
}

body.ck-mcaa-focus-active .navbar .nav-link,
body.ck-mcaa-focus-active .navbar a,
body.ck-mcaa-focus-active .navbar label,
body.ck-mcaa-focus-active .navbar .custom-control-label {
    color: #fff !important;
}

body.ck-mcaa-focus-active .navbar .dropdown-menu {
    background: #111622 !important;
    border: 1px solid var(--ck-orange) !important;
}

body.ck-mcaa-focus-active .navbar .dropdown-menu a:hover {
    background: var(--ck-blue) !important;
    color: var(--ck-orange) !important;
}

@keyframes ck-electric-glow {
    0%, 100% {
        border-color: var(--ck-cyan);
        box-shadow: 0 0 8px rgba(0, 212, 255, .5), 0 0 15px rgba(0, 212, 255, .2);
    }
    50% {
        border-color: #9d4edd;
        box-shadow: 0 0 16px rgba(157, 78, 221, .8), 0 0 25px rgba(157, 78, 221, .4);
    }
}

.ck-kairos-widget {
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 9999;
    font-family: Arial, sans-serif;
}

.ck-unified-widget {
    display: flex;
    align-items: center;
    gap: 14px;
    width: max-content;
    padding: 6px 10px 6px 22px;
    border: 2px solid var(--ck-cyan);
    border-radius: 50px;
    background: rgba(1, 43, 70, .38);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: ck-electric-glow 4s infinite ease-in-out;
    box-shadow: 0 8px 24px rgba(1, 22, 34, .16);
    transition: border-color .25s, background .25s, box-shadow .25s;
    touch-action: none;
}

body.ck-mcaa-focus-active .ck-unified-widget {
    animation: none;
    border-color: var(--ck-orange);
    background: rgba(17, 22, 34, .58);
    box-shadow: 0 0 12px rgba(255, 159, 0, .4);
}

.ck-mcaa-btn,
.ck-guini-btn,
.ck-icon-btn,
.ck-send-btn,
.ck-guini-actions button {
    font: inherit;
}

.ck-mcaa-btn {
    border: 0;
    padding: 8px 0;
    background: transparent;
    color: #fff;
    font-weight: 800;
    font-size: .88rem;
    cursor: pointer;
    white-space: nowrap;
    letter-spacing: .2px;
}

.ck-guini-btn {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    transition: transform .2s, opacity .2s;
}

.ck-guini-btn:hover { transform: scale(1.08); }

.ck-guini-btn img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--ck-cyan);
    background: rgba(255,255,255,.25);
}

body.ck-mcaa-focus-active .ck-guini-btn img { border-color: var(--ck-orange); }

.ck-guini-panel {
    position: absolute;
    left: 0;
    bottom: calc(100% + 14px);
    width: min(600px, calc(100vw - 40px));
    height: min(70vh, 720px);
    min-height: 420px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(0, 212, 255, .38);
    border-radius: 16px;
    background: rgba(1, 43, 70, .72);
    box-shadow: 0 18px 52px rgba(0,0,0,.35);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: #fff;
}

.ck-guini-panel[hidden] { display: none !important; }

.ck-kairos-widget.ck-opens-down .ck-guini-panel {
    top: calc(100% + 14px);
    bottom: auto;
}

.ck-kairos-widget.ck-opens-left .ck-guini-panel {
    left: auto;
    right: 0;
}

.ck-guini-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(0, 212, 255, .16);
    background: rgba(1, 30, 50, .76);
    font-weight: 800;
}

.ck-guini-actions { display: flex; align-items: center; gap: 10px; }

.ck-guini-actions button {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: rgba(255,255,255,.08);
    color: #fff;
    cursor: pointer;
}

.ck-guini-actions button:hover { background: rgba(255,255,255,.16); }

.ck-guini-modebar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(0, 212, 255, .12);
    background: rgba(1, 43, 70, .58);
}

.ck-guini-modebar label {
    flex: 0 0 auto;
    margin: 0;
    color: var(--ck-orange);
    font-size: .86rem;
    font-weight: 800;
}

.ck-guini-modebar select {
    min-width: 0;
    flex: 1;
    padding: 7px 9px;
    border: 1px solid rgba(0, 212, 255, .3);
    border-radius: 8px;
    background: #111622;
    color: #fff;
    outline: none;
}

.ck-guini-history {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
}

.ck-guini-history::-webkit-scrollbar { width: 6px; }
.ck-guini-history::-webkit-scrollbar-thumb { background: rgba(255,255,255,.22); border-radius: 999px; }

.ck-msg-user,
.ck-msg-guini {
    display: flex;
    width: 100%;
}

.ck-msg-user { justify-content: flex-end; }
.ck-msg-guini { justify-content: flex-start; align-items: flex-start; gap: 8px; }

.ck-msg-avatar {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--ck-cyan);
    background: #fff;
}

.ck-bubble-user,
.ck-bubble-guini {
    max-width: 90%;
    padding: 10px 14px;
    font-size: .91rem;
    line-height: 1.48;
    word-break: break-word;
    white-space: pre-wrap;
}

.ck-bubble-user {
    border-radius: 16px 16px 2px 16px;
    background: rgba(0, 132, 255, .82);
    color: #fff;
}

.ck-bubble-guini {
    border-left: 3px solid var(--ck-cyan);
    border-radius: 16px 16px 16px 2px;
    background: rgba(33, 38, 45, .88);
    color: #f0f6fc;
}

.ck-choice-list { display: grid; gap: 8px; margin-top: 10px; }
.ck-choice {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(0, 212, 255, .48);
    border-radius: 9px;
    background: rgba(0, 212, 255, .13);
    color: #fff;
    text-align: left;
    cursor: pointer;
}
.ck-choice:hover { background: rgba(0, 212, 255, .28); }

.ck-guini-file-name {
    flex: 0 0 auto;
    padding: 6px 12px;
    border-top: 1px dashed rgba(0, 212, 255, .2);
    background: rgba(1, 43, 70, .72);
    color: var(--ck-orange);
    font-size: .82rem;
    font-weight: 700;
}

.ck-guini-inputbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px;
    border-top: 1px solid rgba(0, 212, 255, .16);
    background: rgba(1, 30, 50, .76);
}

.ck-guini-inputbar textarea {
    flex: 1;
    min-width: 0;
    max-height: 110px;
    resize: none;
    padding: 9px 13px;
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 20px;
    background: rgba(13, 17, 23, .82);
    color: #fff;
    outline: none;
}

.ck-guini-inputbar textarea:focus { border-color: var(--ck-cyan); }

.ck-icon-btn,
.ck-send-btn {
    flex: 0 0 auto;
    height: 38px;
    border: 0;
    border-radius: 19px;
    cursor: pointer;
    font-weight: 800;
}

.ck-icon-btn {
    min-width: 38px;
    padding: 0 10px;
    background: var(--ck-cyan);
    color: var(--ck-ink);
}

.ck-send-btn {
    padding: 0 16px;
    background: var(--ck-cyan);
    color: var(--ck-blue);
}
.ck-send-btn:hover { background: var(--ck-cyan2); }
.ck-send-btn:disabled { opacity: .5; cursor: wait; }

.ck-mcaa-menu {
    position: absolute;
    left: 0;
    bottom: calc(100% + 12px);
    width: 300px;
    padding: 14px;
    border: 1px solid rgba(0, 212, 255, .34);
    border-radius: 14px;
    background: rgba(1, 30, 50, .78);
    color: #fff;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 16px 42px rgba(0,0,0,.32);
}
.ck-mcaa-menu[hidden] { display: none !important; }
.ck-mcaa-menu-title { margin-bottom: 10px; font-weight: 800; }
.ck-mcaa-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ck-mcaa-presets button,
.ck-mcaa-custom button {
    border: 1px solid rgba(0,212,255,.35);
    border-radius: 9px;
    padding: 9px 10px;
    background: rgba(0,212,255,.12);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
}
.ck-mcaa-presets button:hover,
.ck-mcaa-custom button:hover { background: rgba(0,212,255,.26); }
.ck-mcaa-custom { margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
.ck-mcaa-custom[hidden] { display: none !important; }
.ck-mcaa-custom label { margin: 0; color: #cbd5e1; font-size: .78rem; }
.ck-mcaa-custom label span { display: block; margin-bottom: 4px; }
.ck-mcaa-custom input { width: 100%; padding: 7px; border: 1px solid rgba(255,255,255,.18); border-radius: 7px; background: #111622; color: #fff; }

.ck-mcaa-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(17, 22, 34, .48);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}
.ck-mcaa-overlay[hidden] { display: none !important; }

.ck-mcaa-overlay-card {
    width: min(620px, 100%);
    padding: 34px;
    border: 3px solid var(--ck-blue);
    border-radius: 20px;
    background: rgba(210, 235, 217, .82);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    box-shadow: 0 20px 60px rgba(0,0,0,.45);
    text-align: center;
    color: var(--ck-ink);
}
.ck-mcaa-overlay-avatar { width: 92px; height: 92px; object-fit: cover; border-radius: 50%; margin-bottom: 10px; }
.ck-mcaa-overlay-card h2 { margin: 0 0 8px; color: var(--ck-blue); font-weight: 900; }
.ck-mcaa-overlay-timer { margin: 4px 0 12px; color: var(--ck-orange); font-size: clamp(2.4rem, 8vw, 4rem); font-weight: 900; }
.ck-mcaa-overlay-card p { margin: 0 auto 22px; max-width: 500px; font-size: 1.05rem; line-height: 1.5; }
.ck-mcaa-overlay-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.ck-mcaa-overlay-actions button {
    min-height: 42px;
    padding: 10px 18px;
    border: 0;
    border-radius: 999px;
    background: var(--ck-blue);
    color: #fff;
    cursor: pointer;
    font-weight: 800;
}
.ck-mcaa-overlay-actions button.ck-secondary { background: rgba(1,43,70,.12); color: var(--ck-blue); border: 1px solid rgba(1,43,70,.28); }
.ck-mcaa-overlay-actions button.ck-warn { background: var(--ck-orange); color: var(--ck-ink); }

.ck-kairos-toast {
    position: absolute;
    left: 0;
    bottom: calc(100% + 12px);
    width: min(360px, calc(100vw - 40px));
    padding: 12px 14px;
    border: 1px solid rgba(255,159,0,.45);
    border-radius: 12px;
    background: rgba(17,22,34,.80);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    color: #fff;
    box-shadow: 0 12px 32px rgba(0,0,0,.28);
    font-size: .9rem;
    line-height: 1.45;
}
.ck-kairos-toast[hidden] { display: none !important; }

body.ck-kairos-dragging,
body.ck-kairos-dragging * { cursor: grabbing !important; }

@media (max-width: 700px) {
    .ck-kairos-widget { left: 10px; bottom: 12px; }
    .ck-unified-widget { padding-left: 16px; gap: 10px; }
    .ck-guini-panel { width: calc(100vw - 20px); height: min(74vh, 680px); }
    .ck-mcaa-menu { width: min(300px, calc(100vw - 20px)); }
    .ck-guini-modebar { align-items: stretch; flex-direction: column; gap: 5px; }
    .ck-guini-inputbar { gap: 6px; }
    .ck-send-btn { padding: 0 12px; }
}

/* Runtime bootstrap diagnostics 0.3.1 */
.ck-kairos-widget.ck-runtime-booting .ck-unified-widget {
    opacity: .92;
}

.ck-kairos-widget.ck-runtime-error .ck-unified-widget {
    border-color: #EF4444;
    animation: none;
}

.ck-kairos-widget.ck-runtime-error .ck-mcaa-btn {
    color: #FFFFFF;
}

.ck-kairos-widget.ck-runtime-error .ck-guini-btn {
    opacity: .45;
}

.ck-mcaa-overlay-timer[hidden] { display: none !important; }


/* ============================================================
   Curiosity Kairos 0.4.5 — posición y arrastre
   ============================================================ */

/* Toda la cápsula puede tomarse para moverla.
   Los botones conservan cursor de acción y siguen recibiendo click. */
.ck-unified-widget {
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

body.ck-kairos-dragging,
body.ck-kairos-dragging * {
    cursor: grabbing !important;
}

.ck-mcaa-btn,
.ck-guini-btn {
    cursor: pointer;
}

/* Igual que el panel de Guiñi, el menú MCAA cambia de dirección
   según la posición del widget para no quedar fuera de pantalla. */
.ck-kairos-widget.ck-opens-down .ck-mcaa-menu {
    top: calc(100% + 12px);
    bottom: auto;
}

.ck-kairos-widget.ck-opens-left .ck-mcaa-menu {
    left: auto;
    right: 0;
}
