/* ----------------- Base styling ----------------- */

body {
    --body-font: "Segoe UI Variable", "Segoe UI", sans-serif;
    font-family: var(--body-font);
    font-size: var(--type-ramp-base-font-size, 16px);
    line-height: var(--type-ramp-base-line-height, 1.5);
    margin: 0;
    background-color: var(--neutral-layer-1, #121212);
    color: var(--neutral-foreground-rest, #f0f0f0);
}

body {
    --neutral-foreground-rest: #ffffff !important;
    --neutral-fill-input-rest: #2f2f2f !important; /* темний фон */
    --neutral-fill-input-hover: #3a3a3a !important;
    --neutral-fill-input-focus: #444444 !important;
    --neutral-stroke-control-rest: #555 !important; /* рамка */
    --neutral-foreground-hint: #aaa !important; /* placeholder */
}

:root {
    --accent-foreground-rest: #64b5f6 !important; /* світло-блакитний */
    --accent-foreground-hover: #90caf9 !important; /* на hover */
    --accent-foreground-active: #42a5f5 !important;
}

.navmenu-icon {
    display: none;
}

.message.received h1,
.message.received h2,
.message.received h3 {
    margin: 0.5em 0;
    font-weight: bold;
}

.message.received p {
    margin: 0.3em 0;
    line-height: 1.6;
}

.message.received pre {
    background: #1e1e1e;
    padding: 10px;
    border-radius: 6px;
    overflow-x: auto;
    font-family: 'Consolas', monospace;
    font-size: 0.9em;
    color: #dcdcdc;
}

.message.received code {
    background-color: #2e2e2e;
    color: #ffd700;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.95em;
}

.message.received blockquote {
    border-left: 4px solid #aaa;
    padding-left: 12px;
    color: #aaa;
    font-style: italic;
    margin: 0.5em 0;
}

.text-field-white {
    --neutral-foreground-rest: white;
    --fill-color: #1e1e1e;
}

.custom-input {
    --neutral-foreground-rest: #ffffff;
    --neutral-fill-input-rest: #2a2a2a;
    --neutral-fill-input-hover: #333333;
    --neutral-fill-input-active: #2a2a2a;
}

html, body, #app {
    height: 100%;
    margin: 0;
    padding: 0;
    background-color: #181818;
    color: #fff;
}

body {
    overflow: auto;
}

.logout-form {
    display: flex;
    align-items: center;
    margin-left: 16px;
}

.message.system-intro {
    align-self: center;
    background: #1e1e1e;
    color: #cccccc;
    border-left: 4px solid #10a37f;
    padding: 20px;
    font-size: 14px;
    font-style: italic;
    max-width: 95%;
}

.logout-button {
    display: flex;
    align-items: center;
    padding: 6px 14px;
    background-color: transparent;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 6px;
    color: white;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.logout-button:hover {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.7);
}

.logout-icon {
    font-family: 'Material Icons';
    font-size: 20px;
    margin-right: 6px;
    margin-left: 10px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
}

.logout-text {
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.external-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: #aaa;
    margin: 1.5rem 0;
}

.external-divider span {
    white-space: nowrap;
}

.external-divider::before,
.external-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #444;
    margin: 0 0.75rem;
}
.external-divider::before { left: 0; }
.external-divider::after { right: 0; }

.login-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    -ms-transform: translate(-50%, -50%);
    -webkit-transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #181818; /* З темним фоном всередині */
}

.login-title {
    font-size: 1.75rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 1rem;
}

.oauth-button {
    display: flex;
    align-items: center;
    background: #fff;
    color: #000;
    border: none;
    font-size: 1rem;
    padding: 0.65rem 1.25rem;
    margin-bottom: 0.75rem;
    width: 100%;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}
.oauth-button img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    margin-right: 0.75rem;
}

.oauth-button img.oauth-icon {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    object-fit: contain;
}

.oauth-button.google {
    background-color: #4285F4;
}

.oauth-button.twitter {
    background-color: #1DA1F2;
}

.oauth-button:hover {
    background: #f0f0f0;
}

.oauth-logo {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--body-bg);
}
.login-card {
    background-color: #23272b;
    padding: 3rem 2.5rem;
    border-radius: 12px;
    max-width: 540px;
    width: 100%;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    color: #fff;
}

