html,
body {
    margin: 0;
    min-height: 100%;
    font-family: ui-sans-serif, system-ui, sans-serif;
}

.hidden { display: none !important; }

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: url("diakszobahatter.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -1;
    filter: blur(4px) brightness(1.1) saturate(1.0);
    transform: scale(1.05);
    transition: filter 0.3s ease;
}

body.logged-in::before {
    filter: blur(6px) brightness(0.45) saturate(1.05);
}

#login-container {
    background: rgba(76, 105, 233, 0.16) !important;
    backdrop-filter: blur(18px) saturate(170%);
    -webkit-backdrop-filter: blur(18px) saturate(170%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
    border-radius: 1.5rem;
}

/* ── Sidebar layout ── */
#main-content {
    display: flex;
    min-height: 100vh;
}

.diak-sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 220px;
    min-height: 100vh;
    background: rgba(8, 22, 48, 0.88);
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    will-change: width;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
}
.diak-sidebar.collapsed { width: 68px; }
.diak-sidebar.collapsed .diak-nav-text { display: none; }
.diak-sidebar.collapsed .diak-sidebar-header { justify-content: center; padding: 1.25rem 0; min-height: 70px; }
.diak-sidebar.collapsed .diak-nav-item a { padding: 0.75rem 5px; display: flex; justify-content: center; align-items: center; }
.diak-sidebar.collapsed .diak-nav-item i { width: 1.25rem; font-size: 1.1rem; text-align: center; margin: 0 auto; }

.diak-sidebar-header {
    display: flex;
    align-items: center;
    padding: 1.25rem 1rem 1.25rem 4.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    min-height: 68px;
}

.diak-toggle-btn {
    position: fixed;
    top: 0.85rem;
    left: 0.85rem;
    z-index: 200;
    background: rgba(10, 30, 60, 0.65);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 0.6rem;
    color: rgba(255, 255, 255, 0.85);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.6rem 0.8rem;
    transition: all 0.2s;
    line-height: 1;
}
.diak-toggle-btn:hover { background: rgba(255, 255, 255, 0.18); color: #fff; }

.diak-nav-item { margin: 0; padding: 0; }
.diak-nav-item a {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.65rem 0.85rem;
    border-radius: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 700;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
    overflow: hidden;
}
.diak-nav-item a:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.diak-nav-item.active a { background: rgba(22, 163, 74, 0.35); color: #fff; border: 1px solid rgba(22, 163, 74, 0.5); }
.diak-nav-item i { font-size: 1.05rem; width: 1.2rem; text-align: center; flex-shrink: 0; }
.diak-nav-text { white-space: nowrap; overflow: hidden; flex-shrink: 0; }

.diak-logout-item a { color: rgba(252, 165, 165, 0.9); }
.diak-logout-item a:hover { background: rgba(239, 68, 68, 0.18); color: #fca5a5; }

.diak-content {
    flex: 1;
    margin-left: 220px;
    padding: 1.75rem;
    overflow-y: auto;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
#main-content.sidebar-collapsed .diak-content { margin-left: 68px; }

.diak-content-section { max-width: 860px; margin: 0 auto; }

.diak-section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #e0f2fe;
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
    padding-bottom: 0.6rem;
    margin: 0 0 1.25rem 0;
}

.diak-modal-card {
    background: rgba(10, 30, 60, 0.82);
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 1.25rem;
    padding: 1.5rem;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

#login-form input,
#login-form input:hover,
#login-form input:focus,
#login-form input:active,
#login-form input:not(:placeholder-shown),
#login-form input:-webkit-autofill,
#login-form input:-webkit-autofill:hover,
#login-form input:-webkit-autofill:active,
#login-form input:-webkit-autofill:focus,
#login-form input:autofill {
    background-color: transparent !important;
    background-image: none !important;
    box-shadow: inset 0 0 0 1000px transparent !important;
    -webkit-box-shadow: inset 0 0 0 1000px transparent !important;
    appearance: none;
    -webkit-appearance: none;
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    caret-color: #ffffff;
    opacity: 1;
    transition: background-color 9999s ease-out 0s, color 0s ease-out 0s;
}

#login-form input::selection {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

#login-form input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

#main-content {
    font-family: ui-sans-serif, system-ui;
}

#main-content button {
    min-height: 2.75rem;
}

#quiz-list > p,
#quiz-answer-list > p {
    color: rgba(224, 242, 254, 0.85);
}

.diak-quiz-card {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.7);
    color: #1e293b;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
}

