/* ==============================================================================
 * 💎 VIP Club TMA - iOS Style Sheet (SF Pro & Glassmorphic Elements)
 * ============================================================================== */

:root {
    --ios-bg: #F2F2F7;
    --ios-card-bg: rgba(255, 255, 255, 0.82);
    --ios-card-solid: #FFFFFF;
    --ios-blue: #007AFF;
    --ios-green: #34C759;
    --ios-red: #FF3B30;
    --ios-orange: #FF9500;
    --ios-gray: #8E8E93;
    --ios-light-gray: #D1D1D6;
    --ios-border-color: rgba(60, 60, 67, 0.15);
    --ios-text: #000000;
    --ios-text-secondary: #3C3C43;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "SF Pro Icons", "Helvetica Neue", Helvetica, Arial, sans-serif;
    background-color: var(--ios-bg);
    color: var(--ios-text);
    overflow: hidden;
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
}


/* ─── APP SHELL & PAGE SLIDING ────────────────────────────────────────────── */

#app-container {
    /* position: fixed — єдиний надійний спосіб на мобільних:
       явно займає весь екран мінус таббар, не залежить від flex */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 66px; /* точна висота таббару */
    overflow: hidden;
}



.page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--ios-bg);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.1, 0.7, 0.1, 1);
    z-index: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    /* Add bottom padding for tabbar clearance */
    padding-bottom: 16px;
}


/* Flex layout overrides for chat/CRM interfaces that need sticky headers/inputs */
#page-support, #page-admin-chat {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ─── TWO-LEVEL CHANNEL MENU PANELS ──────────────────────────────────────── */

/* Both panels live inside page-channels and slide against each other */
.channels-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    background-color: var(--ios-bg);
    transition: transform 0.3s cubic-bezier(0.1, 0.7, 0.1, 1);
    will-change: transform;
}

/* Sub-panel is hidden off-screen to the right by default */
.channels-sub-hidden {
    transform: translateX(100%);
    pointer-events: none;
}


.page.active {
    transform: translateX(0);
    z-index: 2;
}

.page.prev {
    transform: translateX(-30%);
}

/* ─── HEADERS & TITLE BAR ─────────────────────────────────────────────────── */

.ios-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(249, 249, 249, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 0.5px solid var(--ios-border-color);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
}

.ios-header h1 {
    font-size: 17px;
    font-weight: 600;
    color: var(--ios-text);
    flex: 1;
    text-align: center;
}

.ios-header .left-action, .ios-header .right-action {
    min-width: 60px;
    font-size: 17px;
    color: var(--ios-blue);
    font-weight: 400;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.ios-header .left-action:active, .ios-header .right-action:active {
    opacity: 0.3;
}

/* Large Page Title (iOS style settings) */
.ios-large-title-block {
    padding: 16px 16px 8px 16px;
}

.ios-large-title-block h2 {
    font-size: 34px;
    font-weight: 700;
    color: var(--ios-text);
    letter-spacing: -0.5px;
}

/* ─── GROUPED LISTS (iOS settings style) ─────────────────────────────────── */

.ios-group-title {
    font-size: 13px;
    font-weight: 400;
    text-transform: uppercase;
    color: var(--ios-gray);
    margin: 16px 20px 6px 20px;
    letter-spacing: 0.3px;
}

.ios-group {
    background: var(--ios-card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 12px;
    margin: 0 16px 16px 16px;
    overflow: hidden;
    border: 0.5px solid var(--ios-border-color);
}

.ios-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: transparent;
    border-bottom: 0.5px solid var(--ios-border-color);
    position: relative;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.ios-item:last-child {
    border-bottom: none;
}

.ios-item:active {
    background-color: rgba(0, 0, 0, 0.05);
}

.ios-item-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    margin-right: 12px;
    color: #FFFFFF;
}

.ios-item-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.ios-item-title {
    font-size: 16px;
    font-weight: 400;
    color: var(--ios-text);
    word-break: break-word;
    white-space: normal;
    line-height: 1.3;
}


.ios-item-subtitle {
    font-size: 12px;
    color: var(--ios-gray);
    margin-top: 2px;
}

.ios-item-right {
    font-size: 16px;
    color: var(--ios-gray);
    display: flex;
    align-items: center;
}

.ios-chevron {
    color: var(--ios-light-gray);
    font-size: 20px;
    margin-left: 6px;
    font-weight: 300;
}

/* ─── BUTTONS & INTERACTIVES ────────────────────────────────────────────── */

.ios-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 50px;
    background: var(--ios-card-solid);
    border-radius: 12px;
    font-size: 17px;
    font-weight: 600;
    color: var(--ios-blue);
    border: 0.5px solid var(--ios-border-color);
    margin: 16px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.02);
    transition: transform 0.1s ease, background-color 0.15s ease;
}