@media (max-width: 800px) {
    .mud-drawer.chat-drawer {
        width: 0px !important;
        min-width: 0px !important;
        overflow-x: hidden;
        transition: width 0.3s ease;
    }

    .mud-drawer.chat-drawer .mud-list-item {
        justify-content: flex-start;
        padding: 8px 6px;
    }

    .mud-drawer.chat-drawer .mud-list-item .mud-icon-root {
        font-size: 18px;
        margin-right: 4px;
    }

    .mud-drawer.chat-drawer .mud-list-item .mud-typography {
        font-size: 0.75rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100px;
    }

    .maincontent-dark {
        background-color:#181c20 !important;
        color:#fff !important;
        display:flex;
        flex:1 1 auto;
        min-height:0;
        padding:0 !important;
        box-sizing:border-box;
        margin-top:64px;
    }
    
    
    .chat-input {
        flex-direction: column;
        gap: 12px;
    }

    .chat-input input {
        width: 100%;
    }

    .chat-input .send-btn { width:48px !important; height:48px !important; flex-shrink:0; }

    .logout-form {
        margin-left: 0;
        margin-top: 10px;
    }

    .mud-appbar {
        flex-wrap: wrap;
        padding: 10px;
    }

    .mud-appbar .mud-spacer {
        display: none;
    }
}

/* --------- Active chat item highlighting --------- */
.drawer-listitem-dark.mud-selected,
.drawer-listitem-dark.mud-list-item-active {
    background-color: #10a37f !important;
    color: white !important;
    border-left: 4px solid #0d8a6b;
}

.drawer-listitem-dark.mud-selected .mud-icon-root,
.drawer-listitem-dark.mud-list-item-active .mud-icon-root {
    color: white !important;
}

/* Ensure chat content doesn’t disappear */
.maincontent-dark {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}


.chat-drawer {
    width: 10vw !important;
    min-width: 64px !important;
    max-width: 200px;
    transition: width 0.3s ease;
}



@media (max-width: 800px) {
    .chat-drawer {
        width: 10vw !important;
        min-width: 64px !important;
    }

    .chat-drawer .mud-list-item {
        justify-content: flex-start;
    }

    .chat-drawer .mud-list-item .mud-icon-root {
        margin-right: 4px;
        font-size: 18px;
    }

    .chat-drawer .mud-list-item .mud-typography {
        font-size: 0.75rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 90px;
    }
}

.mud-layout {
    min-height: 100dvh;
}

.mud-layout, .mud-main-content, .chat-scroll {
    height: 100%;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
}

.chat-input {
    background: #212121;
    border-top: 1px solid #444;
    padding: 20px;
}

.chat-input input {
    flex:1 1 auto; min-width:0;
    height:48px; padding:0 16px;
    border:1px solid #3a3a3a; border-radius:9999px;
    background:#2a2a2a; color:#fff; font-size:15px; outline:none;
    box-shadow:inset 0 1px 0 rgba(255,255,255,.03);
}

