/*
 * ASHOKA - app shell pieces shared by many pages
 *   1. Phone / tablet bottom menu      (templates/layout.html, block mobile_bottom_nav)
 *   2. Billing pay bar + shortcut keys (templates/sales/new_sale.html)
 *   3. Sign-in / password / OTP pages  (templates/unified_auth/_auth_layout.html)
 * Colours come from the .theme-fashion tokens in style.css.
 */

/* ============================== 0. Page width fix ============================== */
/* The decorative colour blob (.app-frame::before, inset -60px) stuck out past the right
   edge, making every page 60px wider than a phone screen: pages scrolled sideways and
   fixed bars sat partly off-screen. "clip" (unlike "hidden") does not create a scroll
   container, so the sticky top menu keeps working. */
.theme-fashion .app-frame {
    overflow-x: clip;
}

/* ============================== 1. Bottom menu ============================== */
.app-bottom-nav {
    position: fixed;
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(0.6rem + env(safe-area-inset-bottom, 0px));
    z-index: 1030;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    gap: 0.25rem;
    padding: 0.35rem 0.4rem;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.74));
    backdrop-filter: blur(18px) saturate(170%);
    -webkit-backdrop-filter: blur(18px) saturate(170%);
    box-shadow: 0 14px 34px rgba(2, 8, 23, 0.18);
    animation: app-rise 0.4s ease-out backwards;
}
.app-bottom-nav-spacer {
    height: calc(84px + env(safe-area-inset-bottom, 0px));
}
.app-bottom-nav-item {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    padding: 0.35rem 0.2rem;
    border: 0;
    border-radius: 16px;
    background: transparent;
    color: rgba(11, 18, 32, 0.62);
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.1;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.2s ease, background-color 0.2s ease, transform 0.15s ease;
}
.app-bottom-nav-item i {
    font-size: 1.15rem;
    line-height: 1;
}
.app-bottom-nav-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.app-bottom-nav-item:hover,
.app-bottom-nav-item:focus-visible {
    color: #0b1220;
    background: rgba(11, 18, 32, 0.05);
}
.app-bottom-nav-item:active {
    transform: scale(0.94);
}
.app-bottom-nav-item.active {
    color: #0b1220;
    background: rgba(247, 223, 76, 0.35);
}
.app-bottom-nav-item.active i {
    animation: app-nav-bounce 0.45s ease;
}
/* The raised yellow "New bill" button in the middle */
.app-bottom-nav-primary {
    color: #0b1220;
}
.app-bottom-nav-primary.active {
    background: transparent;
}
.app-bottom-nav-fab {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    margin-top: -1.35rem;
    border-radius: 50%;
    background: linear-gradient(145deg, #ffe873, var(--fx-accent, #f7df4c) 55%, #f0c419);
    box-shadow: 0 10px 22px rgba(240, 196, 25, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.7);
    border: 3px solid #fff;
}
.app-bottom-nav-fab i {
    font-size: 1.1rem;
}
@keyframes app-nav-bounce {
    0% { transform: translateY(0); }
    40% { transform: translateY(-4px); }
    100% { transform: translateY(0); }
}
/* Opened from the bottom "Menu" button: the collapsed top menu becomes a scrollable sheet */
@media (max-width: 991.98px) {
    .app-navbar .navbar-collapse.show,
    .app-navbar .navbar-collapse.collapsing {
        max-height: calc(100vh - 170px);
        overflow-y: auto;
    }
    /* In the opened phone menu there is room for words: show them next to the icons */
    .theme-fashion .app-navbar .navbar-collapse .app-nav-icon .app-nav-label {
        max-width: 12rem;
        opacity: 1;
        transform: none;
    }
    .theme-fashion .app-navbar .navbar-collapse .app-nav-icon {
        justify-content: flex-start;
    }
    /* Toasts must not sit under the bottom menu on small screens */
    #app-toasts {
        top: auto !important;
        bottom: calc(96px + env(safe-area-inset-bottom, 0px));
        right: 0;
        left: 0;
        margin: 0 auto;
    }
}