.ios-btn:active {
    transform: scale(0.96);
    background-color: rgba(240, 240, 240, 0.85);
}

.ios-btn-primary {
    background: var(--ios-blue);
    color: #FFFFFF;
    border: none;
}

.ios-btn-primary:active {
    background-color: #0056B3;
}

.ios-btn-danger {
    color: var(--ios-red);
}

/* iOS Toggle/Switch */
.ios-switch {
    position: relative;
    display: inline-block;
    width: 51px;
    height: 31px;
}

.ios-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.ios-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--ios-light-gray);
    transition: .3s;
    border-radius: 34px;
}

.ios-slider:before {
    position: absolute;
    content: "";
    height: 27px;
    width: 27px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}

input:checked + .ios-slider {
    background-color: var(--ios-green);
}

input:checked + .ios-slider:before {
    transform: translateX(20px);
}

/* ─── CLIENT VIP SPECIFIC CARDS ─────────────────────────────────────────── */

.vip-card-block {
    background: linear-gradient(135deg, #1C1C1E 0%, #2C2C2E 100%);
    border-radius: 16px;
    padding: 24px;
    margin: 16px;
    color: #FFFFFF;
    box-shadow: 0 12px 30px rgba(0,0,0,0.15);
    position: relative;
    overflow: hidden;
}

.vip-card-block::after {
    content: "VIP";
    position: absolute;
    right: -20px;
    bottom: -30px;
    font-size: 140px;
    font-weight: 800;
    color: rgba(255,255,255,0.03);
    pointer-events: none;
}

.vip-card-status {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--ios-orange);
    font-weight: 600;
    margin-bottom: 8px;
}

.vip-card-title {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 20px;
}

.vip-card-days-circle {
    display: flex;
    align-items: center;
    gap: 16px;
}

.vip-circle-svg {
    transform: rotate(-90deg);
}

.vip-days-num {
    font-size: 32px;
    font-weight: 700;
}

.vip-days-text {
    font-size: 14px;
    color: #AEAEB2;
}

/* ─── WISHLIST GRID ────────────────────────────────────────────────────── */

.wishlist-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 0 16px 16px 16px;
}

.wishlist-card {
    background: var(--ios-card-solid);
    border-radius: 12px;
    border: 0.5px solid var(--ios-border-color);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    transition: transform 0.15s ease;
}

.wishlist-card:active {
    transform: scale(0.97);
}

.wishlist-img-box {
    width: 100%;
    aspect-ratio: 1;
    background: #E5E5EA;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    position: relative;
}

.wishlist-info {
    padding: 10px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.wishlist-brand {
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--ios-gray);
}

.wishlist-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--ios-text);
    margin: 4px 0 8px 0;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 38px;
}

.wishlist-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}

.wishlist-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--ios-text);
}

.wishlist-action-btns {
    display: flex;
    gap: 6px;
}

.wishlist-icon-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #F2F2F7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    border: none;
    cursor: pointer;
}

.wishlist-icon-btn:active {
    background-color: var(--ios-light-gray);
}

/* ─── SUPPORT CHAT ROOM ─────────────────────────────────────────────────── */

.chat-history {
    flex: 1;
    min-height: 0; /* Критично для flex-scroll на iOS */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.4;
    position: relative;
    word-break: break-word;
}

