/* ==========================================================================
   User Karma Bar — stiliai
   ========================================================================== */

:root {
    --ukb-bg: #ffffff;
    --ukb-fg: #16181c;
    --ukb-border: #e5e5e5;
    --ukb-muted-bg: #f4f4f5;
    --ukb-accent: #d99a00;
    --ukb-accent-fg: #ffffff;
    --ukb-radius: 999px;
}

/* Admin juostos rodymą/slėpimą valdo tik PHP pusėje esantis show_admin_bar filtras
   (žr. user-karma-bar.php -> hide_admin_bar_for_non_admins). Kai filtras grąžina
   false, WordPress pats nebeišveda #wpadminbar elemento ir nebeprideda
   body.admin-bar / html.admin-bar klasių, todėl jokio papildomo CSS priverstinio
   "display:none" čia sąmoningai NEDEDAME — kitaip jis paslėptų juostą ir
   administratoriams. */

/* ---- Pagrindinė juosta -------------------------------------------------- */

.ukb-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
    width: 100%;
    box-sizing: border-box;
        padding: 6px 7px;
	margin-bottom: 10px;
    background: var(--ukb-bg);
    color: var(--ukb-fg);
    border: 1px solid var(--ukb-border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.2;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
    z-index: 9;
}

.ukb-bar * {
    box-sizing: border-box;
}

/* ---- Svečio būsena ------------------------------------------------------- */

.ukb-guest {
    justify-content: flex-start;
}

.ukb-guest-text {
    white-space: nowrap;
}

.ukb-login-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    /* Mygtukas visada prispaustas prie dešinės juostos pusės — tiek dideliame,
       tiek mobiliame ekrane. */
    margin-left: auto;
}

/* ---- „Prisijungti su Google" mygtukas, pritaikytas prie juostos dizaino ---- */

.ukb-google-signin {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    flex: 0 0 auto !important;
    padding: 6px 14px !important;
    background: var(--ukb-bg) !important;
    color: var(--ukb-fg) !important;
    border: 1px solid var(--ukb-border) !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    line-height: 18px !important;
    white-space: nowrap !important;
    cursor: pointer !important;
    transition: background-color 0.15s ease, box-shadow 0.15s ease !important;
}
.ukb-google-signin:hover {
    background: var(--ukb-muted-bg) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
}
.ukb-google-signin:active {
    background: #ececec !important;
}
.ukb-google-signin:disabled {
    opacity: 0.6 !important;
    cursor: default !important;
}
.ukb-google-signin__icon {
    flex: 0 0 auto !important;
    width: 16px !important;
    height: 16px !important;
    display: block !important;
}
.ukb-google-signin__label {
    white-space: nowrap !important;
}

.ukb-google-status {
    font-size: 12px;
    color: #666;
    white-space: nowrap;
}

@media (max-width: 480px) {
    .ukb-google-signin__label {
        display: none;
    }
    .ukb-google-signin {
        padding: 6px 10px !important;
    }
}

/* ---- Prisijungusio vartotojo elementai ----------------------------------- */

.ukb-avatar-btn {
    border: none;
    background: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    line-height: 0;
    flex-shrink: 0;
    border-radius: 50%;
}

.ukb-avatar-btn img,
.ukb-avatar-img,
.ukb-avatar-preview img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: block;
    border: 2px solid var(--ukb-accent);
    object-fit: cover;
}

.ukb-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
    font-weight: 600;
    flex-shrink: 1;
}

.ukb-stat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    flex-shrink: 0;
    padding: 3px 9px;
    background: var(--ukb-muted-bg);
    border: 1px solid var(--ukb-border);
    color: var(--ukb-fg);
    /* .ukb-karma / .ukb-karma-given / .ukb-comments dabar yra <button>, kad būtų
       paspaudžiami (patarimo iššokimui / komentarų sąrašui) — atstatome numatytą
       naršyklės mygtuko stilių, kad atrodytų taip pat kaip anksčiau. */
    font: inherit;
    cursor: default;
    margin: 0;
    -webkit-appearance: none;
    appearance: none;
}

button.ukb-stat {
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}
button.ukb-stat:hover {
    background: #ebebeb;
}
button.ukb-stat:focus-visible {
    outline: 2px solid var(--ukb-accent);
    outline-offset: 1px;
}

.ukb-icon {
    font-size: 13px;
}

.ukb-edit-btn {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--ukb-accent);
    background: transparent;
    color: var(--ukb-accent);
    padding: 5px 12px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease;
}
.ukb-edit-btn:hover {
    background: var(--ukb-accent);
    color: var(--ukb-accent-fg);
}
.ukb-edit-icon {
    display: none;
}

.ukb-logout-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--ukb-border);
    background: transparent;
    color: var(--ukb-fg);
    padding: 5px 12px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.ukb-logout-btn:hover {
    background: #fdeeee;
    color: #cf222e;
    border-color: #cf222e;
}
.ukb-logout-icon {
    display: none;
}

