/* =========================================================
   AVNERI ORDER WIZARD - MOBILE / RESPONSIVE OVERRIDES
   ---------------------------------------------------------
   Load this file AFTER:
   OrderWizardNew.css
   wizardStyleNewAdd.css
   wizardStyleNewAdd2.css

   No HTML structure or JavaScript logic is changed.
   ========================================================= */


/* ---------------------------------------------------------
   GLOBAL SAFETY
   --------------------------------------------------------- */

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

img,
svg,
video {
    max-width: 100%;
}

.app,
.app main,
.page,
.page-grid,
.form-card,
.preview-card,
.grid,
.models {
    min-width: 0;
}


/* ---------------------------------------------------------
   TABLET / MOBILE
   --------------------------------------------------------- */

@media (max-width: 900px) {

    /* ---------- Main wrapper ---------- */

    .app {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 auto !important;
        padding: 8px 10px 20px !important;
        overflow: hidden;
    }

    main {
        width: 100%;
        max-width: 100%;
    }

    .page {
        width: 100%;
        max-width: 100%;
        margin: 0 !important;
        padding: 14px 4px 24px !important;
    }

    .page h2 {
        font-size: 1.35rem !important;
        line-height: 1.35;
        margin: 10px 0 16px !important;
    }


    /* ---------- Banner ---------- */

    .banner-outer,
    .content-container {
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }

    .banner-content-img {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: none !important;
        object-fit: cover;
        display: block;
    }

    .wizard-brand-banner {
        width: 100% !important;
        max-width: 100% !important;
        min-height: 150px !important;
        padding: 14px 18px !important;
        margin-bottom: 8px !important;
        border-radius: 0 0 18px 18px !important;
        overflow: hidden !important;
    }

    .wizard-brand-content {
        min-width: 0;
    }

    .wizard-logo {
        max-width: 200px !important;
        height: auto !important;
    }

    .wizard-hero-book {
        max-width: 38vw;
        margin-left: 0 !important;
    }


    /* ---------- Progress bar ---------- */

    .topbar {
        width: 100% !important;
        max-width: 100% !important;
        margin: 6px 0 12px !important;
        padding: 7px 38px 7px 0 !important;
        gap: 4px !important;
        overflow: hidden;
    }

    .wizard-home-button {
        right: 3px !important;
        width: 30px !important;
        height: 30px !important;
        font-size: 16px !important;
    }

    #stepsBar.steps {
        width: 100%;
        min-width: 0;
        gap: 3px !important;
        flex-wrap: nowrap !important;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        padding: 2px 2px 5px;
    }

    #stepsBar.steps::-webkit-scrollbar {
        display: none;
    }

    #stepsBar .step {
        flex: 0 0 auto;
        min-width: 42px;
        gap: 3px !important;
        flex-direction: column;
        justify-content: center;
        text-align: center;
    }

    #stepsBar .step .bullet,
    #stepsBar .bullet {
        width: 24px !important;
        height: 24px !important;
        min-width: 24px !important;
        min-height: 24px !important;
        line-height: 24px !important;
        font-size: 11px !important;
        box-shadow: none !important;
    }

    #stepsBar .step .label {
        width: 48px;
        max-width: 48px;
        white-space: normal;
        font-size: 9px !important;
        line-height: 1.15;
        text-align: center;
    }

    #stepsBar .connector {
        flex: 0 0 14px !important;
        width: 14px !important;
        min-width: 14px !important;
        height: 4px !important;
        margin-top: -15px;
    }


    /* ---------- Page 1 ---------- */

    #page1 {
        width: 100%;
        padding: 12px 2px 25px !important;
    }

    .page1-heading {
        margin: 8px 0 16px !important;
        padding: 0 8px;
    }

    .page1-heading h2 {
        font-size: 1.35rem !important;
        line-height: 1.35;
    }

    .page1-intro {
        font-size: .85rem !important;
        line-height: 1.45;
    }

    .page1-topics,
    #topicsGrid {
        width: 100%;
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .page1-topic-card {
        width: 100%;
        min-width: 0;
        min-height: 0 !important;
        grid-template-columns: minmax(0, 1fr) 105px !important;
        grid-template-rows: auto auto !important;
        grid-template-areas:
            "title title"
            "content image" !important;
        gap: 8px 12px !important;
        padding: 13px !important;
        border-radius: 14px !important;
    }

    .page1-topic-card .card-title {
        font-size: 15px !important;
        line-height: 1.3;
    }

    .page1-topic-card .topic-image-wrapper {
        width: 105px;
        height: 120px !important;
        min-width: 0;
    }

    .page1-topic-card .topic-image-wrapper img {
        width: 100% !important;
        max-width: 105px !important;
        height: 120px !important;
        max-height: 120px !important;
        object-fit: contain !important;
    }

    .page1-topic-card .card-content {
        min-width: 0;
        padding: 0 !important;
    }

    .page1-topic-card .card-desc {
        font-size: 12px !important;
        line-height: 1.4;
        margin-bottom: 8px !important;
    }

    .page1-topic-card .topic-price {
        font-size: 13px !important;
        margin-top: 4px !important;
        padding-top: 6px !important;
    }

    .book-type-buttons {
        width: 100%;
        flex-direction: column !important;
        gap: 9px !important;
    }

    .book-type-buttons .book-type-btn {
        width: 100% !important;
        min-width: 0 !important;
        min-height: 48px !important;
        margin: 0 !important;
    }

    .page1-help {
        width: 100% !important;
        justify-content: center;
        text-align: center;
        line-height: 1.4;
    }


    /* ---------- Page 2 ---------- */

    #page2 {
        overflow: hidden;
    }

    .search-row {
        width: 100%;
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }

    .search-row input {
        width: 100% !important;
        min-width: 0 !important;
        flex: none !important;
    }

    .search-row .actions {
        width: 100%;
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 8px !important;
    }

    .search-row .actions button {
        width: 100%;
        min-width: 0;
    }

    .result-line-container {
        width: 100% !important;
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
    }

    #resultLine,
    #searchErrorMsg {
        max-width: 100%;
    }

    .models,
    #modelsGrid {
        width: 100%;
        max-width: 100%;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }

    .model {
        min-width: 0;
        width: 100%;
    }

    .model img {
        width: 100% !important;
        height: auto !important;
        max-height: 260px !important;
        object-fit: contain !important;
    }

    .model .meta {
        padding: 8px !important;
    }

    .model .row {
        gap: 5px;
        flex-wrap: wrap;
    }

    .model .name,
    .model .code {
        font-size: 12px;
    }

    .bottom-controls {
        width: 100%;
        margin-top: 14px !important;
    }


    /* ---------- Pages 3 / 4 / 5 ---------- */

    .page-grid {
        width: 100%;
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 12px !important;
    }

    .form-card,
    .preview-card {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        padding: 13px !important;
        border-radius: 12px !important;
    }

    .preview-card img,
    .modelPreviewImg,
    #page3Image {
        width: auto !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: 360px !important;
        object-fit: contain !important;
    }

    .size-options {
        width: 100%;
        flex-wrap: wrap;
        gap: 7px !important;
    }

    .size-btn {
        flex: 1 1 45%;
        min-width: 0;
    }

    .row-inline {
        width: 100%;
        max-width: 100%;
        flex-wrap: wrap !important;
    }

    .row-inline input,
    .row-inline select,
    .form-card select,
    .form-card textarea {
        max-width: 100%;
    }

    .color-options {
        width: 100%;
        max-width: 100%;
        justify-content: flex-start;
        gap: 10px !important;
    }

    .color-option-wrapper {
        max-width: 90px;
    }

    .color-option-wrapper .color-name,
    .color-name {
        max-width: 88px;
        white-space: normal !important;
        line-height: 1.2;
        text-align: center;
    }

    .qty-row {
        width: 100%;
        gap: 10px;
    }

    .qty-row > * {
        min-width: 0;
    }

    .continue-btn {
        width: 100% !important;
        float: none !important;
        margin: 14px 0 0 !important;
    }

    .primary-upload {
        max-width: 100%;
    }


    /* ---------- Summary page ---------- */

    .summary-table-container {
        width: 100%;
        max-width: 100%;
        padding: 10px !important;
    }

    .summary-detail {
        width: 100%;
        gap: 8px;
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .summary-detail > span {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .price-detail-row {
        width: 100%;
        gap: 6px;
        padding: 5px 2px !important;
        flex-wrap: wrap;
    }

    #DateEventProduct {
        max-width: 100%;
    }


    /* ---------- Page 6 ---------- */

    #page6 .form-card {
        padding: 18px 12px !important;
    }

    #page6 h2 {
        font-size: 1.25rem !important;
    }

    #recommendationsGrid {
        width: 100%;
        max-width: 100%;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }

    #recommendationsGrid .model img {
        width: 100% !important;
        height: 150px !important;
        max-height: 150px !important;
        object-fit: contain !important;
    }

    .action-row {
        width: 100%;
    }

    .action-row .btn {
        max-width: 100%;
    }


    /* ---------- Touch devices ---------- */

    .card:hover,
    .model:hover,
    .page1-topic-card:hover {
        transform: none !important;
    }
}


