/**
 * mobile.css — Мобильная адаптация Halora
 * Все стили применяются ТОЛЬКО на viewport ≤768px
 * Desktop остаётся без изменений
 */

/* ==========================================================================
   HEADER
   ========================================================================== */
/* Вариант A: мобильная и десктопная раскладка шапки полностью задаётся
   в `src/partials/header.html` Tailwind‑классами (`lg:hidden` / `lg:flex`,
   гриды и флексы). Здесь НАМЕРЕННО нет дополнительных стилей для header,
   чтобы он выглядел одинаково на всех страницах — и там, где подключён
   `mobile.css`, и там, где его нет. */

/* ==========================================================================
   CALCULATOR PAGE — Compact Layout + Price/Button row
   ========================================================================== */

@media (max-width: 768px) {

    /* Preview frame - no extra border */
    #calcPreviewFrame {
        max-width: 240px !important;
        aspect-ratio: 4/5 !important;
        border: none !important;
        margin: 0 auto !important; /* центрируем превью на мобильном */
    }

    /* Remove ring border from preview on mobile */
    #calcPreviewFrame.ring-1 {
        ring: none !important;
        --tw-ring-opacity: 0 !important;
    }

    /* Backlight chip - более компактный и в правом нижнем углу превью */
    #calcBacklightChip {
        right: 12px !important;
        bottom: 12px !important;
        padding: 6px 10px !important;
        font-size: 10px !important;
        gap: 6px !important;
        border-radius: 999px !important;
        background: rgba(25, 16, 10, 0.78) !important;
        border-color: rgba(246, 242, 237, 0.18) !important;
        color: rgba(246, 242, 237, 0.88) !important;
    }

    #calcBacklightDot {
        width: 10px !important;
        height: 10px !important;
        box-shadow: 0 0 8px rgba(245, 205, 120, 0.85) !important;
    }

    /* Section titles */
    .calc-section-title {
        font-size: 9px !important;
    }

    /* Material/Backlight buttons - smaller */
    .calc-material-btn,
    .calc-backlight-btn {
        padding: 6px 10px !important;
        font-size: 11px !important;
        gap: 4px !important;
    }

    .calc-material-btn img {
        height: 16px !important;
        width: 16px !important;
    }

    .calc-backlight-btn span.inline-flex {
        height: 10px !important;
        width: 10px !important;
    }

    /* Shape buttons - smaller */
    .calc-shape-btn {
        height: 44px !important;
        width: 44px !important;
    }

    .calc-shape-btn span {
        height: 28px !important;
        width: 28px !important;
    }

    /* Price section - horizontal layout with button on right */
    .mt-auto.pt-2.border-t {
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding-top: 12px !important;
        gap: 12px !important;
    }

    /* Price text left */
    .mt-auto.pt-2.border-t>.space-y-1 {
        flex: 0 0 auto !important;
    }

    /* Add to cart button - compact, on the right */
    #calcAddToCartBtn {
        width: auto !important;
        max-width: 140px !important;
        height: auto !important;
        padding: 10px 16px !important;
        font-size: 12px !important;
        border-radius: 18px !important;
        flex-shrink: 0 !important;
    }

    #calcAddToCartBtn svg {
        height: 12px !important;
        width: 12px !important;
    }

    /* Collapsible triggers - styled buttons for sections with icons */
    .mobile-section-trigger {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        width: 100% !important;
        padding: 12px 16px !important;
        border-radius: 16px !important;
        background: rgba(246, 242, 237, 0.06) !important;
        border: 1px solid rgba(246, 242, 237, 0.12) !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        color: rgba(249, 244, 238, 0.95) !important;
        cursor: pointer !important;
        transition: background 0.2s ease !important;
    }

    .mobile-section-trigger:hover {
        background: rgba(246, 242, 237, 0.10) !important;
    }

    .mobile-section-trigger::after {
        content: '▼';
        font-size: 8px;
        opacity: 0.5;
        transition: transform 0.2s ease;
    }

    .mobile-section-trigger.is-open::after {
        transform: rotate(180deg);
    }

    /* Trigger with icon */
    .mobile-section-trigger .trigger-icon {
        height: 20px;
        width: 20px;
        margin-right: 8px;
        border-radius: 50%;
        object-fit: contain;
    }

    /* Collapsible content - hidden by default on mobile */
    .mobile-collapsible-content {
        display: none !important;
    }

    .mobile-collapsible-content.is-open {
        display: block !important;
    }
}

/* ==========================================================================
   CATALOG PAGE — All filter tabs in one row
   ========================================================================== */

@media (max-width: 768px) {

    /* Filter buttons container - flex row, wrap if needed */
    [data-filter-buttons] {
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: clamp(4px, 1vw, 8px) !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
    }

    [data-filter-buttons]::-webkit-scrollbar {
        display: none !important;
    }

    /* Filter buttons - compact to fit in row */
    [data-filter-buttons] button {
        flex-shrink: 0 !important;
        padding: clamp(4px, 0.9vw, 7px) clamp(6px, 1.8vw, 12px) !important;
        font-size: clamp(9px, 2.4vw, 11px) !important;
        white-space: nowrap !important;
    }

    /* Product count badge - smaller */
    [data-filter-buttons] button span:last-child {
        font-size: clamp(8px, 2.1vw, 10px) !important;
        padding: 2px clamp(4px, 1.4vw, 8px) !important;
    }
}

