/* Shared mobile / small-screen layout for Premier Signature */

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

input, select, textarea, button {
    max-width: 100%;
    font-size: 16px; /* prevent iOS zoom on focus */
    touch-action: manipulation;
}

html, body, * {
    max-width: 100%;
    touch-action: manipulation;
}

/* Shop page mobile fixes */
@media screen and (max-width: 768px) {
    .catalog-container {
        margin-top: 10px !important;
        padding: 0 10px !important;
    }

    #sidebarToggle {
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        margin-bottom: 10px !important;
        padding: 15px !important;
        font-size: 1.1rem !important;
    }

    .shop-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    .product-card {
        font-size: 0.85rem;
    }

    .product-title {
        font-size: 0.8rem !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        line-height: 1.3 !important;
        min-height: 1.6em !important;
    }

    .product-price {
        font-size: 0.9rem !important;
    }
}

/* Index page mobile fixes */
@media screen and (max-width: 768px) {
    .product-card .product-img-wrapper {
        aspect-ratio: 1 / 1 !important;
    }

    .product-card .product-title {
        font-size: 0.85rem !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        line-height: 1.3 !important;
        min-height: 2.2em !important;
    }

    .product-card .product-price {
        font-size: 0.9rem !important;
        margin-top: 6px !important;
    }

    /* Carousel mobile fixes */
    .product-carousel-wrap {
        padding: 10px 36px !important;
    }

    .carousel-item {
        flex: 0 0 160px !important;
        width: 160px !important;
        margin-right: 15px !important;
    }

    .product-carousel {
        padding: 10px 0 !important;
    }

    .carousel-arrow {
        width: 36px !important;
        height: 36px !important;
        font-size: 0.85rem;
    }
}

/* Product modal + cart (index / shop) */
@media screen and (max-width: 900px) {
    .product-modal {
        align-items: flex-start !important;
        overflow-y: auto;
        padding: 16px 0;
        -webkit-overflow-scrolling: touch;
        z-index: 9999 !important;
    }
    .product-modal-content {
        flex-direction: column !important;
        width: 94% !important;
        max-height: none !important;
        margin: 12px auto;
        overflow: auto !important;
    }
    .pm-main-img {
        height: 220px !important;
    }
    .pm-info {
        padding: 24px 18px !important;
    }
    .pm-title {
        font-size: 1.4rem !important;
    }
    .cart-sidebar {
        width: 100% !important;
        max-width: 100%;
        right: 0 !important;
        transform: translateX(100%);
        transition: transform 0.3s ease !important;
    }
    .cart-sidebar.open,
    .cart-sidebar[style*="right: 0"] {
        transform: translateX(0);
        z-index: 4000 !important;
    }
    
    /* Navigation improvements for mobile */
    .premium-nav {
        z-index: 3000 !important;
    }
    
    .nav-links.active {
        z-index: 3001 !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        overflow-y: auto !important;
    }
    #mobile-nav-close {
        display: block !important;
    }
    .cart-icon {
        bottom: 80px !important;
        right: 18px !important;
        width: 54px !important;
        height: 54px !important;
        z-index: 2500 !important;
    }
}

