/**
 * フロントエンドスタイル
 * 
 * デフォルトではWordPressテーマのスタイルを継承します。
 * カスタムスタイルが設定されている場合は、それらが適用されます。
 */

.gsheet-table-container {
    margin-top: 20px;
    margin-bottom: 0;
}

/* テーマスタイルを継承（デフォルト） */
.gsheet-table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px;
    /* テーマの背景色を継承 */
    background: inherit;
    border-radius: 4px;
}

.gsheet-table-global-filter-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.gsheet-table-global-filter {
    min-width: 220px;
    padding: 8px 12px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
}

.gsheet-table-global-filter:focus {
    outline: none;
    border-color: currentColor;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.08);
}

.gsheet-table-global-filter-clear {
    padding: 6px 16px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 999px;
    background: #f6f6f6;
    color: inherit;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    transition: background 0.2s, border-color 0.2s, opacity 0.2s;
    min-width: 64px;
    text-align: center;
    white-space: nowrap;
}

.gsheet-table-global-filter-clear:hover {
    background: #ededed;
    border-color: rgba(0, 0, 0, 0.35);
}

.gsheet-table-toggle-advanced-filters {
    margin-left: 0;
    white-space: nowrap;
}

.gsheet-table-search {
    flex: 1;
    max-width: 300px;
}

.gsheet-table-search-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.gsheet-table-export {
    display: flex;
    gap: 10px;
}

.gsheet-table-export-btn {
    padding: 8px 16px;
    /* テーマのボタンスタイルを継承 */
    background: inherit;
    color: inherit;
    border: 1px solid currentColor;
    border-color: inherit;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: opacity 0.3s;
}

.gsheet-table-export-btn:hover {
    /* テーマのホバースタイルを継承 */
    opacity: 0.8;
}

.gsheet-table-wrapper {
    overflow-x: auto;
    /* テーマのボーダー色を継承 */
    border: 1px solid currentColor;
    border-color: inherit;
    border-radius: 4px;
    /* テーブルラッパーの下の余分な空白を防ぐ */
    margin-bottom: 0 !important;
    padding-bottom: 0;
}

.gsheet-table {
    width: 100%;
    border-collapse: collapse;
    /* テーマの背景色を継承 */
    background: inherit;
    /* テーブルの下の余分な空白を防ぐ */
    margin-bottom: 0 !important;
    margin-top: 0;
}

.gsheet-table thead {
    /* テーマの背景色を継承（デフォルトは薄いグレー） */
    background: rgba(0, 0, 0, 0.02);
}

.gsheet-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    /* テーマのボーダー色を継承 */
    border-bottom: 2px solid currentColor;
    border-color: inherit;
    position: relative;
    vertical-align: top;
}

/* フィルタセル */
.gsheet-table-filter-cell {
    margin-top: 8px;
    display: flex;
    gap: 5px;
    align-items: center;
}

.gsheet-table-filter-input {
    flex: 1;
    padding: 4px 8px;
    /* テーマの入力欄スタイルを継承 */
    border: 1px solid currentColor;
    border-color: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
    font-size: 12px;
    min-width: 80px;
}