/* ---- Karmos paaiškinimo "toast" -------------------------------------------
   Fiksuotos pozicijos (position: fixed), nes .ukb-bar viduje esantis turinys
   apkarpomas dėl overflow-x:auto — čia to išvengiama, nes toast'as yra ATSKIRAS
   elementas ekrano, o ne juostos, atžvilgiu. Rodomas užvedus pelę / paspaudus /
   fokusavus karmos statistikas (žr. JS: initKarmaToast()). ------------------- */

.ukb-karma-toast {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%) translateY(16px);
    max-width: 340px;
    width: calc(100% - 32px);
    background: #16181c;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 13px;
    line-height: 1.5;
    padding: 12px 16px;
    border-radius: 10px;
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.35);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
    z-index: 100050;
    text-align: left;
}
.ukb-karma-toast.ukb-toast-visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* ---- Modalinis langas ----------------------------------------------------- */

.ukb-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.ukb-modal-overlay.ukb-open {
    display: flex;
}

.ukb-modal {
    background: #ffffff;
    color: #16181c;
    border-radius: 12px;
    padding: 24px;
    max-width: 420px;
    width: 100%;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    max-height: 90vh;
    overflow-y: auto;
}

.ukb-modal h2 {
    margin: 0 0 16px;
    font-size: 18px;
}

.ukb-modal-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    color: #888;
}
.ukb-modal-close:hover {
    color: #16181c;
}

.ukb-form-row {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ukb-avatar-row {
    flex-direction: row;
    align-items: center;
    gap: 14px;
}

.ukb-avatar-preview img {
    width: 56px;
    height: 56px;
}

.ukb-upload-label {
    display: inline-block;
    padding: 6px 12px;
    background: #eee;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}
.ukb-upload-label:hover {
    background: #e2e2e2;
}

#ukb-avatar-upload {
    display: none;
}

.ukb-form-row label {
    font-size: 13px;
    font-weight: 600;
    color: #444;
}

.ukb-form-row input[type="text"] {
    padding: 9px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    width: 100%;
}
.ukb-form-row input[type="text"]:focus {
    outline: none;
    border-color: var(--ukb-accent);
}

/* ---- "Mano komentarai" iššokantis langas (su scrollbar) -------------------- */

.ukb-comments-modal {
    max-width: 460px;
}

.ukb-comments-modal-body {
    /* Fiksuotas maksimalus aukštis + overflow-y:auto duoda scrollbar'ą, kai
       komentarų sąrašas ilgesnis nei matoma sritis. */
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 4px;
}

.ukb-comments-loading,
.ukb-comments-empty {
    font-size: 13px;
    color: #666;
    text-align: center;
    padding: 20px 0;
}

.ukb-comments-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ukb-comment-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--ukb-border);
}
.ukb-comment-item:last-child {
    border-bottom: none;
}

.ukb-comment-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.ukb-comment-link {
    color: #16181c;
    text-decoration: none;
    font-size: 13px;
    line-height: 1.4;
    flex: 1 1 auto;
    min-width: 0;
}
.ukb-comment-link:hover {
    text-decoration: underline;
    color: var(--ukb-accent);
}

.ukb-comment-karma {
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--ukb-radius);
    white-space: nowrap;
}
.ukb-comment-karma.ukb-positive {
    color: #1a7f37;
    background: #eaf7ee;
}
.ukb-comment-karma.ukb-negative {
    color: #cf222e;
    background: #fdeeee;
}
.ukb-comment-karma.ukb-neutral {
    color: #666;
    background: var(--ukb-muted-bg);
}

.ukb-comment-date {
    margin-top: 4px;
    font-size: 11px;
    color: #888;
}

/* ---- Slapyvardžio keitimo ribojimas (tik vieną kartą) ---------------------- */

.ukb-name-hint {
    margin: 2px 0 0;
    font-size: 12px;
    color: #666;
}

.ukb-name-lock-note {
    margin: 2px 0 0;
    font-size: 12px;
    color: #b3610a;
}

.ukb-form-row input[type="text"]:disabled {
    background: var(--ukb-muted-bg);
    color: #888;
    cursor: not-allowed;
}

.ukb-form-msg {
    min-height: 18px;
    font-size: 13px;
    margin-bottom: 8px;
}
.ukb-form-msg.success {
    color: #1a7f37;
}
.ukb-form-msg.error {
    color: #cf222e;
}

.ukb-form-actions {
    display: flex;
    justify-content: flex-end;
}

.ukb-save-btn {
    background: var(--ukb-accent);
    border: none;
    color: #16181c;
    padding: 9px 20px;
    border-radius: var(--ukb-radius);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}
.ukb-save-btn:hover {
    filter: brightness(0.95);
}
.ukb-save-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

