/**
 * CSS สำหรับปุ่ม Data API และการแสดง Endpoints
 */

/* ปุ่ม Data API */
.data-api-btn {
    background-color: #e91e63;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    position: absolute;
    right: 45px;
    top: 15px;
    z-index: 10;
    font-size: 14px;
    font-weight: normal;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    transition: background-color 0.3s;
}

.data-api-btn:hover {
    background-color: #c2185b;
}

/* Modal สำหรับแสดง API */
.ckan-api-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 20px;
    box-sizing: border-box;
}

.ckan-api-modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.ckan-api-modal-content {
    background-color: white;
    border-radius: 8px;
    width: 100%;
    max-width: 800px;
    height: auto;
    max-height: 80vh;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: apiModalAnimation 0.3s;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@keyframes apiModalAnimation {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

.ckan-api-modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    color: #6b7280;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 1;
}

.ckan-api-modal-close:hover {
    color: #1e3a8a;
}

.ckan-api-modal-title {
    margin: 0;
    padding: 15px 20px;
    border-bottom: 1px solid #e5e7eb;
    color: #e91e63;
    font-weight: 600;
    flex-shrink: 0;
}

.ckan-api-modal-body {
    padding: 20px;
    overflow: auto;
    flex-grow: 1;
    max-height: calc(80vh - 60px);
}

/* API Tabs */
.ckan-api-tabs {
    display: flex;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.ckan-api-tab {
    padding: 8px 15px;
    cursor: pointer;
    border: 1px solid #e5e7eb;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    margin-right: 5px;
    margin-bottom: -1px;
    background-color: #f3f4f6;
    font-weight: 500;
    transition: all 0.2s;
}

.ckan-api-tab:hover {
    background-color: #e5e7eb;
}

.ckan-api-tab.active {
    background-color: white;
    border-color: #e5e7eb;
    border-bottom: 1px solid white;
    color: #e91e63;
}

/* Tab Content */
.ckan-api-tab-content {
    display: none;
    padding: 15px;
    border: 1px solid #e5e7eb;
    border-top: none;
    margin-bottom: 20px;
    background-color: white;
}

.ckan-api-tab-content.active {
    display: block;
}

/* API Table */
.ckan-api-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
    font-size: 14px;
}

.ckan-api-table th,
.ckan-api-table td {
    padding: 10px;
    border: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: top;
    word-break: break-word;
}

.ckan-api-table th {
    background-color: #f3f4f6;
    font-weight: 600;
}

.ckan-api-table tr:nth-child(even) {
    background-color: #f9fafb;
}

.ckan-api-table tr:hover {
    background-color: #f1f9fe;
}

/* API Examples */
.ckan-api-example {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e5e7eb;
}

.ckan-api-example:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.ckan-api-example h3 {
    font-size: 15px;
    margin: 0 0 8px 0;
    color: #374151;
}

.ckan-api-code {
    background-color: #f3f4f6;
    padding: 10px 15px;
    border-radius: 4px;
    font-family: monospace;
    overflow-x: auto;
    white-space: nowrap;
    border: 1px solid #e5e7eb;
}

.ckan-api-code a {
    color: #2563eb;
    text-decoration: none;
    font-size: 13px;
}

.ckan-api-code a:hover {
    text-decoration: underline;
}

/* Code Blocks */
pre {
    margin: 0;
    padding: 15px;
    background-color: #1e293b;
    color: #e5e7eb;
    border-radius: 4px;
    overflow-x: auto;
    font-family: Monaco, Consolas, "Andale Mono", monospace;
    font-size: 13px;
    line-height: 1.5;
}

/* Responsive Design */
@media (max-width: 767px) {
    .data-api-btn {
        position: static;
        display: block;
        margin: 10px 0;
    }
    
    .ckan-api-tabs {
        flex-wrap: wrap;
    }
    
    .ckan-api-tab {
        margin-bottom: 5px;
        font-size: 13px;
        padding: 6px 10px;
    }
}


/**
 * CKAN API Modal CSS
 */

/* API Modal */
.ckan-api-modal {
    display: none;
    position: fixed;
    z-index: 10001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 20px;
    box-sizing: border-box;
}

.ckan-api-modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.ckan-api-modal-content {
    background-color: white;
    border-radius: 8px;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ckan-api-modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    color: #6b7280;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 10;
}

.ckan-api-modal-close:hover {
    color: #1e3a8a;
}

.ckan-api-modal-title {
    margin: 0;
    padding: 15px 20px;
    border-bottom: 1px solid #e5e7eb;
    color: #1e3a8a;
    font-weight: 600;
}

.ckan-api-modal-body {
    flex: 1;
    overflow: auto;
}

/* API Tabs */
.ckan-api-tabs {
    display: flex;
    background-color: #f3f4f6;
    border-bottom: 1px solid #e5e7eb;
}

.ckan-api-tab {
    padding: 12px 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    background-color: transparent;
    border: none;
    transition: all 0.3s;
    position: relative;
}

.ckan-api-tab:hover {
    color: #374151;
    background-color: #e5e7eb;
}

.ckan-api-tab.active {
    color: #1e3a8a;
    background-color: white;
}

.ckan-api-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: #1e3a8a;
}

