/* ---------- container ---------- */

.top-region {
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.top-region-row {
    display: flex;
    align-items: center;
    padding: 0 var(--top-region-pad-x);
    gap: 20px;
}

.top-region-row-main {
    height: var(--top-region-height);
}

.top-region-row-sub {
    height: var(--top-region-sub-height);
    background: var(--color-navy);
    color: var(--color-text-on-dark);
}

/* ---------- mobile menu toggle ---------- */

.top-region-menu-toggle {
    display: none;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
}

.top-region-menu-icon {
    width: 24px;
    height: 24px;
    display: inline-block;
    background-color: var(--color-primary);
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><line x1='3' y1='6' x2='21' y2='6'/><line x1='3' y1='12' x2='21' y2='12'/><line x1='3' y1='18' x2='21' y2='18'/></svg>") no-repeat center / contain;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><line x1='3' y1='6' x2='21' y2='6'/><line x1='3' y1='12' x2='21' y2='12'/><line x1='3' y1='18' x2='21' y2='18'/></svg>") no-repeat center / contain;
}

.top-region-menu-icon-open {
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><line x1='6' y1='6' x2='18' y2='18'/><line x1='18' y1='6' x2='6' y2='18'/></svg>");
    mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><line x1='6' y1='6' x2='18' y2='18'/><line x1='18' y1='6' x2='6' y2='18'/></svg>");
}

@media (max-width: 768px) {
    .top-region-menu-toggle {
        display: flex;
    }

    /* Manje pretrpan red — korpa i odjava se premeštaju u hamburger meni (LeftRegion.razor). Pretraga
       i kartica izabranog kupca idu jedno ispod drugog (flex-basis 100% forsira prelom u nov red),
       umesto da se stiskaju jedno pored drugog u istom redu. */
    .top-region-row-main {
        height: auto;
        flex-wrap: wrap;
        padding: 10px 12px;
        gap: 10px;
    }

    /* Logo je već dostupan u hamburger meniju (LeftLogo) — na uskom top baru samo oduzima prostor
       pretrazi, pa se ovde potpuno sklanja. */
    .top-logo {
        display: none;
    }

    .top-search {
        min-width: 0;
        max-width: none;
        margin: 0;
        flex: 1 1 100%;
    }

    .top-customer {
        max-width: none;
        flex: 1 1 100%;
    }

    .top-customer-card {
        width: 100%;
        min-width: 0;
        max-width: none;
        padding: 4px 8px;
        height: 40px;
        gap: 6px;
        box-sizing: border-box;
    }

    .top-customer-icon {
        width: 18px;
        height: 18px;
    }

    .top-customer-title {
        font-size: 9px;
    }

    /* Kartica je sad puna širina reda, pa ime kupca ima mnogo više prostora — širi se preko
       preostalog dela kartice i skraćuje sa "..." samo ako mu ni to ne bude dovoljno. */
    .top-customer-labels {
        min-width: 0;
        flex: 1;
    }

    .top-customer-name {
        font-size: 10px;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Bitno: skalirano samo na top-bar kopije — CartBadge/UserMenu se ponovo koriste u hamburger
       meniju (LeftRegion.razor) sa ISTIM CSS klasama (.top-cart/.top-user-menu), pa ovo pravilo NE
       sme biti globalno (.top-cart bez konteksta) ili bi sakrilo i te kopije u meniju. */
    .top-region-row-main .top-cart,
    .top-region-row-main .top-user-menu {
        display: none;
    }
}

/* ---------- logo ---------- */

.top-logo {
    flex: 0 0 auto;
}

.top-logo img {
    height: 44px;
    display: block;
}

/* ---------- search ---------- */

.top-search {
    flex: 1;
    min-width: 280px;
    max-width: 720px;
    position: relative;
    display: flex;
    align-items: center;
    margin: 0 auto;
}

.top-search input {
    width: 100%;
    height: 44px;
    padding: 0 48px 0 20px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-input);
    background: var(--color-input-bg);
    font-size: var(--font-size-base);
    color: var(--color-text);
    outline: none;
    transition: border-color 0.15s;
}

.top-search input:focus {
    border-color: var(--color-primary);
}

.top-search input::placeholder {
    color: var(--color-text-muted);
}

.top-search button {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.top-search-icon {
    width: 18px;
    height: 18px;
    display: inline-block;
    background-color: var(--color-text-muted);
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>") no-repeat center / contain;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>") no-repeat center / contain;
}

/* ---------- active customer card + hover menu ---------- */

.top-customer {
    position: relative;
    max-width: 260px;
}

.top-customer-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 20px;
    height: 56px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    min-width: 220px;
    max-width: 260px;
    text-align: left;
    transition: border-color 0.15s;
    cursor: default;
    outline: none;
    box-sizing: border-box;
}