@media screen and (max-width: 768px) {
    body {
        padding-top: 130px !important;
    }

    .hero-section,
    header.hero-section {
        min-height: 70vh;
    }
    .hero-content {
        padding: 0 16px;
    }
    .hero-buttons {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .hero-buttons .btn {
        text-align: center;
        width: 100%;
    }
    .page-header h1 {
        font-size: 2rem !important;
    }
    .page-header {
        padding: 110px 16px 40px !important;
    }
    .catalog-container {
        margin: 24px auto !important;
        padding: 0 14px !important;
    }
    .checkout-container {
        grid-template-columns: 1fr !important;
        margin: 24px auto !important;
        gap: 20px !important;
        padding: 12px !important;
    }
    .checkout-box {
        padding: 20px !important;
    }
    .checkout-box > div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
    .btn-logo-row {
        gap: 10px !important;
    }
    .payment-brand-svg,
    .card-badge-svg {
        height: 18px !important;
    }

    /* Account modal (index/shop) */
    #accountModal .modal-content {
        display: flex !important;
        flex-direction: column !important;
        width: 96% !important;
        max-width: 96% !important;
        margin: 8% auto !important;
        padding: 20px 16px !important;
        max-height: 88vh;
        overflow: auto;
        gap: 16px !important;
    }
    #accountModal .sidebar {
        border-right: none !important;
        padding-right: 0 !important;
        border-bottom: 1px solid #333;
        padding-bottom: 12px;
    }

    /* Standalone account page */
    .container {
        grid-template-columns: 1fr !important;
        margin: 20px auto !important;
        padding: 12px !important;
        gap: 16px !important;
    }
    .nav-bar {
        padding: 14px 16px !important;
        flex-wrap: wrap;
        gap: 10px;
    }
    .order-header,
    .promo-card,
    #accountModal [style*="justify-content: space-between"] {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px;
    }

    /* Login */
    .auth-container {
        margin: 80px 16px !important;
        padding: 22px 16px !important;
        width: auto !important;
        max-width: 100%;
    }

    /* Personalize */
    .canvas-canvas-wrapper {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 1 / 1;
    }
    .controls-card {
        padding: 22px 16px !important;
    }
    .personalize-section {
        padding-top: 110px !important;
    }

    /* Master / accounting */
    body:has(.admin-sidebar) {
        flex-direction: column !important;
        height: auto !important;
        overflow: auto !important;
    }
    
    .sidebar-toggle {
        display: block !important;
        position: fixed !important;
        top: 10px !important;
        left: 10px !important;
        z-index: 1001 !important;
        background: var(--accent, #8b5cf6) !important;
        color: white !important;
        border: none !important;
        padding: 10px 15px !important;
        border-radius: 4px !important;
        cursor: pointer !important;
        font-size: 16px !important;
    }
    
    .admin-sidebar {
        position: fixed !important;
        left: -250px !important;
        top: 0 !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 24px) !important;
        box-sizing: border-box !important;
        z-index: 1000 !important;
        transition: left 0.3s ease !important;
        width: 250px !important;
        border-right: 1px solid var(--border, #333) !important;
        flex-direction: column !important;
    }
    
    .admin-sidebar.collapsed {
        left: 0 !important;
    }
    
    .admin-main {
        margin-left: 0 !important;
        padding: 16px !important;
        overflow: visible !important;
    }
    
    .admin-sidebar-header {
        width: 100%;
        padding: 12px !important;
    }
    
    .admin-nav {
        flex-direction: column !important;
        padding: 20px 0 !important;
        flex: 1;
    }
    
    .admin-nav a {
        padding: 15px 20px !important;
        border-left: 3px solid transparent !important;
        color: #aaa !important;
        text-decoration: none !important;
        font-weight: bold !important;
        display: flex !important;
        align-items: center !important;
        gap: 10px !important;
    }
    }
    .admin-nav a {
        flex: 1 1 45%;
        padding: 12px !important;
        border-left: none !important;
        justify-content: center;
        font-size: 0.85rem;
    }
    .admin-main {
        padding: 16px !important;
        overflow: visible !important;
    }
    .product-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .modal-content {
        width: 94% !important;
        margin: 12% auto !important;
        padding: 16px !important;
    }
    .master-container {
        padding: 16px !important;
        border-radius: 8px !important;
    }
    .nav-tabs {
        flex-wrap: wrap;
    }
    .nav-tabs .nav-link {
        padding: 10px 12px !important;
        margin: 0 4px 6px 0 !important;
        font-size: 0.85rem;
    }
    .tab-content-card {
        padding: 14px !important;
        overflow-x: auto;
    }
    .stylish-table {
        display: block;
        overflow-x: auto;
    }
}

