/* PWA / мобилен app layout — safe areas, без хоризонтално лизгање */

:root {
    --pwa-safe-top: env(safe-area-inset-top, 0px);
    --pwa-safe-right: env(safe-area-inset-right, 0px);
    --pwa-safe-bottom: env(safe-area-inset-bottom, 0px);
    --pwa-safe-left: env(safe-area-inset-left, 0px);
    --pwa-pad-x: max(16px, var(--pwa-safe-left), var(--pwa-safe-right));
    --pwa-pad-bottom: max(24px, var(--pwa-safe-bottom));
}

html {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    overscroll-behavior-x: none;
    -webkit-overflow-scrolling: touch;
}

img,
svg,
video,
canvas,
iframe {
    max-width: 100%;
    height: auto;
}

.container,
.container-fluid,
.container-main,
.billing-wrap {
    max-width: 100%;
    box-sizing: border-box;
}

.container-main {
    padding-left: var(--pwa-pad-x);
    padding-right: var(--pwa-pad-x);
    padding-bottom: var(--pwa-pad-bottom);
}

.billing-wrap {
    padding-left: var(--pwa-pad-x);
    padding-right: var(--pwa-pad-x);
    padding-bottom: max(60px, var(--pwa-pad-bottom));
}

.navbar {
    margin-top: max(7vh, var(--pwa-safe-top));
    padding-left: max(1rem, var(--pwa-safe-left));
    padding-right: max(1rem, var(--pwa-safe-right));
}

.navbar .container-fluid {
    padding-left: 0;
    padding-right: 0;
    max-width: 100%;
}

.row {
    margin-left: 0;
    margin-right: 0;
    max-width: 100%;
}

