/* KPG Multi-Tab Selector CSS */
:root {
    --fs-color-primary: #046494;
    --fs-color-secondary: #f45404;
    --fs-color-success: #fdab00;
}

/* Main Container */
.kpg-multi-tab-container {
    margin: 20px 0;
    font-family: Arial, sans-serif;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(4, 100, 148, 0.1);
    background: #fff;
}

/* Tab Navigation */
.kpg-main-tab {
    display: flex;
    flex-wrap: wrap;
    background: linear-gradient(135deg, var(--fs-color-primary) 0%, #0576b8 100%);
    border-bottom: 3px solid var(--fs-color-success);
    position: relative;
    overflow: hidden;
}

.kpg-tab-item {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    padding: 18px 30px;
    cursor: pointer;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    font-size: 15px;
    position: relative;
    flex: 1;
    text-align: center;
    min-width: 140px;
    backdrop-filter: blur(10px);
    overflow: hidden;
}

.kpg-tab-item:last-child {
    border-right: none;
}

.kpg-tab-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.6s;
    z-index: 1;
}

.kpg-tab-item:hover::before {
    left: 100%;
}

.kpg-tab-item:hover {
    background: rgba(244, 84, 4, 0.2);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(244, 84, 4, 0.3);
}

.kpg-tab-item.active {
    background: var(--fs-color-success);
    color: #fff;
    font-weight: 700;
    box-shadow: inset 0 -4px 0 rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.kpg-tab-item.active:hover {
    background: #e09900;
    transform: translateY(-2px);
}

/* Active tab indicator */
.kpg-tab-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 4px;
    background: var(--fs-color-secondary);
    transition: width 0.3s ease;
    border-radius: 2px 2px 0 0;
}

.kpg-tab-item.active::after {
    width: 80%;
}

/* Content Container */
.kpg-tab-content-container {
    position: relative;
    min-height: 400px;
    background: #fff;
}

.kpg-tab-content {
    display: none;
    padding: 25px;
    animation: fadeInUp 0.5s ease-out;
}

.kpg-tab-content.active {
    display: block;
}

/* Version Sections */
.kpg-version-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.kpg-version-section {
    background: #f8f9fc;
    border-radius: 0;
    padding: 0;
    border-left: none;
    position: relative;
    overflow: hidden;
}

.kpg-version-title {
    color: var(--fs-color-primary);
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--fs-color-success);
    display: inline-block;
}

/* School Title */
.kpg-school-title {
    color: var(--fs-color-primary);
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 15px 0;
    text-shadow: 0 2px 4px rgba(4, 100, 148, 0.1);
}

/* Exchange Rate */
.kpg-exchange-rate {
    color: var(--fs-color-secondary);
    font-weight: 600;
    font-size: 14px;
    text-align: right;
    margin: 10px 0;
    padding: 8px 12px;
    background: #f0f0f0;
    border-radius: 0;
    border-left: 5px solid #056597;
}