.gsheet-table-filter-input:focus {
    outline: none;
    /* テーマのフォーカススタイルを継承 */
    border-color: currentColor;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.gsheet-table-filter-clear {
    padding: 2px 6px;
    /* テーマのボタンスタイルを継承 */
    background: inherit;
    color: inherit;
    border: 1px solid currentColor;
    border-color: inherit;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    min-width: 20px;
}

.gsheet-table-filter-clear:hover {
    /* テーマのホバースタイルを継承 */
    opacity: 0.8;
}

/* ローディング・エラー表示 */
.gsheet-table-loading,
.gsheet-table-error,
.gsheet-table-no-data {
    padding: 20px;
    text-align: center;
    color: #666;
}

.gsheet-table-error {
    color: #dc3232;
}

.gsheet-table th:hover {
    background: #f0f0f0;
}

.gsheet-table th.sortable::after {
    content: ' ↕';
    opacity: 0.5;
    font-size: 12px;
}

.gsheet-table th.sort-asc::after {
    content: ' ↑';
    opacity: 1;
}

.gsheet-table th.sort-desc::after {
    content: ' ↓';
    opacity: 1;
}

.gsheet-table td {
    padding: 10px 12px;
    /* テーマのボーダー色を継承（デフォルトは薄いグレー） */
    border-bottom: 1px solid currentColor;
    border-color: rgba(0, 0, 0, 0.1);
}

/* 最後の行のセルの下の余分な空白を防ぐ */
.gsheet-table tbody tr:last-child td {
    padding-bottom: 10px !important;
    margin-bottom: 0 !important;
}

/* テーブルの直後に余分な要素が追加されないようにする */
.gsheet-table-wrapper::after {
    content: '';
    display: none;
}

/* WordPressのwpautopやテーマによる余分な段落を非表示 */
.gsheet-table-container + p:empty,
.gsheet-table-container + p:only-child:empty,
.gsheet-table-wrapper + p:empty,
.gsheet-table-wrapper + p:only-child:empty {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
    height: 0 !important;
    line-height: 0 !important;
}

/* テーマのCSS干渉を防ぐ（より強力な指定） */
.gsheet-table-container {
    /* テーマの段落スタイルの影響を防ぐ */
    display: block;
    clear: both;
}

/* テーブルコンテナの直後の空の段落や改行を非表示 */
.gsheet-table-container ~ p:empty,
.gsheet-table-container ~ br {
    display: none !important;
}

.gsheet-table tbody tr:hover {
    /* テーマのホバー背景色を継承 */
    background: rgba(0, 0, 0, 0.02);
}

/* カスタムスタイル用のクラス（管理画面で設定された場合に適用） */
.gsheet-table-custom-style {
    /* カスタムスタイルはインラインスタイルで適用されます */
}

/* カスタムスタイルが有効な場合、テーマのスタイルを上書き */
.gsheet-table-custom-style .gsheet-table th,
.gsheet-table-custom-style .gsheet-table td {
    /* インラインスタイルで上書きされるため、ここでは基本設定のみ */
}

/* カスタムスタイルが有効な場合、デフォルトの背景色をリセット */
.gsheet-table-custom-style .gsheet-table thead {
    /* インラインスタイルで上書きされるため、デフォルトの背景色をリセット */
    background: transparent;
}

/* 罫線スタイル（カスタムスタイルが有効な場合） */
.gsheet-table-custom-style.gsheet-table-border-horizontal th,
.gsheet-table-custom-style.gsheet-table-border-horizontal td {
    border-left: none !important;
    border-right: none !important;
    border-top: none !important;
}

.gsheet-table-custom-style.gsheet-table-border-vertical th,
.gsheet-table-custom-style.gsheet-table-border-vertical td {
    border-top: none !important;
    border-bottom: none !important;
}

.gsheet-table-custom-style.gsheet-table-border-none th,
.gsheet-table-custom-style.gsheet-table-border-none td {
    border: none !important;
}

.gsheet-table-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    margin-bottom: 0;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 4px;
}

.gsheet-table-info-text {
    font-size: 14px;
    color: #666;
}

.gsheet-table-pagination-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.gsheet-table-pagination-controls button {
    padding: 6px 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.gsheet-table-pagination-controls button:hover:not(:disabled) {
    background: #f0f0f0;
}

.gsheet-table-pagination-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.gsheet-table-page-numbers {
    display: flex;
    gap: 5px;
}

.gsheet-table-page-numbers button {
    padding: 6px 10px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    min-width: 35px;
}

.gsheet-table-page-numbers button.active {
    /* テーマのアクティブスタイルを継承 */
    background: currentColor;
    color: inherit;
    border-color: currentColor;
    opacity: 0.2;
    font-weight: bold;
}

.gsheet-table-page-size select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

/* ソート機能のスタイル */
.gsheet-table-header-sortable {
    position: relative;
    user-select: none;
}

.gsheet-table-header-sortable:hover {
    background-color: #f0f0f0;
}

.gsheet-table-header-text {
    margin-right: 5px;
}

.gsheet-table-sort-icon {
    font-size: 0.9em;
    color: #666;
    opacity: 0.6;
}

.gsheet-table-header-sortable:hover .gsheet-table-sort-icon {
    opacity: 1;
}

.gsheet-table-sort-icon.sort-asc,
.gsheet-table-sort-icon.sort-desc {
    /* テーマのアクティブ色を継承 */
    color: currentColor;
    opacity: 1;
    font-weight: bold;
}

/* レスポンシブ */
@media (max-width: 768px) {
    .gsheet-table-toolbar {
        flex-direction: column;
        gap: 10px;
    }
    
    .gsheet-table-search {
        max-width: 100%;
    }
    
    .gsheet-table-pagination {
        flex-direction: column;
        gap: 10px;
    }
}