.row > * {
    max-width: 100%;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

.table-responsive:has(.dataTables_wrapper) {
    overflow: visible;
}

.bill-modal {
    padding-left: var(--pwa-safe-left);
    padding-right: var(--pwa-safe-right);
    padding-bottom: var(--pwa-safe-bottom);
}

.bill-notification-bar,
.billing-hero h1,
.billing-card-header h2 {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Standalone PWA (инсталирана апликација) */
@media (display-mode: standalone) {
    .navbar {
        margin-top: 0;
        padding-top: calc(0.75rem + var(--pwa-safe-top));
        position: sticky;
        top: 0;
        z-index: 1030;
    }

    body {
        -webkit-tap-highlight-color: transparent;
    }
}

html.pwa-standalone .navbar {
    margin-top: 0;
    padding-top: calc(0.75rem + var(--pwa-safe-top));
    position: sticky;
    top: 0;
    z-index: 1030;
}

html.pwa-standalone body.billing-body,
html.pwa-standalone body {
    padding-bottom: var(--pwa-safe-bottom);
}

/* Login / auth fullscreen */
html.pwa-standalone .auth-body {
    padding:
        max(24px, var(--pwa-safe-top))
        max(24px, var(--pwa-safe-right))
        max(24px, var(--pwa-safe-bottom))
        max(24px, var(--pwa-safe-left));
    min-height: 100dvh;
    box-sizing: border-box;
}

html.pwa-standalone.login-page body {
    overflow: hidden;
    height: 100dvh;
}

html.pwa-standalone.login-page .container {
    margin-top: 0 !important;
    padding-top: max(10vh, var(--pwa-safe-top));
    max-width: 100%;
    padding-left: var(--pwa-pad-x);
    padding-right: var(--pwa-pad-x);
}

.pwa-location-banner-soft {
    top: max(12px, var(--pwa-safe-top));
    bottom: auto;
}

body.pwa-location-blocked {
    overflow: hidden;
}

.pwa-location-banner {
    position: fixed;
    left: max(12px, var(--pwa-safe-left));
    right: max(12px, var(--pwa-safe-right));
    bottom: max(12px, var(--pwa-safe-bottom));
    z-index: 1040;
    background: #fff;
    border: 1px solid var(--bill-border, #e8ecf3);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.15);
    padding: 14px 16px;
}

.pwa-location-banner-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.pwa-location-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #d4a017, #bb890b);
    color: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.pwa-location-text {
    flex: 1;
    min-width: 160px;
    font-size: 0.88rem;
    line-height: 1.4;
}

.pwa-location-text strong {
    display: block;
    margin-bottom: 2px;
}

.pwa-location-msg {
    color: #64748b;
    font-size: 0.82rem;
}

.pwa-location-modal {
    position: fixed;
    inset: 0;
    z-index: 1060;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(20px, var(--pwa-safe-top)) max(16px, var(--pwa-safe-right)) max(20px, var(--pwa-safe-bottom)) max(16px, var(--pwa-safe-left));
}

.pwa-location-modal-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 20px;
    padding: 28px 24px;
    text-align: center;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.2);
}

.pwa-location-modal-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    border-radius: 18px;
    background: linear-gradient(135deg, #d4a017, #bb890b);
    color: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.pwa-location-modal-card h2 {
    margin: 0 0 10px;
    font-size: 1.25rem;
    font-weight: 800;
}

.pwa-location-modal-desc,
.pwa-location-modal-hint {
    font-size: 0.9rem;
    color: #64748b;
    line-height: 1.55;
    margin: 0 0 16px;
}

.pwa-location-modal-hint {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 12px;
    padding: 12px 14px;
    color: #92400e;
    font-size: 0.85rem;
}

/* PWA нотификации */
body.pwa-notify-blocked {
    overflow: hidden;
}

.pwa-notify-banner {
    position: fixed;
    left: max(12px, var(--pwa-safe-left));
    right: max(12px, var(--pwa-safe-right));
    z-index: 1035;
    background: #fff;
    border: 1px solid var(--bill-border, #e8ecf3);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.15);
    padding: 14px 16px;
}

.pwa-notify-banner-soft {
    top: max(72px, calc(var(--pwa-safe-top) + 56px));
    bottom: auto;
}

.pwa-notify-banner-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.pwa-notify-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.pwa-notify-text {
    flex: 1;
    min-width: 140px;
    font-size: 0.88rem;
    line-height: 1.4;
}

.pwa-notify-text strong {
    display: block;
    margin-bottom: 2px;
}

.pwa-notify-msg {
    color: #64748b;
    font-size: 0.82rem;
}

.pwa-notify-modal {
    position: fixed;
    inset: 0;
    z-index: 1055;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(20px, var(--pwa-safe-top)) max(16px, var(--pwa-safe-right)) max(20px, var(--pwa-safe-bottom)) max(16px, var(--pwa-safe-left));
}

.pwa-notify-modal-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 20px;
    padding: 28px 24px;
    text-align: center;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.2);
}

.pwa-notify-modal-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    border-radius: 18px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.pwa-notify-modal-card h2 {
    margin: 0 0 10px;
    font-size: 1.25rem;
    font-weight: 800;
}

.pwa-notify-modal-desc {
    font-size: 0.9rem;
    color: #64748b;
    line-height: 1.55;
    margin: 0 0 16px;
}

/* PWA инсталација — index.php */
body.pwa-install-open {
    overflow: hidden;
}

.pwa-install-modal {
    position: fixed;
    inset: 0;
    z-index: 1056;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(20px, var(--pwa-safe-top)) max(16px, var(--pwa-safe-right)) max(20px, var(--pwa-safe-bottom)) max(16px, var(--pwa-safe-left));
}

.pwa-install-modal-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: min(90dvh, 640px);
    overflow-y: auto;
    background: #fff;
    border-radius: 20px;
    padding: 28px 24px 24px;
    text-align: left;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.2);
}

.pwa-install-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    border: none;
    background: transparent;
    font-size: 1.6rem;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px 8px;
}

.pwa-install-modal-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    border-radius: 18px;
    background: linear-gradient(135deg, #d4a017, #bb890b);
    color: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.pwa-install-modal-card h2 {
    margin: 0 0 10px;
    font-size: 1.2rem;
    font-weight: 800;
    text-align: center;
    line-height: 1.35;
}

.pwa-install-modal-desc {
    font-size: 0.9rem;
    color: #64748b;
    line-height: 1.55;
    margin: 0 0 18px;
    text-align: center;
}

.pwa-install-steps {
    margin: 0 0 16px;
    padding-left: 1.2rem;
    font-size: 0.9rem;
    color: #334155;
    line-height: 1.55;
}

.pwa-install-steps li {
    margin-bottom: 10px;
}

.pwa-install-steps li:last-child {
    margin-bottom: 0;
}

.pwa-install-hint {
    margin: 0 0 16px;
    padding: 12px 14px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 12px;
    color: #92400e;
    font-size: 0.85rem;
    line-height: 1.45;
}