/* Tab Content */
.ckan-api-tab-content {
    display: none;
    padding: 20px;
}

.ckan-api-tab-content.active {
    display: block;
}

/* API Content Styles */
.ckan-api-tab-content h3 {
    color: #1e3a8a;
    font-size: 16px;
    margin-top: 20px;
    margin-bottom: 10px;
}

.ckan-api-tab-content h3:first-child {
    margin-top: 0;
}

.ckan-api-tab-content p {
    color: #4b5563;
    line-height: 1.6;
    margin-bottom: 15px;
}

.ckan-api-tab-content a {
    color: #2563eb;
    text-decoration: none;
}

.ckan-api-tab-content a:hover {
    text-decoration: underline;
}

/* API Table */
.ckan-api-table-container {
    overflow-x: auto;
    margin-bottom: 20px;
}

.ckan-api-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.ckan-api-table th,
.ckan-api-table td {
    padding: 10px 15px;
    text-align: left;
    border: 1px solid #e5e7eb;
}

.ckan-api-table th {
    background-color: #f3f4f6;
    font-weight: 600;
    color: #374151;
}

.ckan-api-table td code {
    background-color: #f3f4f6;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 13px;
    color: #dc2626;
}

/* Code blocks */
.ckan-api-code {
    background-color: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 15px;
    overflow-x: auto;
}

.ckan-api-code code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    color: #374151;
    word-break: break-all;
}

.ckan-api-code a {
    color: #2563eb;
    text-decoration: none;
    word-break: break-all;
}

.ckan-api-code a:hover {
    text-decoration: underline;
}

/* Example blocks */
.ckan-api-example {
    margin-bottom: 30px;
}

.ckan-api-example h3 {
    background-color: #f3f4f6;
    padding: 8px 15px;
    margin: 0;
    border: 1px solid #e5e7eb;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    font-size: 14px;
}

.ckan-api-example pre {
    margin: 0;
    padding: 15px;
    background-color: #1e293b;
    color: #e2e8f0;
    border: 1px solid #e5e7eb;
    border-radius: 0 0 4px 4px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.5;
}

/* JSON Example */
.ckan-api-json-example {
    background-color: #1e293b;
    color: #e2e8f0;
    padding: 15px;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 15px;
}

/* Responsive */
@media (max-width: 768px) {
    .ckan-api-modal-content {
        max-width: 95%;
        max-height: 95vh;
    }
    
    .ckan-api-tabs {
        flex-wrap: wrap;
    }
    
    .ckan-api-tab {
        flex: 1 0 50%;
        text-align: center;
    }
    
    .ckan-api-tab-content {
        padding: 15px;
    }
    
    .ckan-api-code {
        font-size: 12px;
    }
}