/* ---------------------------------------------------------
   SMALL PHONES
   --------------------------------------------------------- */

@media (max-width: 520px) {

    .app {
        padding-left: 6px !important;
        padding-right: 6px !important;
    }

    .page {
        padding-left: 2px !important;
        padding-right: 2px !important;
    }

    .wizard-brand-banner {
        min-height: 115px !important;
        padding: 10px 12px !important;
    }

    .wizard-logo {
        max-width: 165px !important;
    }

    .wizard-brand-title {
        font-size: .75rem !important;
    }

    .wizard-hero-book {
        display: none !important;
    }

    .wizard-brand-content {
        width: 100% !important;
    }

    #stepsBar .step {
        min-width: 39px;
    }

    #stepsBar .step .label {
        width: 42px;
        max-width: 42px;
        font-size: 8.5px !important;
    }

    #stepsBar .connector {
        flex-basis: 9px !important;
        width: 9px !important;
        min-width: 9px !important;
    }

    .page1-heading h2,
    .page h2 {
        font-size: 1.2rem !important;
    }

    .page1-topic-card {
        grid-template-columns: minmax(0, 1fr) 92px !important;
        padding: 11px !important;
        gap: 7px 9px !important;
    }

    .page1-topic-card .topic-image-wrapper {
        width: 92px;
        height: 105px !important;
    }

    .page1-topic-card .topic-image-wrapper img {
        max-width: 92px !important;
        height: 105px !important;
        max-height: 105px !important;
    }

    .models,
    #modelsGrid {
        grid-template-columns: 1fr !important;
    }

    .model img {
        max-height: 320px !important;
    }

    .search-row .actions {
        grid-template-columns: 1fr;
    }

    .form-card,
    .preview-card {
        padding: 10px !important;
    }

    .size-btn {
        flex-basis: 100%;
    }

    .qty-row {
        align-items: flex-start;
    }

    #recommendationsGrid {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
    }

    #recommendationsGrid .model img {
        height: 125px !important;
        max-height: 125px !important;
    }

    .book-type-buttons .book-type-btn {
        font-size: .9rem !important;
    }
}


/* ---------------------------------------------------------
   VERY SMALL PHONES
   --------------------------------------------------------- */

@media (max-width: 380px) {

    #stepsBar .step .label {
        display: none;
    }

    #stepsBar .step {
        min-width: 25px;
    }

    #stepsBar .connector {
        flex-basis: 10px !important;
        width: 10px !important;
        min-width: 10px !important;
        margin-top: 0;
    }

    .page1-topic-card {
        grid-template-columns: minmax(0, 1fr) 82px !important;
    }

    .page1-topic-card .topic-image-wrapper {
        width: 82px;
        height: 95px !important;
    }

    .page1-topic-card .topic-image-wrapper img {
        max-width: 82px !important;
        height: 95px !important;
        max-height: 95px !important;
    }

    #recommendationsGrid {
        grid-template-columns: 1fr !important;
    }
}
