/* src/web/web.css */

:root {
    --bg0: #0b1020;
    --bg1: #0f1a33;
    --card: rgba(255, 255, 255, 0.08);
    --card2: rgba(255, 255, 255, 0.06);
    --stroke: rgba(255, 255, 255, 0.14);
    --text: rgba(255, 255, 255, 0.92);
    --muted: rgba(255, 255, 255, 0.68);
    --brand: #6aa9ff;
    --brand2: #8be9ff;
    --good: #30d158;
    --bad: #ff453a;
    --warn: #ff9f0a;
    --shadow: rgba(0, 0, 0, 0.35);
    --radius: 18px;
    --mono:
        ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg0: #eef3ff;
        --bg1: #f7f9ff;
        --card: rgba(10, 18, 35, 0.06);
        --card2: rgba(10, 18, 35, 0.04);
        --stroke: rgba(10, 18, 35, 0.12);
        --text: rgba(10, 18, 35, 0.92);
        --muted: rgba(10, 18, 35, 0.62);
        --shadow: rgba(10, 18, 35, 0.14);
    }
}

/* Optional manual override if you set :root[data-theme="light"/"dark"] */
:root[data-theme="light"] {
    --bg0: #eef3ff;
    --bg1: #f7f9ff;
    --card: rgba(10, 18, 35, 0.06);
    --card2: rgba(10, 18, 35, 0.04);
    --stroke: rgba(10, 18, 35, 0.12);
    --text: rgba(10, 18, 35, 0.92);
    --muted: rgba(10, 18, 35, 0.62);
    --shadow: rgba(10, 18, 35, 0.14);
}

:root[data-theme="dark"] {
    --bg0: #0b1020;
    --bg1: #0f1a33;
    --card: rgba(255, 255, 255, 0.08);
    --card2: rgba(255, 255, 255, 0.06);
    --stroke: rgba(255, 255, 255, 0.14);
    --text: rgba(255, 255, 255, 0.92);
    --muted: rgba(255, 255, 255, 0.68);
    --shadow: rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: var(--sans);
    color: var(--text);
    background: var(--bg1);
}

/* Background layer */
.bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 1;
    background:
        radial-gradient(1200px 700px at 20% 10%, rgba(106, 169, 255, 0.35), transparent 55%),
        radial-gradient(900px 650px at 90% 20%, rgba(139, 233, 255, 0.22), transparent 60%),
        linear-gradient(180deg, var(--bg0), var(--bg1));
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    max-width: 1180px;
    margin: 0 auto;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
}

.logo {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(106, 169, 255, 0.7), rgba(139, 233, 255, 0.35));
    color: #081022;
    font-weight: 900;
    box-shadow: 0 12px 30px var(--shadow);
}

.brand-text .title {
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand-text .subtitle {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.nav {
    display: flex;
    gap: 12px;
    align-items: center;
}

.nav-link {
    color: var(--muted);
    text-decoration: none;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 12px;
}

.nav-link:hover {
    color: var(--text);
    border-color: var(--stroke);
    background: rgba(255, 255, 255, 0.05);
}

.page {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 20px 26px;
}

.footer {
    max-width: 1180px;
    margin: 0 auto;
    padding: 10px 20px 24px;
}

.muted {
    color: var(--muted);
}

.card {
    border-radius: var(--radius);
    border: 1px solid var(--stroke);
    background: linear-gradient(180deg, var(--card), var(--card2));
    box-shadow: 0 18px 50px var(--shadow);
    padding: 16px;
    backdrop-filter: blur(10px);
    /* Animacija ulaska */
    animation: fadeInSlide 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

:root[data-mounted="1"] .card {
    animation: none;
}

.btn {
    height: 34px;
    padding: 0 12px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font-family: var(--sans);
    font-size: 12px;
    font-weight: 750;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition:
        transform 0.12s ease,
        background 0.12s ease,
        border-color 0.12s ease,
        opacity 0.12s ease;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.22);
}

.btn.primary {
    border-color: rgba(106, 169, 255, 0.35);
    background: linear-gradient(135deg, rgba(106, 169, 255, 0.35), rgba(139, 233, 255, 0.12));
}

.btn.ghost {
    background: transparent;
}

.drawer-close-x {
    width: 36px; /* kvadratno dugme */
    padding: 0; /* bez horizontalnog “dugmeta” */
    font-size: 18px; /* da × izgleda kao pravi close */
    font-weight: 900;
    line-height: 1;
}

.drawer-close-x.btn.ghost {
    border-color: transparent;
}

.drawer-close-x.btn.ghost:hover:not(:disabled) {
    border-color: rgba(255, 255, 255, 0.22);
}

.input,
select,
textarea {
    width: 100%;
    border-radius: 14px;
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    padding: 10px 12px;
    outline: none;
    font-family: var(--sans);
}

textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.45;
}

textarea[readonly] {
    font-family: var(--mono);
    opacity: 0.92;
}

/* --- APP LAYOUT --- */

.app-root {
    display: grid;
    gap: 14px;
}

.segment {
    display: inline-flex;
    gap: 6px;
    padding: 6px;
    border: 1px solid var(--stroke);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
}

.app-grid {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 14px;
    /* Animacija ulaska */
    animation: fadeInSlide 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@media (max-width: 980px) {
    .app-grid {
        grid-template-columns: 1fr;
    }
}

.panel-sub {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.grow {
    flex: 1;
}

/* DROP ZONE */
.drop {
    position: relative;
    border: 1px dashed rgba(255, 255, 255, 0.25);
    border-radius: 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    margin-bottom: 12px;
    /* Cleaned up transition (removed duplicate) */
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.drop:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.38);
    background: rgba(255, 255, 255, 0.05);
}

.drop.drag {
    border-color: var(--brand);
    background: rgba(106, 169, 255, 0.15);
    transform: scale(1.02); /* Malo uvećanje */
    box-shadow: 0 0 0 4px rgba(106, 169, 255, 0.15); /* Glow efekat */
}

.drop.drag .drop-icon {
    transform: translateY(-5px) scale(1.2); /* Ikonica skače gore */
    color: var(--brand);
}

.drop input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.drop-inner {
    display: grid;
    gap: 6px;
    text-align: center;
    padding: 18px 10px;
}

.drop-icon {
    font-family: var(--mono);
    font-weight: 900;
    font-size: 28px;
    color: var(--brand2);
    transition: transform 0.3s ease;
}

.kv {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
}

.pill {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--muted);
}

.progress {
    height: 10px;
    border-radius: 999px;
    border: 1px solid var(--stroke);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.03);
}

.bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--brand), var(--brand2));
    transition: width 0.16s ease;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 10px 0 12px;
}

.pre {
    font-family: var(--mono);
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
    border: 1px solid var(--stroke);
    border-radius: 14px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
}

.table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--stroke);
    border-radius: 14px;
    overflow: hidden;
}

.table th,
.table td {
    text-align: left;
    padding: 10px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    vertical-align: top;
    font-size: 13px;
}

.table th {
    color: var(--muted);
    font-weight: 800;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.03);
    font-size: 12px;
    font-family: var(--mono);
    color: var(--muted);
}

.badge.good {
    border-color: rgba(48, 209, 88, 0.35);
    color: rgba(48, 209, 88, 0.95);
}

.badge.bad {
    border-color: rgba(255, 69, 58, 0.35);
    color: rgba(255, 69, 58, 0.95);
}

/* Drawer */
.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(6px);
    display: none;
    z-index: 50;
}

.drawer-overlay.open {
    display: block;
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    width: min(460px, 92vw);
    background: linear-gradient(180deg, var(--card), var(--card2));
    border-left: 1px solid var(--stroke);
    box-shadow: -20px 0 60px var(--shadow);
    transform: translateX(102%);
    transition: transform 0.18s ease;
    z-index: 60;
    display: grid;
    grid-template-rows: auto 1fr auto;
}

.drawer.open {
    transform: translateX(0%);
}

.drawer-head {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.drawer-body {
    padding: 16px;
    overflow: auto;
    display: grid;
    gap: 12px;
}

.drawer-foot {
    padding: 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.field {
    display: grid;
    gap: 6px;
}

.field label {
    font-size: 12px;
    color: var(--muted);
}

.hr {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    border: 0;
    margin: 6px 0;
}

/* Diff classes */
.diff-added {
    background: rgba(48, 209, 88, 0.16);
    border-bottom: 1px solid rgba(48, 209, 88, 0.35);
}

.diff-removed {
    background: rgba(255, 69, 58, 0.14);
    border-bottom: 1px solid rgba(255, 69, 58, 0.35);
}

.clickable {
    cursor: pointer;
}

.diff-rejected {
    opacity: 0.45;
    text-decoration: line-through;
}

/* Tags (protected words) */
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.03);
    font-size: 12px;
    font-family: var(--mono);
    color: var(--muted);
}

.tag-x {
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 10px;
}

.tag-x:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.18);
}

/* Command palette */
.palette-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(6px);
    display: none;
    z-index: 80;
}

.palette-overlay.open {
    display: block;
}

.palette {
    position: fixed;
    left: 50%;
    top: 14vh;
    transform: translateX(-50%);
    width: min(720px, 92vw);
    border-radius: 18px;
    border: 1px solid var(--stroke);
    background: linear-gradient(180deg, var(--card), var(--card2));
    box-shadow: 0 24px 80px var(--shadow);
    padding: 12px;
    display: none;
    z-index: 90;
}

.palette.open {
    display: grid;
    gap: 10px;
}

.palette-input {
    width: 100%;
    border-radius: 14px;
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    padding: 12px 12px;
    outline: none;
    font-family: var(--sans);
    font-weight: 700;
}

.palette-list {
    display: grid;
    gap: 8px;
    max-height: 44vh;
    overflow: auto;
    padding: 2px;
}

.palette-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    cursor: pointer;
    text-align: left;
}

.palette-item:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.22);
}

.palette-item[aria-selected="true"] {
    border-color: rgba(106, 169, 255, 0.42);
    background: rgba(106, 169, 255, 0.12);
}

