/* =====================================================================
 * common_responsive.css - tablet / mobile layout
 * Load AFTER common.css (same position in the cascade as when these
 * rules lived at the end of common.css).
 * ===================================================================== */

/* ===== Login page (login_sys.jsp) - responsive for mobile / tablet ===== */
/* Selectors are prefixed with .login-page because common.css loads before bootstrap.css */
html, body.login-page { min-height: 100%; }
body.login-page { overflow-x: hidden; }
.login-page .login-wrapper { min-height: 100vh; }
.login-page .login-logo { width: 170px; max-width: 100%; padding-bottom: 10px; }
.login-page .login-card-wrap { width: 400px; max-width: 100%; }
.login-page #errorDiv .breadcrumb { max-width: 100%; text-align: left; word-break: break-word; }
.login-page .login-contact { font-size: 0.95rem; }
.login-page .login-contact .contact-line { display: inline-block; }
.login-page .login-contact .contact-line span { margin: 0 .35rem; white-space: nowrap; }

/* Tablets (portrait) and small laptops */
@media (max-width: 991.98px) {
    .login-page .login-wrapper { align-items: center !important; align-content: center !important; }
    .login-page .login-wrapper > .container { padding-top: 2rem; }
}

/* Phones */
@media (max-width: 575.98px) {
    .login-page .login-wrapper > .container { padding-left: 1rem; padding-right: 1rem; }
    .login-page .login-logo { width: 130px; }
    .login-page h4 { font-size: 1.2rem; }
    .login-page h5.mt-5 { margin-top: 1.5rem !important; }

    /* stack login fields full width */
    .login-page .login-form { flex-direction: column; align-items: stretch !important; width: 100%; max-width: 360px; margin: 0 auto; }
    .login-page .login-form .form-group { width: 100%; margin-right: 0 !important; }
    .login-page .login-form .form-group > input,
    .login-page .login-form .btn { width: 100%; }
    .login-page .login-form .btn { padding-top: .6rem; padding-bottom: .6rem; }

    /* 16px inputs stop iOS from zooming on focus */
    .login-page input.form-control,
    .login-page input.form-control-sm { font-size: 16px; }

    .login-page .card-body { padding: 1rem; }
    .login-page .card-body .btn { width: 100%; white-space: normal; }

    .login-page small { display: block; margin-bottom: .35rem; }
    .login-page .login-contact { font-size: 0.85rem; }
    .login-page .login-contact .contact-line { display: block; margin-bottom: .4rem; }
}


/* ===== Main layout (main_template.jsp + menu_template_sys.jsp) - responsive for tablet / mobile ===== */
.left-nav-toggle { display: none; }

/* content next to the left menu (was inline style float:left;width:780px) */
.main-container.with-left-nav { float: left; width: 780px; }

/* small laptops: 780px + 191px menu does not fit, so the content takes the remaining width */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .main-container.with-left-nav { width: calc(100% - 200px); }
}

/* Tablets and phones: menu goes on top, full width, collapsible */
@media (max-width: 991.98px) {
    #navigationLeft {
        float: none;
        display: block;
        width: 100%;
        height: auto !important;          /* overrides height set by resizeGUI() */
        margin: 15px 0 0 0;
        border-right: none;
        background-color: transparent;
    }
    #navigationLeft .left-nav-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: .65rem 1rem;
        border: 0;
        border-radius: 10px;
        background-color: #39b1c1;
        color: #fff;
        font-weight: 600;
        font-size: 1rem;
        cursor: pointer;
    }
    #navigationLeft .left-nav-toggle:focus { outline: 2px solid #2ba2b1; outline-offset: 2px; }
    #navigationLeft .left-nav-toggle-arrow { transition: transform .2s ease; }
    #navigationLeft.nav-open .left-nav-toggle { border-radius: 10px 10px 0 0; }
    #navigationLeft.nav-open .left-nav-toggle-arrow { transform: rotate(180deg); }

    /* collapsed by default; max-height keeps the Ext trees laid out at full width */
    #navigationLeft #menu {
        width: 100%;
        max-height: 0;
        overflow: hidden;
        transition: max-height .3s ease;
        background-color: #fff;
        border-radius: 0 0 10px 10px;
    }
    #navigationLeft.nav-open #menu {
        max-height: 5000px;
        overflow: visible;
        box-shadow: 0 .1rem .7rem rgba(0, 0, 0, .1);
    }

    #navigationLeft #menu .left_logo { display: none; }
    #navigationLeft #menu .ModuleNavigation2ndlevel { border-radius: 0; }

    /* module links: auto height, wrap text, bigger tap targets */
    #navigationLeft #menu .ModuleNavigation2ndlevel .menuItemActiv,
    #navigationLeft #menu .ModuleNavigation2ndlevel .menuItemInactiv {
        height: auto !important;          /* overrides inline height: 50px / 65px */
        min-height: 42px;
        overflow: hidden;                 /* contains the floated link so the row grows with it */
    }
    #navigationLeft #menu .ModuleNavigation2ndlevel .menuItemActiv .menuItemLabelActiv a,
    #navigationLeft #menu .ModuleNavigation2ndlevel .menuItemInactiv .menuItemLabelInactiv a,
    #navigationLeft #menu .ModuleNavigation2ndlevel .menuItemInactiv .menuItemLabelInactiv a:hover {
        padding: 11px 10px 11px 25px;
    }

    #navigationLeft .leftMenuColoured {
        float: none;
        display: block;
        width: 100%;
        height: auto;
        padding-bottom: 10px;
    }
    /* Ext tree labels had fixed pixel widths */
    #navigationLeft #menu .x-tree-node-anchor span { width: auto !important; }
    #navigationLeft #menu .x-tree-node-el { padding-top: 4px; padding-bottom: 4px; }

    /* content below the menu, full width */
    .main-container.with-left-nav { float: none; width: 100%; }
    .main-container { max-width: 100%; }
    .main-container nav .bcPromoc { float: none !important; padding-right: 0 !important; }
}