.top-customer:hover .top-customer-card,
.top-customer:focus-within .top-customer-card {
    border-color: var(--color-border-strong);
}

.top-customer-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 100%;
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-top: 2px solid var(--color-primary);
    border-radius: 0 0 var(--radius-card) var(--radius-card);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    z-index: 100;
    padding: 4px 0;
    flex-direction: column;
}

.top-customer:hover .top-customer-menu,
.top-customer:focus-within .top-customer-menu {
    display: flex;
}

.top-customer-menu-item:disabled {
    color: var(--color-text-muted);
    cursor: not-allowed;
    background: transparent;
}

.top-customer-menu-item {
    display: block;
    width: 100%;
    padding: 10px 20px;
    border: none;
    background: transparent;
    text-align: left;
    font-size: var(--font-size-base);
    color: var(--color-text);
    cursor: pointer;
    transition: background 0.15s;
}

.top-customer-menu-item:hover {
    background: var(--color-bg);
}

.top-customer-icon {
    width: 26px;
    height: 26px;
    background-color: var(--color-text);
    flex-shrink: 0;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'/><circle cx='12' cy='7' r='4'/></svg>") no-repeat center / contain;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'/><circle cx='12' cy='7' r='4'/></svg>") no-repeat center / contain;
}

.top-customer-labels {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.25;
    min-width: 0;
}

.top-customer-title {
    font-size: var(--font-size-small);
    color: var(--color-text-muted);
    font-weight: 500;
    letter-spacing: 0.06em;
}

.top-customer-name {
    font-size: var(--font-size-base);
    color: var(--color-text);
    font-weight: 700;
    letter-spacing: 0.02em;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- cart badge ---------- */

.top-cart {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    height: 56px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    color: var(--color-text);
    transition: border-color 0.15s;
}

.top-cart:hover {
    border-color: var(--color-border-strong);
}

.top-cart-icon {
    width: 24px;
    height: 24px;
    background-color: var(--color-primary);
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='9' cy='21' r='1'/><circle cx='20' cy='21' r='1'/><path d='M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6'/></svg>") no-repeat center / contain;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='9' cy='21' r='1'/><circle cx='20' cy='21' r='1'/><path d='M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6'/></svg>") no-repeat center / contain;
}

.top-cart-count {
    font-weight: 700;
    font-size: var(--font-size-large);
    color: var(--color-text);
    min-width: 18px;
    text-align: center;
}

/* ---------- user menu / logout ---------- */

.top-user-menu {
    margin: 0;
}

.top-logout {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 4px;
    background: transparent;
    border: none;
    color: var(--color-text);
}

.top-logout-icon {
    width: 26px;
    height: 26px;
    background-color: var(--color-text);
    flex-shrink: 0;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/><polyline points='16 17 21 12 16 7'/><line x1='21' y1='12' x2='9' y2='12'/></svg>") no-repeat center / contain;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/><polyline points='16 17 21 12 16 7'/><line x1='21' y1='12' x2='9' y2='12'/></svg>") no-repeat center / contain;
}

.top-logout-labels {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.25;
}

.top-logout-title {
    font-size: var(--font-size-small);
    color: var(--color-text-muted);
    font-weight: 500;
    letter-spacing: 0.06em;
}

.top-logout-name {
    font-size: var(--font-size-base);
    color: var(--color-text);
    font-weight: 700;
}

/* ---------- breadcrumb ---------- */

.top-breadcrumb {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    color: var(--color-text-on-dark);
    font-size: var(--font-size-base);
}

.top-breadcrumb a {
    color: var(--color-text-on-dark);
    opacity: 0.85;
    transition: opacity 0.15s;
}

.top-breadcrumb a:hover {
    opacity: 1;
}

.top-breadcrumb-home {
    display: inline-flex;
    align-items: center;
    padding: 4px;
}

.top-breadcrumb-home-icon {
    width: 16px;
    height: 16px;
    background-color: currentColor;
    display: inline-block;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'/></svg>") no-repeat center / contain;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'/></svg>") no-repeat center / contain;
}

.top-breadcrumb-sep {
    opacity: 0.55;
    font-size: 17px;
}

/* ---------- view mode toggle ---------- */

.top-viewmode {
    display: flex;
    gap: 2px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    padding: 3px;
    margin-left: auto;
}

.top-viewmode-btn {
    width: 34px;
    height: 28px;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    color: rgba(255, 255, 255, 0.65);
    padding: 0;
    transition: background 0.15s, color 0.15s;
}

.top-viewmode-btn:hover:not(.active) {
    color: var(--color-text-on-dark);
}

.top-viewmode-btn.active {
    background: rgba(255, 255, 255, 0.18);
    color: var(--color-text-on-dark);
}

.top-viewmode-grid-icon,
.top-viewmode-list-icon {
    width: 16px;
    height: 16px;
    background-color: currentColor;
    display: inline-block;
}