.chat-bubble.from-user {
    background-color: var(--ios-blue);
    color: #FFFFFF;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-bubble.from-admin {
    background-color: #E5E5EA;
    color: var(--ios-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chat-bubble img {
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: 6px;
    display: block;
}

.chat-time {
    font-size: 9px;
    opacity: 0.6;
    text-align: right;
    margin-top: 4px;
}

.chat-input-bar {
    flex-shrink: 0; /* Ніколи не зрізається */
    padding: 8px 12px;
    /* Безпечна зона для iPhone з виїмкою + tabbar clearance */
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    background: rgba(249, 249, 249, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 0.5px solid var(--ios-border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-input-bar input {
    flex: 1;
    height: 36px;
    border-radius: 18px;
    border: 0.5px solid var(--ios-border-color);
    padding: 0 14px;
    font-size: 15px;
    background: #FFFFFF;
    outline: none;
}

.chat-send-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--ios-blue);
    border: none;
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
}

.chat-send-btn:active {
    transform: scale(0.9);
    opacity: 0.8;
}

/* ─── TABBAR (iOS style bottom menu) ────────────────────────────────────── */

.ios-tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--ios-border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 8px;
    z-index: 100;
    box-sizing: border-box;
}

.ios-tab-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--ios-text-secondary);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    width: 23%;
    height: 48px;
    border-radius: 12px;
    background-color: rgba(242, 242, 247, 0.8);
    border: 1px solid rgba(60, 60, 67, 0.05);
    cursor: pointer;
    overflow: hidden;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.ios-tab-item.active {
    color: var(--ios-blue);
    background-color: rgba(0, 122, 255, 0.12);
    border-color: rgba(0, 122, 255, 0.3);
    box-shadow: 0 1px 3px rgba(0, 122, 255, 0.05);
}

.ios-tab-icon {
    display: none;
    position: absolute;
    font-size: 32px;
    opacity: 0.12;
    pointer-events: none;
    z-index: 1;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin-bottom: 0;
    transition: all 0.2s ease;
}

.ios-tab-item.active .ios-tab-icon {
    opacity: 0.22;
    transform: translate(-50%, -50%) scale(1.1);
}

.ios-tab-item div:not(.ios-tab-icon) {
    position: relative;
    z-index: 2;
    pointer-events: none;
    text-align: center;
    line-height: 1.15;
}

/* ─── ADMIN CHAT ROOM CRM LAYOUT ────────────────────────────────────────── */

.admin-crm-container {
    display: flex;
    width: 100%;
    height: 100%;
}

.admin-sidebar {
    width: 320px;
    border-right: 0.5px solid var(--ios-border-color);
    display: flex;
    flex-direction: column;
    background: #FFFFFF;
}

.admin-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--ios-bg);
}

.admin-profile-sidebar {
    width: 260px;
    border-left: 0.5px solid var(--ios-border-color);
    background: #FFFFFF;
    display: flex;
    flex-direction: column;
    padding: 16px;
    overflow-y: auto;
}

/* Mobile CRM Layout adaptation */
@media(max-width: 768px) {
    .admin-crm-container {
        flex-direction: column;
    }
    .admin-sidebar {
        width: 100%;
        height: 100%;
    }
    .admin-chat-area {
        width: 100%;
        height: 100%;
        display: none; /* Handled dynamically by JS screen toggle */
    }
    .admin-profile-sidebar {
        display: none;
    }
}

/* ==============================================================================
 * 💙 VIP Club TMA - Admin Pastel Blue Customizations
 * ============================================================================== */

:root {
    --ios-admin-bg: #EBF4FF;
    --ios-admin-tabbar: #E1EEFA;
}

.admin-sidebar {
    background-color: var(--ios-admin-bg) !important;
}

.admin-profile-sidebar {
    background-color: var(--ios-admin-bg) !important;
}

.admin-tabbar {
    background-color: var(--ios-admin-tabbar) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 0.5px solid rgba(0, 122, 255, 0.18) !important;
}


/* ─── CUSTOM MODALS & SEGMENTED CONTROLS FOR ADMIN PANEL ─── */

.admin-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
}

.days-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.days-btn {
    flex: 1;
    height: 38px;
    border-radius: 8px;
    border: 0.5px solid var(--ios-border-color);
    background: #F2F2F7;
    color: var(--ios-text);
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.days-btn.active {
    background: var(--ios-blue) !important;
    color: #FFFFFF !important;
    border-color: var(--ios-blue) !important;
}

/* ─── CABINET SLIDING PANELS ────────────────────────────────────────── */

/* Both panels live inside page-cabinet and slide against each other */
.cabinet-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    background-color: var(--ios-bg);
    transition: transform 0.3s cubic-bezier(0.1, 0.7, 0.1, 1);
    will-change: transform;
}

.cabinet-sub-hidden {
    transform: translateX(100%);
    pointer-events: none;
}