/* ---- Karmos taškų lentelė (leaderboard) ----------------------------------
   .ukb-leaderboard-wrap turi ir overflow-y (ribotas max-height -> vertikalus
   scrollbar, jei vartotojų sąrašas ilgas), ir overflow-x (jei lentelė
   platesnė nei ekranas siaurame įrenginyje) — todėl lentelė visada tilpsta
   į turimą vietą, niekada neišstumdama likusio puslapio turinio. -------------- */

.ukb-leaderboard-wrap {
    width: 100%;
    max-width: 100%;
    max-height: 480px;
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--ukb-border);
    border-radius: 10px;
    box-sizing: border-box;
    background: var(--ukb-bg);
}

.ukb-leaderboard-table {
    width: 100%;
    min-width: 360px;
    border-collapse: collapse;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
    color: var(--ukb-fg);
}

.ukb-leaderboard-table th,
.ukb-leaderboard-table td {
    padding: 8px 12px;
    text-align: left;
    white-space: nowrap;
    box-sizing: border-box;
}

.ukb-leaderboard-table thead th {
    position: sticky;
    top: 0;
    background: var(--ukb-muted-bg);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #555;
    border-bottom: 1px solid var(--ukb-border);
    z-index: 1;
}

.ukb-leaderboard-table tbody tr {
    border-bottom: 1px solid var(--ukb-border);
}
.ukb-leaderboard-table tbody tr:last-child {
    border-bottom: none;
}
.ukb-leaderboard-table tbody tr:hover {
    background: var(--ukb-muted-bg);
}

.ukb-leaderboard-table tr.ukb-leaderboard-me {
    background: #fff6e0;
}
.ukb-leaderboard-table tr.ukb-leaderboard-me:hover {
    background: #fdedc0;
}

.ukb-leaderboard-rank {
    width: 36px;
    color: #888;
    font-weight: 600;
}

.ukb-leaderboard-user {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    vertical-align: middle;
}

.ukb-leaderboard-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: block;
    flex-shrink: 0;
    object-fit: cover;
}

.ukb-leaderboard-name {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.ukb-leaderboard-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.ukb-leaderboard-empty {
    text-align: center;
    color: #666;
    padding: 20px 0;
    white-space: normal;
}

@media (max-width: 480px) {
    .ukb-leaderboard-wrap {
        max-height: 60vh;
    }
    .ukb-leaderboard-table {
        font-size: 12px;
        min-width: 300px;
    }
    .ukb-leaderboard-table th,
    .ukb-leaderboard-table td {
        padding: 6px 8px;
    }
    .ukb-leaderboard-name {
        max-width: 140px;
    }
}

/* ---- Responsive: mobilieji įrenginiai ------------------------------------
   Avataras ir taškai (karma / komentarai) visada lieka matomi, tik tekstai
   sutrumpėja arba pasislepia. ---------------------------------------------- */

@media (max-width: 600px) {
    .ukb-bar {
        gap: 8px;
        padding: 6px 10px;
        font-size: 12px;
    }
    /* Vartotojas nori matyti PILNĄ vardą mobiliajame — nebekarpome jo su
       max-width/ellipsis. Jei vardas ilgas, juosta (kuri turi overflow-x:auto)
       tiesiog slenka horizontaliai, o vardas visada lieka pilnai perskaitomas. */
    .ukb-name {
        max-width: none;
        overflow: visible;
        text-overflow: clip;
        flex-shrink: 0;
    }
    /* Svečio būsena mobiliajame: tekstas ir Google mygtukas VISADA vienoje eilutėje.
       Mygtukas rodomas tik su „G“ ikona (be užrašo), o teksto šrifto dydį tiksliai
       pritaiko user-karma-bar.js (fitGuestText) — jei tekstas netelpa, šriftas mažinamas.
       CSS clamp žemiau — tik atsarginis variantas, jei JS neveiktų. */
    .ukb-guest {
        gap: 6px;
        flex-wrap: nowrap;
        padding-left: 8px;
        padding-right: 8px;
    }
    .ukb-guest-text {
        flex: 1 1 auto;
        min-width: 0;
        max-width: none;
        white-space: nowrap;
        overflow: visible;
        text-overflow: clip;
        line-height: 1.2;
        font-size: clamp(9px, 3.6vw, 14px);
    }
    .ukb-guest .ukb-login-btn {
        gap: 0;
    }
    .ukb-guest .ukb-google-signin__label {
        display: none;
    }
    .ukb-guest .ukb-google-signin {
        padding: 5px 8px !important;
    }
    .ukb-stat {
        padding: 3px 6px;
    }
    .ukb-edit-text {
        display: none;
    }
    .ukb-edit-icon {
        display: inline;
    }
    .ukb-edit-btn {
        padding: 6px 9px;
    }
    .ukb-logout-text {
        display: none;
    }
    .ukb-logout-icon {
        display: inline;
    }
    .ukb-logout-btn {
        padding: 6px 9px;
    }
}