/* Phones */
@media (max-width: 575.98px) {
    .main-content-area { padding-left: 10px; padding-right: 10px; }
    .main-container { margin-top: 10px; }
    .main-container .breadcrumb { font-size: .9rem; padding: .5rem .75rem; margin-bottom: .5rem; }
}


/* ===== Header (header_sys.jsp) - responsive for tablet / mobile ===== */
#header { position: relative; }

/* the generic max-width:768px .navbar-collapse rule also hit 768px, where the navbar is already expanded */
@media (min-width: 768px) {
    #header .navbar-collapse,
    #subMenu .navbar-collapse {
        position: static;
        width: auto;
        padding: 0;
        left: auto;
        top: auto;
    }
}

/* Tablets: logo + buttons on the first row, search full width below */
@media (min-width: 768px) and (max-width: 991.98px) {
    #header .header-actions { flex: 1 1 0; max-width: none; }
    #header .header-actions .navbar-collapse { flex-wrap: wrap; justify-content: flex-end; }
    #header .header-actions .btn { margin-bottom: 4px; }
    #header .header-search { margin-top: 6px; margin-bottom: 4px; }
}

/* Phones: logo | client + hamburger, search below, menu opens as a full-width panel */
@media (max-width: 767.98px) {
    #header { padding-left: 10px; padding-right: 10px; }
    #header .navbar { padding: .4rem 0; }
    #header .navbar > .container > .row { margin: 0; align-items: center; }

    #header .header-logo { flex: 0 0 auto; max-width: 45%; padding: 0 !important; text-align: left; }
    #header .header-logo .logoTop { max-width: 130px; float: none; }

    #header .header-actions {
        position: static;                 /* menu panel positions against the whole navbar */
        flex: 1 1 0;
        max-width: none;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        min-width: 0;
    }
    #header .header-client {
        flex: 0 1 auto;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: .85rem;
        margin-right: 6px;
    }

    #header .navbar-toggler,
    #subMenu .navbar-toggler {
        flex: 0 0 auto;
        width: 42px;
        height: 38px;
        padding: 0;
        border: 1px solid rgba(0, 0, 0, .15);
        border-radius: 6px;
        font-size: 1.15rem;
        color: #333;
    }
    #subMenu .navbar-toggler { color: #fff; border-color: rgba(255, 255, 255, .3); }

    #header .header-search {
        flex: 0 0 100%;
        max-width: 100%;
        padding: 0;
        margin-top: 8px;
    }

    /* dropdown panel with stacked buttons */
    #header .navbar-collapse,
    #subMenu .navbar-collapse {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        width: 100%;
        min-height: 0 !important;
        padding: 10px 15px 12px;
        background-color: #fff;
        box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .15);
        z-index: 1035;
        transition: none;
    }
    #header .navbar-collapse.collapsing,
    #subMenu .navbar-collapse.collapsing { left: 0; }
    #subMenu .navbar-collapse { background-color: #343a40; }

    #header .navbar-collapse .btn,
    #subMenu .navbar-collapse .btn {
        display: block;
        width: 100%;
        max-width: none;
        margin: 0 0 6px 0 !important;
        padding: .6rem .9rem;
        font-size: 1rem;
        text-align: left;
    }
    #header .navbar-collapse .bookBckg,
    #subMenu .navbar-collapse .bookBckg {
        background-position: 10px center;
        padding-left: 40px;
    }

    /* dark bar shown after scrolling */
    #subMenu { padding-left: 10px; padding-right: 10px; }
    #subMenu .navbar { padding-top: .35rem; padding-bottom: .35rem; }
    #subMenu .navbar > .container { flex-wrap: nowrap; }
    #subMenu .logo1 img { width: auto !important; max-width: 150px !important; max-height: 34px; }
}