/* ==========================================================================
   BOTTOM SHEET — Used for calculator sections on mobile
   ========================================================================== */

.mobile-sheet {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
}

.mobile-sheet.is-open {
    display: block;
}

.mobile-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.mobile-sheet-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 60vh;
    overflow-y: auto;
    background: linear-gradient(180deg, rgba(35, 24, 16, 0.98), rgba(25, 16, 10, 0.99));
    border-top: 1px solid rgba(246, 242, 237, 0.18);
    border-radius: 20px 20px 0 0;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    box-shadow: 0 -16px 50px rgba(0, 0, 0, 0.7);
    animation: slideUp 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}

.mobile-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(246, 242, 237, 0.10);
}

.mobile-sheet-title {
    font-size: 15px;
    font-weight: 700;
    color: rgba(249, 244, 238, 0.98);
}

.mobile-sheet-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(246, 242, 237, 0.08);
    border: 1px solid rgba(246, 242, 237, 0.12);
    color: rgba(246, 242, 237, 0.7);
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.mobile-sheet-close:hover {
    background: rgba(246, 242, 237, 0.12);
}

.mobile-sheet-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mobile-sheet-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(246, 242, 237, 0.04);
    border: 1px solid rgba(246, 242, 237, 0.10);
    font-size: 13px;
    font-weight: 600;
    color: rgba(246, 242, 237, 0.85);
    cursor: pointer;
    transition: all 0.2s ease;
}

.mobile-sheet-option:hover {
    background: rgba(246, 242, 237, 0.08);
}

.mobile-sheet-option.is-selected {
    background: rgba(216, 160, 74, 0.15);
    border-color: rgba(216, 160, 74, 0.4);
    color: rgba(249, 244, 238, 0.98);
}

.mobile-sheet-option img,
.mobile-sheet-option .option-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    border-radius: 50%;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

/* ==========================================================================
   CART PAGE — Single Column + Compact Cards
   ========================================================================== */

@media (max-width: 768px) {

    /* Title - smaller */
    .cart-page-title {
        font-size: 24px !important;
    }

    /* Grid to single column */
    .cart-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
    }

    /* Reorder: summary first */
    .cart-grid>aside {
        order: -1 !important;
    }

    /* Summary section - compact */
    .cart-summary {
        padding: 14px !important;
        border-radius: 20px !important;
    }

    .cart-summary h2 {
        font-size: 13px !important;
    }

    .cart-summary [data-cart-total] {
        font-size: 16px !important;
    }

    /* Form fields - smaller */
    .cart-summary input,
    .cart-summary textarea,
    .cart-summary button[data-payment-toggle] {
        padding: 10px 14px !important;
        font-size: 13px !important;
        border-radius: 14px !important;
    }

    /* Hide comment field behind trigger */
    .mobile-comment-hidden {
        display: none !important;
    }

    .mobile-comment-trigger {
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        padding: 10px 14px !important;
        border-radius: 14px !important;
        background: rgba(246, 242, 237, 0.06) !important;
        border: 1px dashed rgba(246, 242, 237, 0.2) !important;
        color: rgba(246, 242, 237, 0.7) !important;
        font-size: 12px !important;
        cursor: pointer !important;
        width: 100% !important;
    }

    .mobile-comment-trigger::before {
        content: '+';
        font-size: 14px;
    }

    /* Cart items - compact */
    .cart-items-list>div {
        padding: 8px 0 !important;
    }

    /* Items section - compact */
    .cart-items-section {
        padding: 12px !important;
    }

    /* Submit button - smaller */
    .cart-summary [data-checkout-submit] {
        padding: 12px 16px !important;
        font-size: 12px !important;
    }
}

/* ==========================================================================
   ORDERS PAGE — Stacked Layout + Centered Card
   ========================================================================== */

@media (max-width: 768px) {

    /* Title */
    .orders-page-title {
        font-size: 24px !important;
    }

    /* Grid to single column */
    [data-orders-auth] {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
    }

    /* Center main cards (история + детали заказа) */
    [data-orders-auth] > aside,
    [data-orders-auth] > section {
        width: 100% !important;
        max-width: 420px !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    /* Order list - center items */
    [data-orders-list] {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
    }

    /* Order cards - compact, centered, full width */
    [data-orders-list] button {
        padding: 10px !important;
        width: 100% !important;
        max-width: 400px !important;
    }

    /* Detail section - more compact */
    .orders-detail-content {
        gap: 12px !important;
    }

    .orders-detail-content section {
        padding: 12px !important;
    }

    /* Items in order - smaller */
    .orders-detail-content .order-item-image {
        width: 36px !important;
        height: 36px !important;
    }
}

/* ==========================================================================
   UTILITY CLASSES — Mobile visibility/behavior
   ========================================================================== */

@media (max-width: 768px) {
    .mobile-only {
        display: block !important;
    }

    .desktop-only {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .mobile-only {
        display: none !important;
    }

    .mobile-section-trigger,
    .mobile-comment-trigger {
        display: none !important;
    }

    .mobile-collapsible-content {
        display: block !important;
    }
}

/* Prevent horizontal scroll */
@media (max-width: 768px) {

    html,
    body {
        overflow-x: hidden !important;
    }
}