@media screen and (max-width: 480px) {
    .logo-text img {
        height: 2.6rem !important;
    }
    .section-title {
        font-size: 1.7rem !important;
    }
    .pm-info {
        padding: 18px 14px !important;
    }
    
    /* Contact form improvements for mobile */
    .contact-layout {
        flex-direction: column !important;
        gap: 30px !important;
    }
    
    /* Services cards grid for mobile */
    .services-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px !important;
    }
    
    .service-card {
        height: 380px !important;
        width: 100% !important;
        padding: 1rem !important;
    }
    
    .service-card h3 {
        font-size: 1rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .service-card p {
        font-size: 0.85rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .service-list {
        font-size: 0.75rem !important;
    }
    
    .service-icon {
        width: 40px !important;
        height: 40px !important;
    }
    
    .service-icon svg {
        width: 20px !important;
        height: 20px !important;
    }
}

@media screen and (max-width: 480px) {
    .services-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    .service-card {
        height: 320px !important;
        width: 100% !important;
        padding: 1.2rem !important;
    }
    
    .service-card h3 {
        font-size: 1.1rem !important;
    }
    
    .service-card p {
        font-size: 0.9rem !important;
    }
    
    .service-list {
        font-size: 0.8rem !important;
    }
    
    .service-icon {
        width: 50px !important;
        height: 50px !important;
    }
    
    .service-icon svg {
        width: 24px !important;
        height: 24px !important;
    }
    
    /* Mobile modal positioning fix */
    .product-modal-content {
        margin-top: 60px !important;
        max-height: calc(100vh - 80px) !important;
    }
    
    .pm-gallery {
        padding: 15px !important;
    }
    
    .pm-main-img {
        height: 250px !important;
    }
    
    .pm-info {
        padding: 20px 15px !important;
    }
    
    .pm-title {
        font-size: 1.5rem !important;
    }
    
    .pm-price {
        font-size: 1.2rem !important;
    }
    
    .pm-btn {
        padding: 12px 20px !important;
        font-size: 1rem !important;
    }
    
    .contact-form-wrapper {
        width: 100% !important;
        padding: 20px 15px !important;
    }
    
    .premium-form {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
    }
    
    .premium-form .form-group {
        margin-bottom: 0 !important;
    }
    
    .premium-form input,
    .premium-form select,
    .premium-form textarea {
        padding: 14px 12px !important;
        font-size: 16px !important;
        border-radius: 6px !important;
    }
    
    .premium-form textarea {
        min-height: 120px !important;
        resize: vertical !important;
    }
    
    .premium-form button.form-submit {
        padding: 16px 20px !important;
        font-size: 16px !important;
        margin-top: 10px !important;
    }
    
    .info-column {
        width: 100% !important;
        padding: 20px 15px !important;
    }
}

/* Fallback for browsers without :has() — master panel class on html/body */
@media screen and (max-width: 768px) {
    .admin-layout,
    body.admin-body {
        flex-direction: column !important;
        height: auto !important;
        overflow: auto !important;
    }
    
    /* Portfolio improvements for mobile */
    .portfolio-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    
    .portfolio-item {
        height: 160px !important;
    }
    
    .portfolio-item img {
        height: 100% !important;
    }

    .portfolio-showcase {
        aspect-ratio: 4 / 3 !important;
        border-radius: 10px !important;
    }

    .portfolio-showcase-caption {
        padding: 28px 18px 18px !important;
    }

    .portfolio-showcase-caption h3 {
        font-size: 1.1rem !important;
    }

    .portfolio-nav-btn {
        width: 34px !important;
        height: 34px !important;
    }

    .lightbox-nav {
        width: 38px !important;
        height: 38px !important;
    }
    .lightbox-prev { left: 8px !important; }
    .lightbox-next { right: 8px !important; }
}

@media screen and (max-width: 480px) {
    .portfolio-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    
    .portfolio-item {
        height: 130px !important;
    }
    
    .portfolio-item img {
        height: 100% !important;
    }
}

@media screen and (max-width: 900px) {
    .mobile-social-icons {
        display: flex !important;
    }
    
    /* Ensure My Account Modal is above everything */
    #accountModal {
        z-index: 9999 !important;
    }
}

