/* assets/css/data.css - 実績データ表用スタイル */

/* ========================================================================
   データページ共通ラッパー（白背景カード）- chart-containerを参考
   ======================================================================== */
.data-wrapper {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    padding: 24px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* ========================================================================
   ヘッダーエリア
   ======================================================================== */
.data-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border);
}

.data-header h2 {
    font-size: 30px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

/* ========================================================================
   セクションタイトル（年別・実現損益実績など）
   ======================================================================== */
.data-section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.data-section-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 20px;
    background: var(--primary);
    border-radius: 2px;
}

/* ========================================================================
   生涯実現損益カード
   ======================================================================== */
.lifetime-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    padding: 12px 16px;
    margin: 0 16px 16px 16px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

[data-theme="dark"] .lifetime-card {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

.lifetime-label {
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    margin-bottom: 8px;
    letter-spacing: 0.05em;
}

[data-theme="dark"] .lifetime-label {
    color: #94a3b8;
}

.lifetime-value {
    font-family: 'Saira', 'Zen Kaku Gothic New', sans-serif;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    white-space: nowrap;
    display: inline-flex;
    align-items: baseline;
    justify-content: center;
}

.lifetime-value.profit {
    color: #dc2626;
    text-shadow: 0 2px 8px rgba(220, 38, 38, 0.15);
}

.lifetime-value.loss {
    color: #16a34a;
    text-shadow: 0 2px 8px rgba(22, 163, 74, 0.15);
}

.lifetime-unit {
    font-size: 14px;
    font-weight: 500;
    margin-left: 4px;
    opacity: 0.7;
    flex-shrink: 0;
}

/* ========================================================================
   テーブルコントロール（並び替え）
   ======================================================================== */
.col-sort {
    padding: 8px !important;
}

.sort-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 16px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sort-toggle:hover {
    background: var(--hover-bg);
    border-color: var(--primary);
    color: var(--primary);
}

[data-theme="dark"] .sort-toggle {
    color: #94a3b8;
}

/* ========================================================================
   データテーブルラッパー
   ======================================================================== */
.data-table-wrapper {
    overflow-x: auto;
    padding: 0 16px;
    /* 左右にマージン */
}

/* ========================================================================
   データテーブル（シンプル＆モダン）
   ======================================================================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 16px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    table-layout: fixed;
    /* 列幅を固定・均等に */
}

.data-table th,
.data-table td {
    padding: 12px 8px;
    text-align: center;
    color: var(--text);
    border: 1px solid var(--border);
    white-space: nowrap;
}

