/* ========== 銘柄別日記リストモーダル（共通スタイル） ========== */

/* モーダル全体 */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    overflow-y: auto;
    opacity: 0;
    transition: opacity 0.3s ease;
    -webkit-overflow-scrolling: touch;
}

.modal-overlay.active {
    display: block;
    opacity: 1;
}

/* モーダルコンテナ */
.modal-container {
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 60px 12px 20px;
}

/* モーダルコンテンツ */
.modal-content {
    background-color: var(--card, #1e293b);
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: calc(100vh - 80px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border, #334155);
    transform: scale(0.95);
    transition: transform 0.3s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

/* モーダルヘッダー */
.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border, #334155);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.05));
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(10px);
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--foreground, #f1f5f9);
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.modal-title span:first-child {
    font-size: 24px;
    flex-shrink: 0;
}

.modal-title span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-close {
    background: rgba(239, 68, 68, 0.1);
    border: none;
    color: var(--destructive, #ef4444);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
    line-height: 1;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.modal-close:hover {
    background-color: rgba(239, 68, 68, 0.2);
    transform: rotate(90deg);
}

/* モーダルボディ */
.modal-body {
    padding: 0;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

/* ========== サマリーセクション ========== */
.summary-section {
    padding: 20px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(139, 92, 246, 0.04));
    border-bottom: 1px solid var(--border, #334155);
    position: sticky;
    top: 0;
    z-index: 5;
    backdrop-filter: blur(10px);
}

/* メインメトリクス（ROIと実現損益） */
.main-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.metric-box {
    background: rgba(71, 85, 105, 0.3);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.metric-box.highlight-positive {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.08));
    border-color: rgba(16, 185, 129, 0.3);
}

.metric-box.highlight-negative {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.08));
    border-color: rgba(239, 68, 68, 0.3);
}

.metric-box-label {
    font-size: 11px;
    color: var(--muted, #94a3b8);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.metric-box-value {
    font-size: 28px;
    font-weight: 800;
    line-height: 1.2;
}

.metric-box-value.positive {
    color: var(--success, #10b981);
}

.metric-box-value.negative {
    color: var(--destructive, #ef4444);
}

.metric-box-unit {
    font-size: 14px;
    font-weight: 400;
    color: var(--muted, #94a3b8);
    margin-left: 4px;
}

/* サブメトリクス */
.sub-metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 16px;
    background: rgba(71, 85, 105, 0.2);
    border-radius: 12px;
}

.sub-metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sub-metric-label {
    font-size: 10px;
    color: var(--muted, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sub-metric-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--foreground, #f1f5f9);
}

.sub-metric-value .unit {
    font-size: 11px;
    font-weight: 400;
    color: var(--muted, #94a3b8);
    margin-left: 2px;
}

/* メタ情報 */
.summary-meta {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(71, 85, 105, 0.3);
    font-size: 11px;
    color: var(--muted, #94a3b8);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.summary-badge {
    background: rgba(59, 130, 246, 0.2);
    color: var(--primary, #3b82f6);
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 10px;
}

/* ========== 詳細リスト ========== */
.detail-list {
    padding: 16px;
}

.detail-card {
    background: rgba(71, 85, 105, 0.2);
    border: 1px solid var(--border, #334155);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.detail-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(to bottom, var(--primary, #3b82f6), var(--secondary, #8b5cf6));
    opacity: 0;
    transition: opacity 0.2s;
}

.detail-card:hover {
    background: rgba(71, 85, 105, 0.35);
    border-color: var(--primary, #3b82f6);
    transform: translateX(4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.detail-card:hover::before {
    opacity: 1;
}

.detail-card:active {
    transform: translateX(2px) scale(0.98);
}

/* カードヘッダー */
.detail-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 12px;
}

.detail-card-title {
    flex: 1;
    min-width: 0;
}

.detail-card-name {
    font-weight: 700;
    font-size: 16px;
    color: var(--foreground, #f1f5f9);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.3;
}

.detail-card-meta {
    font-size: 11px;
    color: var(--muted, #94a3b8);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ROIバッジ */
.detail-roi-badge {
    font-weight: 800;
    font-size: 20px;
    padding: 8px 12px;
    border-radius: 8px;
    flex-shrink: 0;
    min-width: 80px;
    text-align: center;
}

.detail-roi-badge.positive {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.25), rgba(16, 185, 129, 0.15));
    color: var(--success, #10b981);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.detail-roi-badge.negative {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.25), rgba(239, 68, 68, 0.15));
    color: var(--destructive, #ef4444);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ステータスバッジ */
.detail-status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    margin-left: 8px;
}

.detail-status-badge.holding {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success, #10b981);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.detail-status-badge.sold {
    background: rgba(100, 116, 139, 0.2);
    color: var(--muted, #94a3b8);
    border: 1px solid rgba(100, 116, 139, 0.3);
}

.detail-status-badge.memo {
    background: rgba(245, 158, 11, 0.2);
    color: var(--accent, #f59e0b);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* カード統計 */
.detail-card-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 12px;
    background: rgba(71, 85, 105, 0.15);
    border-radius: 8px;
}

.detail-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.detail-stat-label {
    font-size: 10px;
    color: var(--muted, #94a3b8);
}

.detail-stat-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--foreground, #f1f5f9);
}

.detail-stat-value.positive {
    color: var(--success, #10b981);
}

.detail-stat-value.negative {
    color: var(--destructive, #ef4444);
}

/* 空状態 */
.empty-message {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted, #94a3b8);
}

.empty-message-icon {
    font-size: 48px;
    opacity: 0.5;
    margin-bottom: 16px;
}

.empty-message-text {
    font-size: 16px;
    font-weight: 600;
}

/* ========== モバイル最適化 ========== */
@media (max-width: 480px) {
    .modal-container {
        padding: 50px 8px 12px;
    }

    .modal-content {
        border-radius: 12px;
        max-height: calc(100vh - 62px);
    }

    .modal-header {
        padding: 14px 16px;
    }

    .modal-title {
        font-size: 16px;
        gap: 8px;
    }

    .modal-title span:first-child {
        font-size: 20px;
    }

    .modal-close {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }

    .summary-section {
        padding: 16px;
    }

    .main-metrics {
        gap: 12px;
        margin-bottom: 16px;
    }

    .metric-box {
        padding: 12px;
    }

    .metric-box-label {
        font-size: 10px;
        margin-bottom: 6px;
    }

    .metric-box-value {
        font-size: 24px;
    }

    .metric-box-unit {
        font-size: 12px;
    }

    .sub-metrics {
        gap: 10px;
        padding: 12px;
    }

    .sub-metric-value {
        font-size: 14px;
    }

    .detail-list {
        padding: 12px;
    }

    .detail-card {
        padding: 12px;
        margin-bottom: 10px;
    }

    .detail-card-header {
        margin-bottom: 10px;
    }

    .detail-card-name {
        font-size: 14px;
    }

    .detail-roi-badge {
        font-size: 18px;
        padding: 6px 10px;
        min-width: 70px;
    }

    .detail-card-stats {
        gap: 6px;
        padding: 10px;
    }

    .detail-stat-value {
        font-size: 13px;
    }
}

/* 極小デバイス */
@media (max-width: 360px) {
    .main-metrics {
        grid-template-columns: 1fr;
    }

    .metric-box-value {
        font-size: 22px;
    }

    .sub-metrics {
        grid-template-columns: 1fr;
    }

    .detail-card-stats {
        grid-template-columns: 1fr;
    }
}

/* 横向きスマホ */
@media (max-width: 767px) and (orientation: landscape) {
    .modal-container {
        padding: 40px 12px 12px;
    }

    .modal-content {
        max-height: calc(100vh - 52px);
    }

    .summary-section {
        position: relative;
    }
}

/* タッチデバイス最適化 */
@media (hover: none) and (pointer: coarse) {
    .detail-card {
        padding: 16px;
        min-height: 44px;
    }

    .detail-card:active {
        background: rgba(71, 85, 105, 0.4);
    }

    .modal-close {
        min-width: 44px;
        min-height: 44px;
    }
}