/* Loading States */
.kpg-loading, .kpg-loading-v2 {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    background: linear-gradient(135deg, #f8f9fc 0%, #e8f4f8 100%);
    border-radius: 12px;
    border: 2px dashed var(--fs-color-primary);
    margin: 20px 0;
}

.kpg-loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(4, 100, 148, 0.2);
    border-left: 4px solid var(--fs-color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

.kpg-loading-text {
    color: var(--fs-color-primary);
    font-weight: 600;
    font-size: 16px;
    text-align: center;
}

/* Error States */
.kpg-error {
    text-align: center;
    padding: 40px 20px;
    font-size: 16px;
    color: #dc3545;
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    border: 2px solid #f5c6cb;
    border-radius: 12px;
    margin: 20px 0;
    line-height: 1.6;
}

.kpg-error::before {
    content: "⚠️ ";
    font-size: 24px;
    display: block;
    margin-bottom: 10px;
}

.kpg-error small {
    display: block;
    margin-top: 15px;
    font-size: 12px;
    color: #6c757d;
    word-break: break-all;
    opacity: 0.8;
}

/* Table Integration with Mobile Scrolling Support */
.kpg-tab-content .table-wrapper {
    margin-top: 15px;
    border-radius: 8px;
    overflow-x: auto; /* Enable horizontal scrolling */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.kpg-tab-content .beautiful-table {
    margin: 0;
    border-radius: 0;
    min-width: 100%; /* Ensure table uses minimum full width */
}

.kpg-tab-content .beautiful-table thead tr {
    background: linear-gradient(135deg, var(--fs-color-primary) 0%, #0576b8 100%);
}

.kpg-tab-content .beautiful-table tbody tr:hover {
    background-color: rgba(4, 100, 148, 0.05);
}

.kpg-tab-content .total-row td {
    background: #5f6368;
    color: white;
    font-weight: bold;
}

.kpg-tab-content .note-container {
    border-left: 5px solid #056597;
    background: #f0f0f0;
    border-radius: 0;
}

.kpg-tab-content .note-title {
    color: var(--fs-color-secondary);
}

/* Note content styling with improved mobile spacing */
.kpg-tab-content .note-content {
    margin-left: 15px; /* Move content slightly right */
    padding-left: 10px;
    line-height: 1.6;
}

/* Hide additional info (Course, Accommodation, Period) */
.kpg-additional-info {
    display: none !important;
}

/* Type 3 Items */
.kpg-tab-content .type-3-item {
    background: #fff;
    border: 1px solid rgba(4, 100, 148, 0.2);
    border-radius: 0;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 15px rgba(4, 100, 148, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.kpg-tab-content .type-3-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 25px rgba(4, 100, 148, 0.15);
}

.kpg-tab-content .type-3-item h3 {
    color: var(--fs-color-primary);
    margin-top: 0;
    font-size: 20px;
}

/* ========================================
   Room Tabs Styling (เพิ่มใหม่)
   ======================================== */

/* Room Tabs Container - ใช้ใน multi-tab selector */
.kpg-tab-content .room-tabs-container {
    margin: 15px 0;
    font-family: Arial, sans-serif;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 15px rgba(4, 100, 148, 0.08);
    background: #fff;
}

/* Room Tab Navigation */
.kpg-tab-content .room-tabs-container .kpg-main-tab {
    display: flex;
    flex-wrap: wrap;
    background: linear-gradient(135deg, #056597 0%, #0576b8 100%);
    border-bottom: 2px solid #fdab00;
    position: relative;
    overflow: hidden;
}

.kpg-tab-content .room-tabs-container .kpg-tab-item {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    padding: 12px 20px;
    cursor: pointer;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    font-weight: 600;
    font-size: 13px;
    position: relative;
    flex: 1;
    text-align: center;
    min-width: 100px;
    backdrop-filter: blur(10px);
}

.kpg-tab-content .room-tabs-container .kpg-tab-item:last-child {
    border-right: none;
}

.kpg-tab-content .room-tabs-container .kpg-tab-item:hover {
    background: rgba(244, 84, 4, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(244, 84, 4, 0.2);
}

.kpg-tab-content .room-tabs-container .kpg-tab-item.active {
    background: #fdab00;
    color: #fff;
    font-weight: 700;
    box-shadow: inset 0 -3px 0 rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.kpg-tab-content .room-tabs-container .kpg-tab-item.active:hover {
    background: #e09900;
    transform: translateY(-1px);
}

/* Room Tab Content Container */
.kpg-tab-content .room-tabs-container .kpg-tab-content-container {
    position: relative;
    min-height: 300px;
    background: #fff;
}

.kpg-tab-content .room-tabs-container .kpg-tab-content {
    display: none;
    padding: 15px;
    animation: fadeInUp 0.3s ease-out;
}

.kpg-tab-content .room-tabs-container .kpg-tab-content.active {
    display: block;
}

/* Room Tab Table Integration */
.kpg-tab-content .room-tabs-container .table-wrapper {
    margin-top: 0;
    border-radius: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 1px 8px rgba(0,0,0,0.08);
}

.kpg-tab-content .room-tabs-container .beautiful-table {
    margin: 0;
    border-radius: 0;
    min-width: 100%;
}

.kpg-tab-content .room-tabs-container .beautiful-table thead tr {
    background: linear-gradient(135deg, #056597 0%, #0576b8 100%);
}

.kpg-tab-content .room-tabs-container .beautiful-table tbody tr:hover {
    background-color: rgba(4, 100, 148, 0.05);
}

.kpg-tab-content .room-tabs-container .total-row td {
    background: #5f6368;
    color: white;
    font-weight: bold;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Responsive Design */
@media (max-width: 768px) {
    .kpg-main-tab {
        flex-direction: column;
    }
    
    .kpg-tab-item {
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.2);
        flex: none;
        text-align: center;
        padding: 15px 20px;
    }
    
    .kpg-tab-item:last-child {
        border-bottom: none;
    }
    
    .kpg-version-container {
        gap: 20px;
    }
    
    .kpg-version-section {
        padding: 20px;
    }
    
    .kpg-tab-content {
        padding: 10px; /* Reduce padding on mobile */
    }

    /* Mobile specific exchange rate */
    .kpg-exchange-rate {
        font-size: 12px; /* Smaller font size on mobile */
    }

    /* Mobile specific table wrapper */
    .kpg-tab-content .table-wrapper {
        border-radius: 0; /* Remove border radius on mobile */
    }

    /* Enhanced horizontal scrolling for mobile */
    .kpg-tab-content .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        scrollbar-width: thin; /* Firefox */
    }

    /* Custom scrollbar for webkit browsers */
    .kpg-tab-content .table-wrapper::-webkit-scrollbar {
        height: 8px;
    }

    .kpg-tab-content .table-wrapper::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 4px;
    }

    .kpg-tab-content .table-wrapper::-webkit-scrollbar-thumb {
        background: var(--fs-color-primary);
        border-radius: 4px;
    }

    .kpg-tab-content .table-wrapper::-webkit-scrollbar-thumb:hover {
        background: #044a73;
    }

    /* Note content mobile adjustments */
    .kpg-tab-content .note-content {
        font-size: 10px;
        margin-left: 0; /* Reset margin on mobile */
        padding-left: 0; /* Reset padding on mobile */
        line-height: 1.4;
    }

    /* Room Tabs Mobile Styles */
    .kpg-tab-content .room-tabs-container .kpg-main-tab {
        flex-direction: column;
    }
    
    .kpg-tab-content .room-tabs-container .kpg-tab-item {
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.2);
        flex: none;
        text-align: center;
        padding: 10px 15px;
        font-size: 12px;
    }
    
    .kpg-tab-content .room-tabs-container .kpg-tab-item:last-child {
        border-bottom: none;
    }
    
    .kpg-tab-content .room-tabs-container .kpg-tab-content {
        padding: 10px;
    }

    .kpg-tab-content .room-tabs-container .table-wrapper {
        border-radius: 0;
    }
}

@media (max-width: 480px) {
    .kpg-tab-item {
        padding: 12px 15px;
        font-size: 14px;
        min-width: 100px;
    }
    
    .kpg-school-title {
        font-size: 20px;
    }
    
    .kpg-version-title {
        font-size: 16px;
    }
    
    .kpg-loading, .kpg-loading-v2 {
        padding: 40px 15px;
    }
    
    .kpg-loading-spinner {
        width: 40px;
        height: 40px;
    }

    /* Additional mobile note styling */
    .kpg-tab-content .note-content {
        margin-left: 0;
        padding-left: 0;
    }

    /* Room Tabs Extra Small Mobile */
    .kpg-tab-content .room-tabs-container .kpg-tab-item {
        padding: 8px 12px;
        font-size: 11px;
        min-width: 80px;
    }
}

/* Enhanced visual effects */
.kpg-tab-item {
    position: relative;
}

.kpg-tab-item:hover {
    position: relative;
    z-index: 2;
}

.kpg-tab-item.active {
    position: relative;
    z-index: 3;
}

/* Smooth content transitions */
.kpg-tab-content {
    transition: opacity 0.3s ease-in-out;
}

.kpg-version-section {
    transition: all 0.3s ease;
}

.kpg-version-section:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(4, 100, 148, 0.1);
}