/* ============================== 2. Billing pay bar ============================== */
.pos-paybar-spacer {
    height: calc(96px + env(safe-area-inset-bottom, 0px));
}
.pos-paybar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(255, 255, 255, 0.85);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.96));
    backdrop-filter: blur(20px) saturate(170%);
    -webkit-backdrop-filter: blur(20px) saturate(170%);
    box-shadow: 0 -12px 32px rgba(2, 8, 23, 0.14);
    animation: pos-paybar-in 0.4s ease-out backwards;
}
.pos-paybar-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: 1600px;
    margin: 0 auto;
}
.pos-paybar-count {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}
.pos-paybar-count-badge {
    display: grid;
    place-items: center;
    min-width: 44px;
    height: 44px;
    padding: 0 0.5rem;
    border-radius: 14px;
    background: rgba(11, 18, 32, 0.06);
    font-weight: 800;
    font-size: 1.1rem;
    font-variant-numeric: tabular-nums;
}
.pos-paybar-count-label {
    font-size: 0.78rem;
    line-height: 1.2;
    color: rgba(11, 18, 32, 0.6);
    font-weight: 600;
}
.pos-paybar-keys {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.8rem;
    font-size: 0.74rem;
    color: rgba(11, 18, 32, 0.58);
}
.pos-paybar-keys kbd {
    display: inline-block;
    min-width: 1.6em;
    padding: 0.1em 0.45em;
    margin-right: 0.25em;
    border-radius: 6px;
    border: 1px solid rgba(11, 18, 32, 0.15);
    border-bottom-width: 2px;
    background: #fff;
    color: #0b1220;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    text-align: center;
    box-shadow: none;
}
.pos-paybar-total {
    margin-left: auto;
    text-align: right;
    line-height: 1.1;
}
.pos-paybar-total-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(11, 18, 32, 0.55);
}
.pos-paybar-amount {
    display: inline-block;
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    color: #0b1220;
}
.pos-paybar-amount.is-bumped {
    animation: pos-amount-bump 0.35s ease;
}
.pos-paybar-roundoff {
    font-size: 0.72rem;
    color: rgba(11, 18, 32, 0.55);
}
.pos-paybar-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.8rem 1.4rem;
    border-radius: 16px;
    font-size: 1.05rem;
    font-weight: 800;
    white-space: nowrap;
    box-shadow: 0 10px 22px rgba(25, 135, 84, 0.32);
}
.pos-paybar-btn kbd {
    padding: 0.1em 0.4em;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.22);
    color: inherit;
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 700;
    box-shadow: none;
}
.pos-paybar-btn:disabled {
    box-shadow: none;
}
.pos-paybar.is-empty .pos-paybar-btn {
    opacity: 0.55;
}
/* Short "found it" flash on the scanner box when F2 moves focus there */
.pos-focus-flash {
    animation: pos-focus-flash 0.8s ease;
}
@keyframes pos-paybar-in {
    from { transform: translateY(100%); }
    to { transform: none; }
}
@keyframes pos-amount-bump {
    0% { transform: scale(1); }
    40% { transform: scale(1.08); color: #198754; }
    100% { transform: scale(1); }
}
@keyframes pos-focus-flash {
    0% { box-shadow: 0 0 0 0 rgba(247, 223, 76, 0.9); }
    100% { box-shadow: 0 0 0 10px rgba(247, 223, 76, 0); }
}
@media (max-width: 767.98px) {
    .pos-paybar { padding-left: 0.75rem; padding-right: 0.75rem; }
    .pos-paybar-inner { gap: 0.6rem; }
    .pos-paybar-keys,
    .pos-paybar-count-label,
    .pos-paybar-btn kbd { display: none; }
    .pos-paybar-count-badge { min-width: 38px; height: 38px; font-size: 0.95rem; }
    .pos-paybar-amount { font-size: 1.45rem; }
    .pos-paybar-btn { padding: 0.7rem 1rem; font-size: 0.95rem; }
}
@media (max-width: 991.98px) {
    /* Toast position when the pay bar owns the bottom edge */
    body.has-pos-paybar #app-toasts {
        bottom: calc(92px + env(safe-area-inset-bottom, 0px));
    }
}

