.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.beautiful-table {
    width: 100%;
    border-collapse: collapse;
    margin: 25px 0;
    font-size: 14px;
    text-align: left;
    font-weight: bold; /* Make all text in the table bold */
    min-width: 100%; /* Ensure table uses minimum full width */
}

.beautiful-table thead tr {
    background-color: #056597;
    color: #fff;
    text-align: left;
}

.beautiful-table th,
.beautiful-table td {
    padding: 12px 15px;
    border: 1px solid #ddd;
    font-weight: bold; /* Ensure th and td are bold */
    white-space: nowrap; /* Prevent text wrapping for better mobile scroll */
}

/* Allow text wrapping for Type 1 tables to improve mobile display */
.beautiful-table.type-1-table th,
.beautiful-table.type-1-table td {
    white-space: normal; /* Allow text wrapping */
    word-wrap: break-word;
    hyphens: auto;
}

/* Specific styling for course name column in Type 1 tables */
.beautiful-table.type-1-table td:first-child {
    max-width: 200px; /* Limit width to force wrapping */
    line-height: 1.3;
}

/* Header styling for Type 1 tables */
.beautiful-table.type-1-table th {
    line-height: 1.3;
    vertical-align: middle;
}

.beautiful-table tbody tr {
    border-bottom: 1px solid #ddd;
}

.beautiful-table tbody tr:nth-child(even) {
    background-color: #f3f3f3;
}

.beautiful-table tbody tr:hover {
    background-color: #e1f5fe;
    cursor: pointer;
}

.beautiful-table td {
    vertical-align: top;
}

.beautiful-table th {
    background-color: #056597;
    color: #fff !important;
}

.type-2-table th,
.type-2-table td {
    font-size: 10px;
}

/* Center-align the first header row in Type 2 tables */
.type-2-table thead tr:first-child th {
    text-align: center;
}

/* Center-align 'THB' headers in the second header row for Type 2 tables */
.type-2-table thead tr:nth-child(2) th:nth-child(2n) {
    text-align: center;
}

.note-container {
    margin-top: 20px;
    padding: 15px;
    background-color: #f9f9f9;
    border-left: 5px solid #056597;
    font-size: 16px;
}

.note-title {
    font-weight: bold;
    color: #056597;
    margin-bottom: 10px;
}

.note-content {
    color: #333;
    line-height: 1.6;
    margin-left: 15px; /* Add left margin for better spacing */
    padding-left: 10px;
}

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

.type-3-container {
    display: flex;
    flex-wrap: wrap;
}

.type-3-item {
    flex: 1;
    margin-right: 20px;
    margin-bottom: 20px;
}

/* Loading and Error state styling */
.loading {
    text-align: center;
    padding: 40px 20px;
    font-size: 16px;
    color: #6c757d;
    background-color: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    margin: 20px 0;
}

.loading:before {
    content: "⏳ ";
    font-size: 20px;
    margin-right: 10px;
}

.error {
    text-align: center;
    padding: 40px 20px;
    font-size: 16px;
    color: #dc3545;
    background-color: #f8d7da;
    border: 2px solid #f5c6cb;
    border-radius: 8px;
    margin: 20px 0;
    line-height: 1.5;
}

.error:before {
    content: "⚠️ ";
    font-size: 20px;
    margin-right: 10px;
}

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

/* Selector integration */
.tsp-table-selector-container .table-wrapper {
    margin-top: 0;
}

.tsp-table-selector-container .beautiful-table {
    margin-top: 10px;
}

.tsp-table-selector-container h1 {
    margin-top: 0;
    margin-bottom: 15px;
}

.tsp-table-selector-container h2 {
    margin-top: 0;
    margin-bottom: 10px;
}

/* Mobile specific styles */
@media (max-width: 768px) {
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

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

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

    .table-wrapper::-webkit-scrollbar-thumb {
        background: #056597;
        border-radius: 4px;
    }

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

    /* Mobile note content styling */
    .note-content {
        font-size: 10px;
        margin-left: 20px;
        padding-left: 15px;
        line-height: 1.4;
    }

    .beautiful-table th,
    .beautiful-table td {
        padding: 8px 12px; /* Reduce padding on mobile */
        font-size: 12px; /* Slightly smaller font on mobile */
    }

    .type-2-table th,
    .type-2-table td {
        font-size: 9px; /* Smaller font for type-2 tables on mobile */
    }

    /* Enhanced mobile styling for Type 1 tables */
    .beautiful-table.type-1-table th,
    .beautiful-table.type-1-table td {
        padding: 6px 8px; /* Reduce padding more on mobile */
        font-size: 11px; /* Smaller font for better fit */
    }

    .beautiful-table.type-1-table td:first-child {
        max-width: 150px; /* Reduce max width on mobile */
    }
}

@media (max-width: 480px) {
    .note-content {
        margin-left: 25px;
        padding-left: 20px;
    }

    .beautiful-table th,
    .beautiful-table td {
        padding: 6px 10px; /* Further reduce padding on small mobile */
        font-size: 11px;
    }

    .type-2-table th,
    .type-2-table td {
        font-size: 8px; /* Even smaller font for type-2 tables on small mobile */
    }

    /* Extra small mobile styling for Type 1 tables */
    .beautiful-table.type-1-table th,
    .beautiful-table.type-1-table td {
        padding: 4px 6px; /* Further reduce padding */
        font-size: 10px; /* Even smaller font */
    }

    .beautiful-table.type-1-table td:first-child {
        max-width: 120px; /* Further reduce max width */
    }
}