.chat-input input::placeholder{ color:#8a8a8a; }
.chat-input input:focus{ border-color:#10a37f; box-shadow:0 0 0 2px rgba(16,163,127,.2); }

.chat-input-top{
    display:flex;
    align-items:center;
    gap:10px;
    width:100%;
}

.chat-input button {
    background-color: #10a37f !important;
    color: white !important;
    border: none;
}

.send-btn{
    width:48px; height:48px; padding:0;
    border:none; border-radius:50%;
    background:#10a37f; color:#fff; font-size:18px; font-weight:700;
    display:inline-flex; align-items:center; justify-content:center;
    cursor:pointer; transition:background-color .2s ease, transform .05s ease;
    margin-right: env(safe-area-inset-right);
}
.send-btn:hover:not(:disabled){ background:#0d8a6b; }
.send-btn:active{ transform: translateY(1px); }
.send-btn:disabled{ background:#444; opacity:.6; cursor:not-allowed; }

.chat-input-bottom{ display:flex; align-items:center; justify-content:flex-start; width:100%; }
.db-toggle{ font-size:12px; }
.db-toggle .mud-switch-label{ font-size:12px; }

@media (max-width: 420px){
    .db-toggle .mud-switch-label{ display:none; }
}

.appbar-dark {
    background-color: #1976d2 !important;
    color: #fff !important;
}
.drawer-dark {
    background-color: #23272b !important;
    color: #fff !important;
}
.drawer-listitem-dark {
    color: #fff !important;
}
.maincontent-dark {
    background-color: #181c20 !important;
    color: #fff !important;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0 !important;
}
.page-content .page-title {
    color: #ffffff !important;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    text-shadow: 0 0 6px #00000066;
}
.form-container {
    color: black;
}
.text-field-white {
    color: white;
}

:root { --chat-bar-h: 72px; }

.chat-container{
    display:flex;
    flex-direction:column;
    flex:1 1 auto;
    min-height:0;
    background:#212121;
    overflow: visible;
}

.chat-messages{
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: calc(var(--chat-bar-h) + env(safe-area-inset-bottom) + 16px);
}

.chat-input{
    position: fixed;
    left: env(safe-area-inset-left);
    right: env(safe-area-inset-right);
    bottom: 0;                                        /* не bottom: env(...); just 0 */
    z-index: 1000;

    display: flex;
    flex-direction: column;
    gap: 6px;

    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid #333;
    background: #1e1e1e;
}

@supports (bottom: constant(safe-area-inset-bottom)) {
    .chat-input { padding-bottom: calc(12px + constant(safe-area-inset-bottom)); }
}

fluent-text-field::part(label),
fluent-text-field::part(control) {
    color: white !important;
}

/* Темний фон і білий текст */
fluent-text-field::part(control) {
    background-color: #2f2f2f !important;
    border-color: #555 !important;
}

/* Корпус поля */
fluent-text-field::part(root) {
    background-color: #1f1f1f !important;
}

/* Placeholder */
fluent-text-field input::placeholder {
    color: #aaa !important;
}

.dark-input::part(label),
.dark-input::part(control),
.dark-input input::placeholder {
    color: white !important;
    background-color: #2f2f2f !important;
}

.main {
    min-height: calc(100dvh - 86px);
    color: #f0f0f0;
    align-items: stretch !important;
}

.body-content {
    align-self: stretch;
    height: calc(100dvh - 86px) !important;
    display: flex;
}

.content {
    padding: 0.5rem 1.5rem;
    align-self: stretch !important;
    width: 100%;
}

.manage {
    width: 100dvw;
}

:root {
    --neutral-foreground-rest: #f0f0f0;
    --neutral-foreground-hover: #ffffff;
}

/* ----------------- Footer ----------------- */

footer {
    background: var(--neutral-layer-4, #1e1e1e);
    color: var(--neutral-foreground-rest, #dcdcdc);
    align-items: center;
    padding: 10px 10px;
}

footer a {
    color: var(--neutral-foreground-rest, #dcdcdc);
    text-decoration: none;
}

footer a:focus {
    outline: 1px dashed;
    outline-offset: 3px;
}

footer a:hover {
    text-decoration: underline;
}

/* ----------------- Alerts ----------------- */

.alert {
    border: 1px dashed var(--accent-fill-rest, #5fa8d3);
    padding: 5px;
}

/* ----------------- Blazor error UI ----------------- */

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    margin: 20px 0;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,...) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::before {
    content: "An error has occurred. ";
}

/* ----------------- Loading progress ----------------- */

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: #1b6ec2;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

/* ----------------- Code highlighting ----------------- */

code {
    color: #c02d76;
}

/* ----------------- NAV menu custom dark styling ----------------- */

.nav-link-dark {
    background-color: #1e1e1e;
    color: #e0e0e0 !important; /* <-- ключовий рядок */
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 8px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease-in-out;
    font-weight: 500;
}

.nav-link-dark:hover {
    background-color: #2a2a2a;
    color: #ffffff !important;
}

.nav-link-dark .fluent-icon {
    color: #5fa8d3;
}

.nav-link-dark:disabled,
.nav-link-dark[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    color: #999999 !important;
}

.btn-dark-outline {
    background-color: transparent;
    border: 1px solid #ccc;
    color: #f0f0f0;
    padding: 0.5rem;
    border-radius: 6px;
    width: 100%;
    transition: background-color 0.2s ease-in-out;
}

.btn-dark-outline:hover {
    background-color: #2a2a2a;
    color: #ffffff;
    border-color: #fff;
}
/* ----------------- Responsive styles ----------------- */

@media (max-width: 800px) {
    .header-gutters {
        margin: 0.5rem 3rem 0.5rem 1.5rem !important;
    }

    [dir="rtl"] .header-gutters {
        margin: 0.5rem 1.5rem 0.5rem 3rem !important;
    }

    .main {
        flex-direction: inherit ;
        row-gap: 0 !important;
    }

    nav.sitenav {
        width: 100%;
        height: 100%;
    }

    #main-menu {
        width: 100% !important;
    }

    #main-menu > div:first-child:is(.expander) {
        display: none;
    }

    .navmenu {
        box-shadow: 2px 0 8px rgba(0,0,0,0.3);
        width: 30vw !important;   /* або 30vw */
        min-width: 120px !important;
        max-width: 200px;
    }
    
    .navmenu .sitenav {
        padding-top: 1rem;
    }
    
    #navmenu-toggle {
        appearance: none;
    }

    #navmenu-toggle:not(:checked) ~ nav {
        display: none;
    }

    #navmenu-toggle:checked ~ nav {
        display: block;
    }

    .navmenu-icon {
        cursor: pointer;
        z-index: 10;
        display: block;
        position: absolute;
        top: 15px;
        right: 20px;
        width: 20px;
        height: 20px;
        border: none;
    }

    [dir="rtl"] .navmenu-icon {
        left: 20px;
        right: unset;
    }
}