#main-content .diak-quiz-card,
#main-content .diak-quiz-card span {
    color: #0f172a !important;
}

.diak-quiz-card button,
.diak-primary-btn {
    background: rgba(22, 163, 74, 0.96);
    color: #ffffff;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.2);
}

.diak-quiz-card button:hover,
.diak-primary-btn:hover {
    background: rgba(21, 128, 61, 0.98);
}

.diak-answer-option {
    background: rgba(255, 255, 255, 0.94);
    border-color: rgba(203, 213, 225, 0.95);
    color: #0f172a;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

#main-content .diak-answer-option,
#main-content #quiz-answer-list label {
    color: #0f172a;
    font-weight: 600;
}

#main-content #quiz-answer-list input {
    accent-color: #2563eb;
}

#main-content .diak-review-correct {
    background: rgb(176, 255, 209);
    border: 5px solid #00752b;
    color: #052e16 !important;
}

#main-content .diak-review-skipped {
    background: rgb(146, 228, 248);
    border: 5px solid #1d4ed8;
    color: #172554 !important;
    
}

#main-content .diak-review-wrong {
    background: rgb(255, 179, 179);
    border: 5px solid #7f1d1d;
    color: #450a0a !important;
    
}

#main-content .diak-review-neutral {
    background: rgba(255, 255, 255, 0.88);
    border: 2px solid rgba(100, 116, 139, 0.85);
    color: #1e293b !important;
}

#main-content .diak-review-correct span,
#main-content .diak-review-skipped span,
#main-content .diak-review-wrong span {
    display: inline-block;
    margin-bottom: 0.25rem;
    border-radius: 0.5rem;
    padding: 0.125rem 0.5rem;
    background: rgba(255, 255, 255, 0.62);
    color: inherit !important;
    font-weight: 800;
}

/* ── Chat layout ── */
.diak-chat-layout {
    display: grid;
    grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
    gap: 1rem;
    min-height: 520px;
}

.diak-chat-sidebar {
    background: rgba(15, 30, 60, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 1.25rem;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.diak-chat-sidebar-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    margin-bottom: 0.25rem;
}

.diak-chat-thread-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.65rem 0.8rem;
    border-radius: 0.75rem;
    border: 1px solid transparent;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    background: rgba(255, 255, 255, 0.04);
}
.diak-chat-thread-item:hover,
.diak-chat-thread-item.active {
    background: rgba(22, 163, 74, 0.25);
    border-color: rgba(22, 163, 74, 0.5);
    color: #fff;
}
.diak-chat-thread-item i { color: rgba(134, 239, 172, 0.9); width: 1.1rem; text-align: center; flex-shrink: 0; }

.diak-chat-window {
    background: rgba(15, 30, 60, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 1.25rem;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
}

.diak-chat-window-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding-bottom: 0.75rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
}
.diak-chat-window-header i { color: rgba(134, 239, 172, 0.9); }

.diak-chat-send-form {
    display: flex;
    gap: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    margin-top: 0.5rem;
    min-width: 0;
}

.diak-chat-send-form .diak-chat-input {
    flex: 1;
    min-width: 0;
}

.diak-chat-send-form button {
    flex-shrink: 0;
}

.diak-chat-input {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 0.75rem;
    padding: 0.6rem 0.9rem;
    color: #fff;
    font-size: 0.95rem;
    font-family: inherit;
    font-weight: 600;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.diak-chat-input::placeholder { color: rgba(255, 255, 255, 0.5); font-weight: 500; }
.diak-chat-input:focus { border-color: rgba(134, 239, 172, 0.6); box-shadow: 0 0 0 3px rgba(134, 239, 172, 0.12); }

.chat-messages {
    height: 24rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    border-radius: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.chat-bubble {
    max-width: 75%;
    padding: 0.55rem 0.85rem;
    border-radius: 0.9rem;
    background: rgba(255, 255, 255, 0.92);
    color: #0f172a;
    align-self: flex-start;
    word-wrap: break-word;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}

.chat-bubble.me {
    background: rgba(22, 163, 74, 0.95);
    color: #ffffff;
    align-self: flex-end;
}

.chat-bubble .chat-meta {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-bottom: 0.15rem;
    font-weight: 700;
}

#toast-container {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    pointer-events: auto;
    min-width: 280px;
}
.toast.show { transform: translateX(0); }
.toast.success { border-left: 4px solid #10b981; }
.toast.success i { color: #10b981; }
.toast.error { border-left: 4px solid #ef4444; }
.toast.error i { color: #ef4444; }