/* ============================== 3. Sign-in / password / OTP ============================== */
.auth-page .app-frame > .container-fluid.my-4 {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}
.auth-page .app-frame > .container-fluid.my-4 > .row > .col-12 > .d-flex.mb-4:first-child {
    display: none !important;   /* empty page-title row */
}
.auth-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 2rem 0.5rem calc(2rem + env(safe-area-inset-bottom, 0px));
    position: relative;
}
/* Soft moving colour blobs behind the card */
.auth-shell::before,
.auth-shell::after {
    content: "";
    position: fixed;
    z-index: -1;
    width: 46vmax;
    height: 46vmax;
    border-radius: 50%;
    filter: blur(70px);
    opacity: 0.55;
    pointer-events: none;
}
.auth-shell::before {
    top: -14vmax;
    left: -12vmax;
    background: radial-gradient(circle at 30% 30%, rgba(247, 223, 76, 0.9), rgba(247, 223, 76, 0));
    animation: auth-float-a 16s ease-in-out infinite alternate;
}
.auth-shell::after {
    bottom: -16vmax;
    right: -12vmax;
    background: radial-gradient(circle at 60% 60%, rgba(96, 165, 250, 0.6), rgba(96, 165, 250, 0));
    animation: auth-float-b 19s ease-in-out infinite alternate;
}
.auth-card {
    width: 100%;
    max-width: 460px;
    padding: 2.25rem 2rem;
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.85);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.62));
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    box-shadow: 0 30px 70px rgba(2, 8, 23, 0.16);
    animation: app-pop 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.15) backwards;
}
.auth-card.auth-card-wide {
    max-width: 960px;
    padding: 0;
    overflow: hidden;
}
.auth-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 1.25rem;
}
.auth-brand img {
    height: 52px;
    width: auto;
}
.auth-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    border-radius: 20px;
    display: grid;
    place-items: center;
    font-size: 1.6rem;
    color: #0b1220;
    background: linear-gradient(145deg, #fff3a6, var(--fx-accent, #f7df4c));
    box-shadow: 0 12px 26px rgba(240, 196, 25, 0.35);
    animation: auth-icon-float 3.2s ease-in-out infinite;
}
.auth-icon.is-success {
    color: #fff;
    background: linear-gradient(145deg, #34d399, #198754);
    box-shadow: 0 12px 26px rgba(25, 135, 84, 0.35);
}
.auth-title {
    text-align: center;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 0.35rem;
}
.auth-subtitle {
    text-align: center;
    color: rgba(11, 18, 32, 0.6);
    font-size: 0.93rem;
    margin-bottom: 1.5rem;
}
.auth-card .form-label {
    font-weight: 700;
    font-size: 0.88rem;
}
.auth-card .form-control,
.auth-card .input-group-text {
    min-height: 48px;
    border-radius: 14px;
    border-color: rgba(11, 18, 32, 0.12);
    background-color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
}
.auth-card .input-group > .input-group-text {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    color: rgba(11, 18, 32, 0.45);
    min-width: 46px;
    justify-content: center;
}
.auth-card .input-group > .form-control {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}
.auth-card .input-group > .form-control:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}
.auth-card .input-group > .btn {
    border-radius: 0 14px 14px 0;
    border-color: rgba(11, 18, 32, 0.12);
}
.auth-card .form-control:focus {
    border-color: #f0c419;
    box-shadow: 0 0 0 0.22rem rgba(247, 223, 76, 0.35);
}
.auth-card .btn-lg {
    min-height: 52px;
    border-radius: 16px;
    font-weight: 800;
}
.auth-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1.25rem;
    margin-top: 1.5rem;
    font-size: 0.9rem;
}
.auth-links a {
    color: rgba(11, 18, 32, 0.72);
    font-weight: 600;
    text-decoration: none;
}
.auth-links a:hover {
    color: #0b1220;
    text-decoration: underline;
}
.auth-footer {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.78rem;
    color: rgba(11, 18, 32, 0.5);
}
/* OTP box */
.auth-card .otp-input {
    text-align: center;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 0.6em;
    padding-left: 0.6em;
    font-variant-numeric: tabular-nums;
}
.auth-card .otp-input.is-complete {
    border-color: #198754;
    box-shadow: 0 0 0 0.22rem rgba(25, 135, 84, 0.2);
}
.auth-timer {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    background: rgba(11, 18, 32, 0.05);
    font-size: 0.85rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: rgba(11, 18, 32, 0.7);
}
.auth-timer.is-expired {
    background: rgba(220, 53, 69, 0.1);
    color: #b02a37;
}
.auth-link-btn {
    border: 0;
    background: none;
    padding: 0;
    color: rgba(11, 18, 32, 0.8);
    font-weight: 700;
    text-decoration: underline;
}
.auth-link-btn:disabled {
    color: rgba(11, 18, 32, 0.4);
    text-decoration: none;
    cursor: not-allowed;
}
/* Password strength meter */
.auth-strength {
    margin-top: 0.5rem;
}
.auth-strength-bar {
    height: 6px;
    border-radius: 999px;
    background: rgba(11, 18, 32, 0.08);
    overflow: hidden;
}
.auth-strength-bar > span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    transition: width 0.3s ease, background-color 0.3s ease;
}
.auth-strength.weak .auth-strength-bar > span { width: 33%; background: #dc3545; }
.auth-strength.medium .auth-strength-bar > span { width: 66%; background: #f0ad00; }
.auth-strength.strong .auth-strength-bar > span { width: 100%; background: #198754; }
.auth-strength-text {
    margin-top: 0.3rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(11, 18, 32, 0.6);
}
/* Login page: two-column card */
.auth-side {
    position: relative;
    height: 100%;
    padding: 3rem 2.5rem;
    background:
        radial-gradient(520px 320px at 10% 0%, rgba(247, 223, 76, 0.55), transparent 65%),
        radial-gradient(480px 360px at 100% 100%, rgba(96, 165, 250, 0.35), transparent 60%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.2));
    overflow: hidden;
}
.auth-side h2 {
    font-weight: 800;
    letter-spacing: -0.035em;
    line-height: 1.15;
}
.auth-feature {
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
    padding: 0.9rem 1rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 8px 20px rgba(2, 8, 23, 0.06);
    animation: app-rise 0.5s ease-out backwards;
}
.auth-feature:nth-child(2) { animation-delay: 0.08s; }
.auth-feature:nth-child(3) { animation-delay: 0.16s; }
.auth-feature-icon {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: rgba(247, 223, 76, 0.45);
    color: #0b1220;
}
.auth-form-side {
    padding: 2.75rem 2.5rem;
}
@media (max-width: 575.98px) {
    .auth-card { padding: 1.75rem 1.25rem; border-radius: 24px; }
    .auth-form-side { padding: 1.75rem 1.25rem; }
}
/* Account picker (several logins on one mobile number) */
.account-card {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.9rem 1rem;
    margin-bottom: 0.7rem;
    border-radius: 18px;
    border: 2px solid rgba(11, 18, 32, 0.08);
    background: rgba(255, 255, 255, 0.75);
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    animation: app-rise 0.4s ease-out backwards;
}
.account-card:nth-child(3) { animation-delay: 0.05s; }
.account-card:nth-child(4) { animation-delay: 0.10s; }
.account-card:nth-child(n+5) { animation-delay: 0.15s; }
.account-card:hover {
    transform: translateY(-1px);
    border-color: rgba(240, 196, 25, 0.6);
}
.account-card.selected {
    border-color: #f0c419;
    background: rgba(255, 249, 214, 0.9);
    box-shadow: 0 0 0 4px rgba(247, 223, 76, 0.25);
}
.account-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.account-icon {
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 1.15rem;
}
.account-icon.super-admin { background: #fff3cd; color: #856404; }
.account-icon.brand-admin { background: #d1ecf1; color: #0c5460; }
.account-icon.branch-user { background: #d4edda; color: #155724; }
.account-info { flex: 1; min-width: 0; }
.account-name { font-weight: 800; color: #0b1220; }
.account-role { font-size: 0.82rem; color: rgba(11, 18, 32, 0.65); margin-top: 2px; }
.account-branch { font-size: 0.78rem; color: rgba(11, 18, 32, 0.55); margin-top: 2px; }
.check-circle {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    border: 2px solid rgba(11, 18, 32, 0.2);
    color: transparent;
    font-size: 0.7rem;
    transition: all 0.2s ease;
}
.account-card.selected .check-circle {
    border-color: #198754;
    background: #198754;
    color: #fff;
    transform: scale(1.08);
}
/* Recovered User ID */
.userid-display {
    margin: 1.25rem 0;
    padding: 1.25rem;
    border-radius: 20px;
    text-align: center;
    background: linear-gradient(145deg, rgba(255, 249, 214, 0.95), rgba(247, 223, 76, 0.4));
    border: 1px solid rgba(240, 196, 25, 0.55);
}
.userid-display .userid-value {
    margin: 0.4rem 0;
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    word-break: break-all;
    color: #0b1220;
}
.change-id-section {
    margin-top: 1.25rem;
    padding: 1.25rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(11, 18, 32, 0.08);
}
@keyframes auth-float-a {
    from { transform: translate(0, 0) scale(1); }
    to { transform: translate(8vmax, 6vmax) scale(1.12); }
}
@keyframes auth-float-b {
    from { transform: translate(0, 0) scale(1.05); }
    to { transform: translate(-7vmax, -5vmax) scale(0.95); }
}
@keyframes auth-icon-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* ============================== Reduced motion ============================== */
@media (prefers-reduced-motion: reduce) {
    .app-bottom-nav,
    .app-bottom-nav-item.active i,
    .pos-paybar,
    .pos-paybar-amount.is-bumped,
    .pos-focus-flash,
    .auth-shell::before,
    .auth-shell::after,
    .auth-card,
    .auth-icon,
    .auth-feature,
    .account-card {
        animation: none !important;
    }
    .app-bottom-nav-item,
    .account-card,
    .auth-strength-bar > span {
        transition: none !important;
    }
}