.palette-item:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.palette-item-title {
    font-weight: 800;
}

.palette-item-hint {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--muted);
}

.palette-empty {
    padding: 12px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 12px;
}

.palette-foot {
    color: var(--muted);
    font-size: 12px;
    font-family: var(--mono);
    padding: 2px 4px;
}

/* --- Update banner (Service Worker update available) --- */
.st-update-banner {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 16px;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 12px;
    border-radius: 16px;
    border: 1px solid var(--stroke);
    background: linear-gradient(180deg, var(--card), var(--card2));
    box-shadow: 0 18px 50px var(--shadow);
    backdrop-filter: blur(10px);
}

.st-update-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.st-update-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--brand), var(--brand2));
    box-shadow: 0 0 0 3px rgba(106, 169, 255, 0.15);
    flex: 0 0 auto;
}

.st-update-msg {
    font-weight: 800;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.st-update-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex: 0 0 auto;
}

.st-update-x {
    border-radius: 12px;
    padding: 8px 10px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-weight: 900;
    line-height: 1;
}

.st-update-x:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.18);
}

.kbd-chip.off {
    opacity: 0.7;
    border-style: dashed;
}

button.kbd-chip:focus-visible {
    outline: 2px solid rgba(106, 169, 255, 0.55);
    outline-offset: 2px;
}

/* Drawer head: allow 2-line left side (title + chips) */
.drawer-head-left {
    display: grid;
    gap: 6px;
}

.badge.warn {
    border-color: rgba(255, 159, 10, 0.35);
    color: rgba(255, 159, 10, 0.95);
}

/* --- ANIMATIONS & TOASTS (NEW) --- */

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: rgba(10, 18, 35, 0.85);
    color: white;
    padding: 10px 16px;
    border-radius: 99px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(20px);
    animation: toastIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

:root[data-theme="light"] .toast {
    background: rgba(255, 255, 255, 0.9);
    color: #081022;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

@keyframes toastIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.app-top-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Top header row: left group (mode+direction) + right group (actions+wifi+version) */
.top-row-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    flex-wrap: wrap;
}

.top-left-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 0;
}

.top-right-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin-left: auto;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.direction-select {
    width: auto !important;
    min-width: 140px;
    flex-grow: 0 !important;
    margin-right: 0;
}

/* --- WIFI DUGME SA TEKSTOM --- */
.wifi-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.wifi-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-1px);
}

.wifi-label {
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}

.wifi-btn svg {
    width: 18px;
    height: 18px;
    display: block;
    flex: 0 0 auto;
}

/* STANJA WIFI DUGMETA */

/* Online: Plavo/Zeleno i svetlo */
.wifi-btn.is-online {
    color: var(--brand2);
    border-color: rgba(139, 233, 255, 0.2);
    background: rgba(139, 233, 255, 0.05);
}

/* Offline: Sivo i "ugašeno" */
.wifi-btn.is-offline {
    color: var(--muted);
    border-color: rgba(255, 255, 255, 0.08);
    background: transparent;
    opacity: 0.85;
}

.tab-btn:disabled,
.seg-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.u-nowrap {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.u-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.panel-head {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.panel-head-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.panel-title {
    min-width: 0;
    margin: 0;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

/* Right-side actions in header */
.panel-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap; /* default: allow wrap on narrow screens */
    margin-left: auto;
}

/* Buttons should fit text in SR/EN */
.panel-actions .btn {
    flex: 0 0 auto;
    width: max-content;
    white-space: nowrap;
}

/* Sub-row: description left, label right (Text panel) */
.panel-sub-row {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    width: 100%;
    align-items: center;
}

.panel-sub-row .panel-sub {
    margin: 0;
}

.panel-sub-label {
    margin-left: auto;
    text-align: right;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

/* If you want actions to NOT wrap inside themselves (Text header), use this modifier */
.panel-actions.nowrap {
    flex-wrap: nowrap;
}

/* Tabs when used inline in header row */
.tabs.tabs-inline {
    margin: 0;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: nowrap;
}

.field-label-right {
    justify-self: end;
    text-align: right;
}

.text-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
    margin: 0;
    padding: 0;
}

@media (max-width: 560px) {
    .panel-head-row {
        grid-template-columns: 1fr;
    }

    .panel-actions.nowrap {
        flex-wrap: wrap; /* allow wrap on very small screens */
        justify-content: flex-end;
    }

    .tabs.tabs-inline {
        flex-wrap: wrap;
    }
}

.btn.ghost.seg-btn,
.btn.ghost.tab-btn,
.btn.ghost.live-toggle {
    color: var(--muted);
    background: transparent;
}

.btn.ghost.seg-btn[aria-pressed="true"],
.btn.ghost.live-toggle[aria-pressed="true"],
.btn.ghost.tab-btn[aria-selected="true"] {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.22);
}

.btn.ghost.seg-btn {
    border-color: transparent;
}

.btn.ghost.seg-btn[aria-pressed="true"] {
    border-color: rgba(255, 255, 255, 0.22);
}

:root[data-mounted="1"] .app-grid {
    animation: none;
}