/* ===== Product list (productsListV3.js, classic view) - info / edit / delete buttons on tablet & mobile ===== */
.prod-admin-actions .btn-prod-label { display: none; }

@media (max-width: 991.98px) {
    .product .prod-admin-actions {
        display: flex;
        flex: 0 0 100%;
        max-width: 100%;
        gap: 6px;
        padding: 0 10px 10px;
    }
    .product .prod-admin-actions .btn-prod-action {
        display: flex;
        align-items: center;
        justify-content: center;
        flex: 1 1 0;
        max-width: none;
        min-height: 42px;
        padding: 6px 8px !important;
        background-color: #fff;
        border: 1px solid #cfd8e3;
        border-radius: 8px;
        font-size: .82rem;
        line-height: 1.15;
        text-decoration: none;
        white-space: normal;
    }
    .product .prod-admin-actions .btn-prod-action i { flex: 0 0 auto; font-size: 1rem; }
    .product .prod-admin-actions .btn-prod-label { display: inline; margin-left: 6px; text-align: left; }
    .product .prod-admin-actions .btn-prod-action:active,
    .product .prod-admin-actions .btn-prod-action:focus { background-color: #eef4fb; box-shadow: none; }

    .product .prod-admin-actions .btn-prod-delete { color: #c82333 !important; border-color: #f1b0b7; }
    .product .prod-admin-actions .btn-prod-delete:active,
    .product .prod-admin-actions .btn-prod-delete:focus { background-color: #fdecee; }
}

/* Tablets: narrow price column -> buttons stacked, full width */
@media (min-width: 768px) and (max-width: 991.98px) {
    /* let the price column grow with the stacked buttons instead of overflowing the card */
    .products-list .card .action-wrap.has-admin-actions { position: static !important; height: auto !important; }
    .product .prod-admin-actions { flex-direction: column; }
    .product .prod-admin-actions .btn-prod-action { flex: 0 0 auto; justify-content: flex-start; }
}

/* Phones: one row, the info button (long label) gets more room */
@media (max-width: 767.98px) {
    .product .prod-admin-actions { padding: 0 12px 12px; }
    .product .prod-admin-actions .btn-prod-info { flex-grow: 2; }
}


/* ===== Shopping cart (shopping_cart/edit_cart_all.jsp) - responsive for tablet / mobile ===== */
@media (max-width: 991.98px) {
    /* bigger touch targets for delete / product info icons */
    .edit-cart-page .cart-table .cart-actions i {
        display: inline-block;
        padding: 10px;
        font-size: 1.1rem;
    }
    /* quantity: readable input + bigger recalculate button (was forced to 14px wide) */
    .edit-cart-page .cart-table .cantitate-cart-wrapper { height: auto; flex-wrap: nowrap; }
    .edit-cart-page .cart-table .cantitate-cart {
        flex: 0 0 60px;
        width: 60px !important;
        height: 36px !important;
        font-size: 16px;
        text-align: center;
    }
    .edit-cart-page .cart-table .cantitate-cart + .input-group-append .input-group-text { padding: 0 12px; }
    .edit-cart-page .cart-table .cantitate-cart + .input-group-append i { font-size: 14px; }

    /* transport conditions label had ml-4 inside a negative-margin .row */
    .edit-cart-page .cart-logistics .form-group.row { margin-left: 0; margin-right: 0; }
    .edit-cart-page .cart-logistics label.row { margin-left: 0 !important; margin-right: 0; }

    /* amounts stay on one line */
    .edit-cart-page .cart-table .cart-cell-price > span:first-child,
    .edit-cart-page .cart-table .cart-cell-total > span:first-child,
    .edit-cart-page .cart-table tr.cart-summary-row strong,
    .edit-cart-page .jumbotron td.text-right { white-space: nowrap; }
    .edit-cart-page .cart-table td.colQtyPrice { max-width: none; }

    /* "other options" card: label above field instead of a cramped inline form */
    .edit-cart-page .cart-other-options .form-inline { display: block; }
    .edit-cart-page .cart-other-options .form-inline > label,
    .edit-cart-page .cart-other-options .form-inline > input,
    .edit-cart-page .cart-other-options .form-inline > .input-group {
        display: flex;
        width: 100% !important;
        max-width: 100%;
        padding-left: 0 !important;
        padding-right: 0;
        margin-bottom: 6px;
    }

    /* bottom buttons: order buttons on their own line, wrapping nicely */
    .cart-bottom-actions .row { flex-wrap: wrap; }
    .cart-bottom-actions .order-button-wrapper {
        flex: 0 0 100%;
        max-width: 100%;
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 6px;
        margin-top: 8px;
    }
    .cart-bottom-actions .order-button { margin-right: 0 !important; padding: .45rem .8rem; }
}

/* Tablets: keep the table, smaller picture column */
@media (min-width: 768px) and (max-width: 991.98px) {
    .edit-cart-page .cart-table .cart-cell-product > div:first-child { width: 22%; padding-left: 0; }
    .edit-cart-page .cart-table .cart-cell-product > div:nth-child(2) { width: 78%; }
    .edit-cart-page .cart-table td,
    .edit-cart-page .cart-table th { padding: .6rem .4rem; }
}

/* Phones: every product becomes a card */
@media (max-width: 767.98px) {
    .progress-tabs-cart.cart-steps > .row {
        width: 100% !important;
        margin-left: 0 !important;
        padding: 2px 34px 0 !important;
    }
    .progress-tabs-cart.cart-steps .badge { white-space: normal; }

    .edit-cart-page .section { padding: 10px !important; }

    .edit-cart-page .cart-table,
    .edit-cart-page .cart-table > tbody { display: block; width: 100%; }
    .edit-cart-page .cart-table > thead { display: none; }

    .edit-cart-page .cart-table tr.cart-item {
        display: block;
        margin: 0 0 12px 0;
        padding: 10px 12px;
        background-color: #fff;
        border: 1px solid #e1e5ea;
        border-radius: 8px;
    }
    .edit-cart-page .cart-table tr.cart-item > td {
        display: grid;
        grid-template-columns: auto 1fr;
        column-gap: 12px;
        align-items: center;
        width: 100%;
        max-width: none;
        padding: 8px 0;
        border-top: 1px solid #eef0f3;
        text-align: right;
    }
    .edit-cart-page .cart-table tr.cart-item > td::before {
        content: attr(data-label);
        grid-column: 1;
        grid-row: 1 / span 6;
        align-self: start;
        padding-top: 2px;
        text-align: left;
        font-weight: 600;
        color: #6c757d;
    }
    .edit-cart-page .cart-table tr.cart-item > td > * { grid-column: 2; justify-self: end; }
    .edit-cart-page .cart-table tr.cart-item > td > br { display: none; }
    .edit-cart-page .cart-table tr.cart-item > td .mt-sm-3 { margin-top: 2px !important; }

    /* product: picture + name */
    .edit-cart-page .cart-table tr.cart-item > td.cart-cell-product {
        display: block;
        border-top: 0;
        padding-top: 0;
        text-align: left;
        overflow: hidden;
    }
    .edit-cart-page .cart-table td.cart-cell-product::before { display: none; }
    .edit-cart-page .cart-table td.cart-cell-product > div:first-child {
        width: 84px;
        max-width: 84px;
        padding: 0 10px 0 0;
    }
    .edit-cart-page .cart-table td.cart-cell-product > div:nth-child(2) {
        width: calc(100% - 84px);
        min-height: 0 !important;
        padding: 0;
    }
    .edit-cart-page .cart-table td.cart-cell-product span[style*="absolute"] {
        position: static !important;
        display: block;
        margin-top: 4px;
    }

    .edit-cart-page .cart-table td.cart-cell-qty .input-group { width: auto; }

    /* actions: right aligned bordered buttons */
    .edit-cart-page .cart-table tr.cart-item > td.cart-actions {
        display: flex;
        justify-content: flex-end;
        gap: 8px;
        padding-bottom: 0;
    }
    .edit-cart-page .cart-table tr.cart-item > td.cart-actions::before { display: none; }
    .edit-cart-page .cart-table td.cart-actions i {
        padding: 10px 14px;
        border: 1px solid #cfd8e3;
        border-radius: 8px;
        background-color: #fff;
    }
    .edit-cart-page .cart-table td.cart-actions i.fa-trash-alt { color: #c82333 !important; border-color: #f1b0b7; }

    /* subtotal / exchange-rate / vouchers rows */
    .edit-cart-page .cart-table tr.cart-summary-row { display: flex; flex-wrap: wrap; width: 100%; }
    .edit-cart-page .cart-table tr.cart-summary-row > td {
        display: block;
        flex: 1 1 auto;
        border-top: 0;
        padding: 8px 10px;
    }
    .edit-cart-page .cart-table tr.cart-summary-row > td.colQtyPrice { max-width: none; text-align: right; }
    .edit-cart-page .cart-table tr.cart-summary-row > td.cart-spacer,
    .edit-cart-page .cart-table tr.cart-summary-row > td.cart-vouchers-none { display: none; }
    .edit-cart-page .cart-table tr.cart-summary-row > td.cart-vouchers { flex: 0 0 100%; }
    .edit-cart-page .cart-table .table_inner { width: 100%; }

    /* totals box */
    .edit-cart-page .jumbotron { padding: 12px 10px !important; }

    /* addresses / options */
    .edit-cart-page #addressD_id { font-size: 14px !important; }

    /* bottom buttons: full width, "Comanda" first, continue shopping last */
    .cart-bottom-actions .row { flex-direction: column-reverse; margin: 0; }
    .cart-bottom-actions .row > .col { flex: 0 0 100%; max-width: 100%; }
    .cart-bottom-actions .order-button-wrapper { flex-direction: column-reverse; margin: 0 0 8px 0; }
    .cart-bottom-actions .btn {
        display: block;
        width: 100%;
        padding: .65rem .9rem;
        font-size: 1rem;
    }
}


/* ===== Header admin mega-menu ("Setari" popover, built in UserMenu.getUserMenuAdminFormat) ===== */
/* the popover gets an inline width of 200px per section, max-width wins over it */
@media (max-width: 991.98px) {
    .popover.popover-megamenu { max-width: calc(100vw - 16px) !important; }
    .popover.popover-megamenu .popover-content {
        max-height: 70vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
}

/* Phones: compact accordion - only section titles visible, tap one to open its links */
@media (max-width: 767.98px) {
    /* Administrare goes last in the header panel, so its menu never covers the other buttons */
    #header .navbar-collapse.show,
    #header .navbar-collapse.collapsing { display: flex; flex-direction: column; }
    #header .navbar-collapse .popover-megamenu-btn { order: 10; }
    .popover.popover-megamenu .popover-content { max-height: 60vh; padding: 4px 8px 8px !important; }
    .popover.popover-megamenu .popover-content > .row > div {
        flex: 0 0 100%;
        max-width: 100%;
        padding: 0;
    }
    .popover.popover-megamenu h5 {
        position: relative;
        margin: 0 !important;
        padding: 12px 30px 12px 6px;
        font-size: 1rem;
        border-bottom: 1px solid #e9ecef;
        cursor: pointer;
        user-select: none;
    }
    .popover.popover-megamenu h5::after {
        content: "\f078";                 /* chevron-down */
        font-family: "Font Awesome 5 Free";
        font-weight: 900;
        font-size: .75rem;
        position: absolute;
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
        transition: transform .2s ease;
        color: #6c757d;
    }
    .popover.popover-megamenu .mm-open > h5::after { transform: translateY(-50%) rotate(180deg); }
    .popover.popover-megamenu .mm-open > h5 { color: #0e74bc; }

    .popover.popover-megamenu .settings-menu { display: none; }
    .popover.popover-megamenu .mm-open > .settings-menu { display: block; padding: 2px 0 6px 10px; }
    .popover.popover-megamenu .settings-menu li a {
        min-height: 40px;
        padding: 11px 6px !important;
        line-height: 18px;
    }
}


/* ===== Home page (home_page.jsp) - teasers / banners on tablet & mobile ===== */
/* teaser backgrounds come inline from TeaserManager ("background: url(...)") and common.css uses
   background-size: cover with a fixed min-height, which crops wide banners on small screens.
   home_page.jsp sets --teaser-ratio (image width / height) + .has-bg-ratio once the image is loaded. */
@media (max-width: 991.98px) {
    .oferte .oferta .media.has-bg-ratio {
        aspect-ratio: var(--teaser-ratio);
        min-height: 0 !important;
        height: auto;
        background-size: contain !important;
        background-repeat: no-repeat !important;
        background-position: center top !important;
    }
    .oferte .oferta-tot,
    .oferte .twoRowLeft,
    .oferte .twoRowRight { min-height: 0; }
}

@media (max-width: 767.98px) {
    .home-banner h3 { font-size: 1.35rem; }
    .home-intro h3 { font-size: 1.15rem; line-height: 1.35; }
    .home-intro h5 { font-size: .95rem; }
    .main-page .oferte { padding-left: 6px !important; padding-right: 6px !important; }
    .oferte .oferta .media { margin-left: 0 !important; margin-right: 0 !important; }
}
