/* ========================================
   属性テーブル: 基本スタイル
   ======================================== */

#attribute-table-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-top: 1px solid #ddd;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 999;
    display: none;
    flex-direction: column;
    height: 300px;
    min-height: 100px;
    max-height: 75vh;
}

#attribute-table-container.visible {
    display: flex;
}

/* ========================================
   ヘッダー部分
   ======================================== */

.attribute-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
    cursor: move;
    user-select: none;
}

.attribute-table-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.attribute-table-title {
    font-size: 14px;
    font-weight: bold;
    color: #333;
    margin: 0;
}

.attribute-table-record-count {
    font-size: 12px;
    color: #666;
    margin: 0;
}

.attribute-table-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.attribute-table-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.attribute-table-btn:hover {
    background: #e0e0e0;
}

.attribute-table-btn img {
    width: 16px;
    height: 16px;
    display: block;
}

/* ========================================
   タブ部分
   ======================================== */

.attribute-table-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    background: #fafafa;
    border-bottom: 1px solid #ddd;
    overflow-x: auto;
}

.attribute-table-tab {
    padding: 6px 12px;
    background: #ffffff;
    border: 1px solid #ddd;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    font-size: 12px;
    color: #666;
    white-space: nowrap;
    transition: all 0.2s;
}

.attribute-table-tab:hover {
    background: #f0f0f0;
}

.attribute-table-tab.active {
    background: #ffffff;
    border-bottom-color: #ffffff;
    color: #333;
    font-weight: bold;
}

/* ========================================
   テーブルコンテンツ部分
   ======================================== */

.attribute-table-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.attribute-table-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: auto;
}

.attribute-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.attribute-table thead {
    position: sticky;
    top: 0;
    background: #f9f9f9;
    z-index: 10;
}

.attribute-table th {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 2px solid #ddd;
    font-weight: bold;
    color: #333;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.attribute-table th:hover {
    background: #f0f0f0;
}

.attribute-table th .sort-icon {
    margin-left: 4px;
    font-size: 10px;
    color: #999;
    display: inline-block;
    min-width: 10px;
}

.attribute-table th.sorted-asc .sort-icon,
.attribute-table th.sorted-desc .sort-icon {
    color: #333;
}

.attribute-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.attribute-table tbody tr {
    cursor: pointer;
    transition: background 0.2s;
}

.attribute-table tbody tr:hover {
    background: #f5f5f5;
}

.attribute-table tbody tr.highlighted {
    background: #e3f2fd;
}

.attribute-table tbody tr.selected {
    background: #bbdefb;
}

/* ========================================
   ローディング・エラー表示
   ======================================== */

.attribute-table-loading,
.attribute-table-error,
.attribute-table-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
    font-size: 14px;
}

.attribute-table-loading::before {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

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

.attribute-table-error {
    color: #d32f2f;
}

/* ========================================
   リサイズハンドル
   ======================================== */

.attribute-table-resize-handle {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    cursor: ns-resize;
    background: transparent;
}

.attribute-table-resize-handle:hover {
    background: #2196F3;
}

/* ========================================
   チャットインプット調整
   ======================================== */

body.attribute-table-open #chatInputContainer {
    transition: none;
}

/* ========================================
   仮想スクロール用
   ======================================== */

.virtual-scroll-viewport {
    position: relative;
    overflow: auto;
    height: 100%;
}

.virtual-scroll-spacer {
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
}

.virtual-scroll-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
}

/* ========================================
   地物ハイライト
   ======================================== */

.attribute-table-feature-highlight {
    fill: #ff0000 !important;
    fill-opacity: 0.6 !important;
    stroke: #ff0000 !important;
    stroke-width: 3 !important;
}

/* ========================================
   JSON値表示
   ======================================== */

.json-value-link {
    color: #0066cc;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    text-decoration: none;
}

.json-value-link:hover {
    text-decoration: underline;
    color: #0052a3;
}

/* ========================================
   ページネーション
   ======================================== */

.attribute-table-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid #eee;
    background: #fafafa;
}

.pagination-btn {
    padding: 4px 12px;
    background: #ffffff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    color: #333;
    transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    background: #f0f0f0;
    border-color: #bbb;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 12px;
    color: #666;
    padding: 0 8px;
}

/* ========================================
   JSONモーダル
   ======================================== */

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

.json-modal-content {
    background: #ffffff;
    border-radius: 8px;
    max-width: 800px;
    max-height: 80vh;
    width: 90%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.json-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #ddd;
}

.json-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

.json-modal-close {
    background: transparent;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.json-modal-close:hover {
    background: #f0f0f0;
}

.json-modal-body {
    padding: 20px;
    overflow: auto;
    flex: 1;
}

.json-modal-body pre {
    margin: 0;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    color: #333;
    background: #f5f5f5;
    padding: 16px;
    border-radius: 4px;
    overflow-x: auto;
}
