/* ------------------------------------------------------------------- */
/* --- Calculator Layout & Base Styles ---------------------------- */
/* ------------------------------------------------------------------- */

.pricing-calculator-section {
    padding: 80px 0;
    background-color: var(--color-bg-secondary);
}

.section-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--color-text-dark);
    margin-bottom: 40px;
    text-align: center;
}

.calculator-wrapper {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    max-width: 1200px;
    margin: 0 auto;
}

/* --- Left Panel: Region Selection --- */
.region-selection-panel {
    flex: 3;
    /* Take up more space */
    background-color: var(--color-card-bg);
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

/* --- Right Panel: Order Summary --- */
.order-summary-panel {
    flex: 1.5;
    /* Take up less space, but enough for the summary */
    background-color: var(--color-card-bg);
    border-radius: 12px;
    padding: 30px;
    border: 1px solid var(--color-border-light);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    position: sticky;
    top: 30px;
    /* Stick near the top when scrolling */
}

.order-summary-panel h3 {
    font-size: 22px;
    color: var(--color-text-dark);
    border-bottom: 2px solid var(--color-border-light);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

/* ------------------------------------------------------------------- */
/* --- 3. Duration Tabs --- */
/* ------------------------------------------------------------------- */
.duration-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.duration-tab-button {
    padding: 10px 20px;
    border: 1px solid var(--color-border-light);
    background-color: var(--color-bg-light);
    color: var(--color-text-subtle);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.duration-tab-button:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.duration-tab-button.active {
    background: var(--brand-gradient);
    color: var(--color-bg-light);
    border-color: transparent;
    box-shadow: 0 4px 10px rgba(0, 191, 255, 0.2);
}

/* ------------------------------------------------------------------- */
/* --- 4. IP Quantity Control (已删除，因为在提供的 HTML 结构中没有找到) --- */
/* ------------------------------------------------------------------- */

/* ------------------------------------------------------------------- */
/* --- 5. Region Selector Grid & Collapsible Sections --- */
/* ------------------------------------------------------------------- */

.region-category {
    margin-bottom: 20px;
}

.region-category h4 {
    /* Existing Styles */
    font-size: 18px;
    color: var(--color-text-dark);
    padding: 10px 15px 10px 10px;
    margin: 25px 0 15px 0;
    font-weight: 700;
    border-left: 5px solid var(--color-primary);

    /* New Styles for Collapsible Header */
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
    border-radius: 4px;
}

.region-category h4:hover {
    background-color: #f1f3f5;
}

.region-category h4 i {
    transition: transform 0.3s ease;
    font-size: 14px;
    color: var(--color-text-subtle);
}

/* Collapsed State Icon */
.region-category.collapsed h4 i {
    transform: rotate(-90deg);
}

/* Collapsed Content */
.region-category.collapsed .region-content {
    display: none;
}

.region-grid {
    display: grid;
    /* 严格固定为 4 列 */
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.region-item {
    display: flex;
    align-items: center;
    /* 垂直居中内容 */
    /* FIX: 确保文字从左往右对齐，即使没占满也没事 */
    justify-content: flex-start;
    cursor: pointer;
    user-select: none;
    background-color: var(--color-bg-secondary);
    border-radius: 6px;
    border: 1px solid var(--color-border-light);
    /* 初始边框 */
    transition: all 0.2s;

    /* 核心 FIX: 严格固定高度，解决参差不齐问题 */
    padding: 0 10px;
    height: 40px;

    /* 文本处理：固定一行显示，防止高度被撑开，并处理溢出 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* FIX: 选中状态 (用 border 突出显示) */
.region-item.selected {
    border-color: var(--color-primary);
    background-color: #e6f7ff;
    /* 浅蓝色背景 */
    box-shadow: 0 0 0 1px var(--color-primary);
}

.region-item:hover {
    border-color: var(--color-primary);
}


.region-item label {
    font-size: 14px;
    color: var(--color-text-dark);
    /* 移除 flex-grow，让文本自然占据空间 */
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* ------------------------------------------------------------------- */
/* --- 6. Summary Panel Details --- */
/* ------------------------------------------------------------------- */
.summary-details {
    margin-bottom: 25px;
}

.detail-line {
    display: flex;
    justify-content: space-between;
    font-size: 15px;
    color: var(--color-text-subtle);
    padding: 5px 0;
}

.highlight-text {
    font-weight: 700;
    color: var(--color-primary);
}

.selected-regions-display {
    padding: 15px;
    margin-top: 20px;
    border: 1px solid var(--color-border-light);
    border-radius: 8px;
    background-color: var(--color-bg-secondary);
    max-height: 250px;
    overflow-y: auto;
}

.selected-regions-display h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-dark);
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--color-border-light);
}

#selectedRegionsList {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 14px;
    color: var(--color-text-subtle);
}

#selectedRegionsList li {
    padding: 3px 0;
    display: block;
}

.summary-metrics {
    padding-top: 15px;
    border-top: 1px solid var(--color-border-light);
    margin-top: 15px;
}

.summary-metrics p {
    display: flex;
    justify-content: space-between;
    font-weight: 500;
    color: var(--color-text-dark);
    margin-bottom: 8px;
}

.summary-metrics span {
    font-weight: 700;
    color: var(--color-primary);
}

/* --- Total Price Area --- */
.total-price-area {
    text-align: center;
    padding: 20px 0;
}

.total-price-area>p:first-child {
    font-size: 16px;
    color: var(--color-text-subtle);
    margin-bottom: 5px;
}

.total-price {
    font-size: 42px;
    font-weight: 900;
    color: var(--color-primary);
    line-height: 1.1;
    margin-bottom: 20px;
}

.total-price .currency {
    font-size: 0.7em;
    font-weight: 700;
    margin-right: 5px;
}

.btn-checkout {
    display: block;
    width: 100%;
    padding: 12px 15px;
    background: var(--brand-gradient);
    color: white;
    text-align: center;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 18px;
    letter-spacing: 0.5px;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s, box-shadow 0.2s, transform 0.1s;
}

.btn-checkout:hover {
    opacity: 0.9;
    box-shadow: 0 5px 15px rgba(0, 191, 255, 0.4);
    transform: translateY(-1px);
}

.btn-checkout:disabled {
    background: var(--color-border-light);
    color: var(--color-text-subtle);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.note {
    font-size: 12px;
    color: #94a3b8;
    text-align: center;
    margin-top: 20px;
}


/* ------------------------------------------------------------------- */
/* --- 7. Responsive Adjustments --- */
/* ------------------------------------------------------------------- */
@media (max-width: 992px) {
    .calculator-wrapper {
        flex-direction: column;
    }

    .region-selection-panel,
    .order-summary-panel {
        flex: none;
        width: 100%;
    }

    .order-summary-panel {
        position: static;
        top: auto;
    }

    /* Keep 4 columns on tablets/smaller desktops */
    .region-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .region-grid {
        /* Reduce to 3 columns on smaller tablets */
        grid-template-columns: repeat(3, 1fr);
    }

    .ip-quantity-control {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .region-grid {
        /* Reduce to 2 columns on mobile */
        grid-template-columns: repeat(2, 1fr);
    }

    .duration-tabs {
        flex-wrap: wrap;
    }

    .duration-tab-button {
        flex: 1 1 auto;
    }
}