/* ヘッダーセルのみ省略表示 */
.data-table th {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* データセルは省略しない（JSでフォントサイズ調整） */
.data-table td {
    overflow: visible;
}

/* ヘッダー行のスタイル */
.data-table thead tr:first-child th {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    font-weight: 600;
    font-size: 14px;
    color: #475569;
    text-align: center;
    border-bottom: 2px solid var(--border);
    padding: 12px 8px;
}

[data-theme="dark"] .data-table thead tr:first-child th {
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: #94a3b8;
}

/* カテゴリ列はインラインスタイルの背景色を優先 */
.data-table thead th.col-category {
    background-image: none !important;
}

/* listviewテーブルのヘッダーはインラインスタイルを優先 */
.listview-table.data-table thead tr:first-child th {
    background: none;
}

/* 日付ヘッダーはグレー背景 */
.listview-table.data-table thead tr:first-child th.th-date {
    background: #e5e7eb !important;
    color: #1e293b !important;
}

/* 合計ヘッダーはグレー背景 */
.listview-table.data-table thead tr:first-child th.th-total {
    background: #e5e7eb !important;
    color: #1e293b !important;
}

/* PC時は月/日形式を表示、モバイル用日のみ表示は非表示 */
.date-pc {
    display: inline;
}
.date-mobile {
    display: none;
}

/* ダークモード対応 */
[data-theme="dark"] .listview-table.data-table thead tr:first-child th.th-date {
    background: #1e293b !important;
    color: #e2e8f0 !important;
}

[data-theme="dark"] .listview-table.data-table thead tr:first-child th.th-total {
    background: #334155 !important;
    color: #e2e8f0 !important;
}

/* メモヘッダーはグレー背景 */
.listview-table.data-table thead tr:first-child th.th-comment {
    background: #e5e7eb !important;
    color: #1e293b !important;
    min-width: 150px;
    max-width: 250px;
}

[data-theme="dark"] .listview-table.data-table thead tr:first-child th.th-comment {
    background: #334155 !important;
    color: #e2e8f0 !important;
}

/* メモセル */
.listview-table .comment-cell {
    text-align: left;
    white-space: pre-wrap;
    word-break: break-word;
    max-width: 250px;
    min-width: 150px;
    font-size: 12px;
    line-height: 1.4;
    padding: 8px 10px;
    vertical-align: top;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}



/* データ行のスタイル */
.data-table tbody tr {
    transition: background-color 0.2s;
}

.data-table tbody tr:hover {
    background: var(--hover-bg);
}

.data-table tbody td {
    border-bottom: 1px solid var(--border);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* 年列（左端） */
.data-table th:first-child,
.data-table .row-year {
    text-align: center;
    font-weight: 500;
    font-size: 16px;
    color: #475569;
    background: rgba(59, 130, 246, 0.04);
    white-space: nowrap;
    width: 100px;
}

/* 合計列の強調 */
.data-table .col-total,
.data-table .cell-total {
    background: rgba(59, 130, 246, 0.04);
}

/* 数値セルの統一スタイル */
.data-table tbody td,
.data-table tfoot td {
    font-weight: 500;
    font-size: 16px;
}

[data-theme="dark"] .data-table .col-total,
[data-theme="dark"] .data-table .cell-total,
[data-theme="dark"] .data-table th:first-child,
[data-theme="dark"] .data-table .row-year {
    background: rgba(59, 130, 246, 0.08);
}

/* 合計行（tfoot） */
.data-table tfoot tr {
    background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
    border-top: 2px solid var(--border);
}

[data-theme="dark"] .data-table tfoot tr {
    background: linear-gradient(180deg, #1e293b 0%, #334155 100%);
}

/* 明細ヘッダー */
.data-table .col-detail-header {
    text-align: center;
    font-weight: 600;
    color: var(--text-light);
}

/* カテゴリ列 */
.data-table .col-category {
    font-weight: 600;
    min-width: 80px;
    padding: 8px 6px;
    /* 明細は余白を狭く */
    border: 1px solid var(--border);
}

.data-table .cell-category {
    font-size: 16px;
    font-weight: 500;
}

/* 損益色 */
.data-table .profit {
    color: var(--profit);
}

.data-table .loss {
    color: var(--loss);
}

/* 縦罫線（控えめに） */
.data-table td+td,
.data-table th+th {
    border-left: 1px solid var(--border);
}

/* ========================================================================
   サマリーカード（チャートページと共通デザイン）
   ======================================================================== */
.data-summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 20px;
}

.data-summary-card {
    background: var(--hover-bg);
    padding: 16px;
    border-radius: 10px;
    text-align: center;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.data-summary-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.data-summary-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 6px;
}

.data-summary-value {
    font-size: 20px;
    font-weight: 700;
}

.data-summary-value.profit {
    color: var(--profit);
}

.data-summary-value.loss {
    color: var(--loss);
}

/* ========================================================================
   PC用「合計のみ表示」モード
   ======================================================================== */
@media (min-width: 769px) {
    /* ヘッダー：日付列と合計列とメモ列以外を非表示 */
    .total-only .listview-table th:not(.th-date):not(.th-total):not(.th-comment) {
        display: none !important;
    }

    /* データセル：日付列、合計列、メモ列以外を非表示 */
    .total-only .listview-table td:not(.day-cell):not(.daily-total):not(.comment-cell) {
        display: none !important;
    }
}

/* ========================================================================
   レスポンシブ対応
   ======================================================================== */
@media (max-width: 768px) {
    .data-wrapper {
        padding: 16px;
    }

    .data-table-wrapper {
        padding: 12px;
        margin: 0 -8px;
    }

    .data-table th,
    .data-table td {
        padding: 10px 12px;
        font-size: 14px;
    }

    .data-table .cell-total {
        font-size: 16px;
    }

    .data-summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* データなしメッセージ */
.no-data-message {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.no-data-message p:first-child {
    font-size: 24px;
    margin-bottom: 12px;
    color: var(--text);
}

.no-data-hint {
    font-size: 14px;
    opacity: 0.7;
}

/* ========================================================================
   利用規約コンテンツ
   ======================================================================== */
.terms-content {
    line-height: 1.8;
    padding: 16px 32px;
}

.terms-content p {
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--text);
    text-align: justify;
}

.terms-content h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-top: 32px;
    margin-bottom: 12px;
    padding-left: 12px;
    border-left: 4px solid var(--primary);
}

.terms-content h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-top: 20px;
    margin-bottom: 10px;
}

.terms-content ul {
    margin-bottom: 16px;
    padding-left: 24px;
    color: var(--text);
}

.terms-content li {
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.6;
}

.terms-content a {
    color: var(--primary);
    text-decoration: none;
}

.terms-content a:hover {
    text-decoration: underline;
}