.top-viewmode-grid-icon {
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='3' width='7' height='7'/><rect x='14' y='3' width='7' height='7'/><rect x='14' y='14' width='7' height='7'/><rect x='3' y='14' width='7' height='7'/></svg>") no-repeat center / contain;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='3' width='7' height='7'/><rect x='14' y='3' width='7' height='7'/><rect x='14' y='14' width='7' height='7'/><rect x='3' y='14' width='7' height='7'/></svg>") no-repeat center / contain;
}

.top-viewmode-list-icon {
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><line x1='8' y1='6' x2='21' y2='6'/><line x1='8' y1='12' x2='21' y2='12'/><line x1='8' y1='18' x2='21' y2='18'/><line x1='3' y1='6' x2='3.01' y2='6'/><line x1='3' y1='12' x2='3.01' y2='12'/><line x1='3' y1='18' x2='3.01' y2='18'/></svg>") no-repeat center / contain;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><line x1='8' y1='6' x2='21' y2='6'/><line x1='8' y1='12' x2='21' y2='12'/><line x1='8' y1='18' x2='21' y2='18'/><line x1='3' y1='6' x2='3.01' y2='6'/><line x1='3' y1='12' x2='3.01' y2='12'/><line x1='3' y1='18' x2='3.01' y2='18'/></svg>") no-repeat center / contain;
}

/* Na mobilnom telefonu /pretraga/artikli uvek prikazuje cue cards (ArticleSearch.razor), pa nema
   smisla nuditi izbor prikaza. */
@media (max-width: 1100px) {
    .top-viewmode {
        display: none;
    }
}

/* ---------- modal ---------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 1000;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #eef0f2;
    border-radius: var(--radius-card);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    z-index: 1001;
    padding: 32px 40px 40px;
    max-height: 90vh;
    overflow: auto;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 23px;
    color: var(--color-text-muted);
    line-height: 1;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--color-text);
}

/* ---------- customer picker ---------- */

.customer-picker {
    width: 640px;
    max-width: 90vw;
}

.customer-picker-filters {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.customer-picker-input {
    width: 100%;
    height: 44px;
    padding: 0 20px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: var(--color-surface);
    font-size: var(--font-size-base);
    color: var(--color-text);
    outline: none;
    transition: border-color 0.15s;
}

.customer-picker-input:focus {
    border-color: var(--color-primary);
}

.customer-picker-input::placeholder {
    color: var(--color-text-muted);
}

.customer-picker-submit {
    width: 100%;
    height: 48px;
    background: transparent;
    border: 2px solid var(--color-navy);
    border-radius: 4px;
    color: var(--color-navy);
    font-size: var(--font-size-large);
    font-weight: 600;
    letter-spacing: 0.15em;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    margin-top: 4px;
}

.customer-picker-submit:hover:not(:disabled) {
    background: var(--color-navy);
    color: var(--color-text-on-dark);
}

.customer-picker-submit:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.customer-picker-results {
    margin-top: 24px;
    background: #d5d7da;
    border-radius: 4px;
    height: 240px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.customer-picker-results-header,
.customer-picker-row-button {
    display: grid;
    grid-template-columns: 100px 1fr 140px;
    gap: 16px;
    padding: 12px 20px;
    align-items: center;
    text-align: left;
}

.customer-picker-results-header {
    font-weight: 700;
    font-size: var(--font-size-base);
    color: var(--color-text);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: #d5d7da;
    position: sticky;
    top: 0;
    z-index: 1;
}

.customer-picker-results-body {
    flex: 1;
    overflow-y: auto;
}

.customer-picker-row {
    margin: 0;
}

.customer-picker-row-button {
    width: 100%;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: var(--font-size-base);
    color: var(--color-text);
    transition: background 0.1s;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.customer-picker-row-button:hover {
    background: rgba(255, 255, 255, 0.4);
}

.customer-picker-row-button > div:nth-child(2) {
    font-weight: 600;
}

.customer-picker-status {
    padding: 20px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--font-size-base);
}

/* ---------- customer debt ---------- */

.customer-debt {
    width: 480px;
    max-width: 90vw;
}

.customer-debt-title {
    margin: 0 0 20px;
    font-size: var(--font-size-large);
    color: var(--color-text);
}

.customer-debt-status {
    padding: 20px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--font-size-base);
}

.customer-debt-table {
    width: 100%;
    border-collapse: collapse;
}

.customer-debt-table td {
    padding: 10px 4px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    font-size: var(--font-size-base);
    color: var(--color-text);
}

.customer-debt-table td:first-child {
    color: var(--color-text-muted);
}

.customer-debt-table td:last-child {
    text-align: right;
    font-weight: 600;
    white-space: nowrap;
}

.customer-debt-row-warning td {
    color: #c62828;
}