/* ── Extra-small phone fix (e.g. 375×667, iPhone SE) ──────────────────── */
@media screen and (max-width: 414px) {

    /* Hero: allow content to breathe — remove height cap, add scroll */
    .hero-section,
    header.hero-section {
        height: auto !important;
        min-height: 100svh;           /* use small viewport height unit */
        overflow: visible !important;
    }

    /* Add top padding so badges clear the fixed nav bar (~70px) */
    .hero-content {
        padding-top: 90px !important;
        padding-bottom: 28px !important;
    }

    /* Shrink hero title so it doesn't push content off-screen */
    .hero-title {
        font-size: 2.2rem !important;
        margin-bottom: 12px !important;
        line-height: 1.15 !important;
    }

    /* Shrink subtitle */
    .hero-subtitle {
        font-size: 1rem !important;
        margin-bottom: 20px !important;
    }

    /* Event / auction badges — smaller so they fit on one line */
    #upcomingEventBadge,
    #liveAuctionBadge {
        font-size: 0.78rem !important;
        padding: 8px 14px !important;
        border-radius: 20px !important;
    }

    /* Buttons stack tighter */
    .hero-buttons {
        gap: 8px !important;
        margin-bottom: 18px !important;
    }

    /* Social icons — give them a safe margin so they're never clipped */
    .hero-content .social-icons {
        margin-top: 16px !important;
        margin-bottom: 12px !important;
        padding-bottom: 8px;
    }
}

/* Also handle landscape on small phones specifically */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .hero-section,
    header.hero-section {
        height: auto !important;
        min-height: 100svh;
    }
    .hero-content {
        padding-top: 70px !important;
        padding-bottom: 20px !important;
    }
    .hero-title { font-size: 1.8rem !important; margin-bottom: 8px !important; }
    .hero-subtitle { font-size: 0.9rem !important; margin-bottom: 12px !important; }
    .hero-buttons { gap: 8px !important; }
    .hero-content .social-icons { margin-top: 10px !important; }
}

/* ===== Product badges on small screens: smaller, never overlapping ===== */
@media screen and (max-width: 768px) {
    .pbadge, .pbadges--lg .pbadge { font-size: 0.6rem; padding: 2px 5px; gap: 3px; }
    .pbadges { gap: 3px; }
    .pbadges-br { gap: 2px; }
    .pbadges-br .pbadge, .pbadges-br.pbadges--lg .pbadge { font-size: 0.6rem; padding: 2px 5px; }
}

/* ===== Home page: featured carousel runs edge to edge on mobile ===== */
@media screen and (max-width: 768px) {
    .shop-section { padding-left: 0 !important; padding-right: 0 !important; }
    .shop-section .container { width: 100% !important; }
    .shop-section .section-subtitle,
    .shop-section .section-title,
    .shop-section .shop-view-all { padding-left: 5%; padding-right: 5%; }
    .shop-section .product-carousel-wrap { padding: 10px 0 !important; }
    .shop-section .product-carousel { padding: 10px 12px !important; }
    .shop-section .carousel-item {
        flex: 0 0 clamp(170px, 54vw, 240px) !important;
        width: clamp(170px, 54vw, 240px) !important;
        margin-right: 12px !important;
    }
    .shop-section .carousel-arrow { width: 34px !important; height: 34px !important; background: rgba(17,17,17,0.78); }
    .shop-section .carousel-arrow-left { left: 6px; }
    .shop-section .carousel-arrow-right { right: 6px; }
}

/* ===== Partner logos on small screens ===== */
@media screen and (max-width: 768px) {
    .partner-logos { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .partner-logo { height: 100px; padding: 16px; }
    .partner-logo--fill { padding: 0; }
    .partner-logos-wrap { margin-bottom: 40px; }
}
