/* 銘柄比較シミュレーター CSS */

:root {
    --stock-a-color: #0d6efd;
    --stock-b-color: #ffc107;
    --card-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

body {
    background-color: #f8f9fa;
    font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
}

/* メインコンテンツ */
.main-content {
    min-height: calc(100vh - 200px);
}

/* ページタイトルヘッダー */
header.text-center {
    padding: 3rem 2rem;
    margin: -1rem -0.75rem 2rem -0.75rem;
}

/* ページタイトル */
.page-title {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.75rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    padding: 2rem 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

/* メインボタン（タイトルと同じグラデーション） */
.btn-gradient-green {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    border: none;
    color: white;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-gradient-green.btn-lg {
    min-width: 360px;
    padding: 1rem 2rem;
    font-size: 1.25rem;
    border-radius: 0.75rem;
}

.btn-gradient-green:hover {
    background: linear-gradient(135deg, #218838 0%, #1aa179 100%);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
}

.btn-gradient-green:active {
    background: linear-gradient(135deg, #1e7e34 0%, #17926d 100%);
    color: white;
    transform: translateY(0);
}

.btn-gradient-green:focus {
    box-shadow: 0 0 0 0.25rem rgba(40, 167, 69, 0.5);
}

/* フローティング実行ボタンの改行防止 */
#floatingCompareBtn {
    white-space: nowrap;
}

@media (max-width: 360px) {
    #floatingCompareBtn {
        font-size: 0.95rem;
        padding: 0.6rem 1rem;
    }
}

.page-title i {
    color: white;
}

header.text-center .lead {
    color: rgba(0, 0, 0, 0.7);
    opacity: 0.95;
}

header.text-center .badge {
    background-color: rgba(40, 167, 69, 0.2) !important;
    color: #28a745;
    border: 1px solid rgba(40, 167, 69, 0.3);
}

@media (max-width: 768px) {
    header.text-center {
        padding: 2rem 1rem;
    }

    .page-title {
        font-size: 1.5rem;
        padding: 1.5rem 1rem;
    }

    /* ボタンのスマホ表示対応 */
    .btn-gradient-green.btn-lg {
        min-width: calc(100% - 20px);
        font-size: 1.125rem;
        padding: 0.875rem 1.5rem;
    }
}

/* カード共通スタイル */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.card-header {
    border-radius: 12px 12px 0 0 !important;
    font-weight: 600;
    padding: 1rem 1.5rem;
}

/* 比較サマリーの有利アイコン */
.advantage-icon-inline {
    display: inline-flex;
    align-items: center;
    margin-right: 0.4rem;
    font-size: 1.1rem;
    line-height: 1;
}

.advantage-icon-inline .bi-trophy-fill {
    color: #ffc107;
}

.advantage-icon-inline .bi-dash-circle {
    color: #6c757d;
}

/* 内訳コンテンツのスタイル */
.breakdown-content {
    background-color: #f8f9fa;
    border-radius: 8px;
    border-left: 3px solid #dee2e6;
}

/* 折りたたみボタンのアイコンアニメーション */
.btn[data-bs-toggle="collapse"] .bi-chevron-right {
    transition: transform 0.2s ease;
}

.btn[data-bs-toggle="collapse"][aria-expanded="true"] .bi-chevron-right {
    transform: rotate(90deg);
}

/* 銘柄カードスタイル */
.stock-card-a {
    border-left: 4px solid var(--stock-a-color) !important;
}

.stock-card-b {
    border-left: 4px solid var(--stock-b-color) !important;
}

.stock-card-a .card-header {
    background-color: rgba(13, 110, 253, 0.1);
    color: var(--stock-a-color);
}

.stock-card-b .card-header {
    background-color: rgba(255, 193, 7, 0.1);
    color: var(--stock-b-color);
}

/* モバイルタブ表示制御 */
@media (max-width: 991.98px) {

    /* モバイルではタブで切り替え */
    #mobile-meigara-a,
    #mobile-meigara-b {
        display: none;
        width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
    }

    #mobile-meigara-a.active,
    #mobile-meigara-b.active {
        display: block;
    }

    .mobile-tabs {
        border-bottom: none;
        gap: 0.5rem;
        margin-bottom: 0 !important;
    }

    .mobile-tabs .nav-link {
        font-weight: 600;
        font-size: 1.1rem;
        color: #6c757d;
        border: 2px solid #dee2e6;
        border-radius: 12px 12px 0 0;
        border-bottom: none;
        padding: 1rem 1.5rem;
        transition: all 0.3s;
        background-color: #fff;
    }

    /* 銘柄Aのタブスタイル */
    .mobile-tabs #mobile-tab-a {
        border-color: #0d6efd;
        color: #0d6efd;
    }

    .mobile-tabs #mobile-tab-a.active {
        background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
        color: white;
        border-color: #0d6efd;
        box-shadow: none;
    }

    /* 銘柄Bのタブスタイル */
    .mobile-tabs #mobile-tab-b {
        border-color: #ffc107;
        color: #cc9a06;
    }

    .mobile-tabs #mobile-tab-b.active {
        background: linear-gradient(135deg, #ffc107 0%, #ffb300 100%);
        color: #000;
        border-color: #ffc107;
        box-shadow: none;
    }

    /* カードとタブを繋げる */
    #mobile-meigara-a .card {
        border-radius: 0 12px 12px 12px;
        margin-top: -2px;
        transition: all 0.3s ease;
    }

    #mobile-meigara-b .card {
        border-radius: 0 12px 12px 12px;
        margin-top: -2px;
        transition: all 0.3s ease;
    }

    /* 選択中のカードを強調表示 */
    #mobile-meigara-a.active .card {
        border: 3px solid #0d6efd !important;
        box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.25), 0 8px 16px rgba(13, 110, 253, 0.2);
    }

    #mobile-meigara-b.active .card {
        border: 3px solid #ffc107 !important;
        box-shadow: 0 0 0 4px rgba(255, 193, 7, 0.25), 0 8px 16px rgba(255, 193, 7, 0.2);
    }
}

@media (min-width: 992px) {

    /* デスクトップでは横並び */
    .mobile-tabs {
        display: none !important;
    }

    #mobile-meigara-a,
    #mobile-meigara-b {
        display: block !important;
    }
}

/* フォームコントロール */
.form-control,
.form-select {
    border-radius: 8px;
    border: 1px solid #dee2e6;
    padding: 0.5rem 0.75rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus,
.form-select:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #495057;
}

/* スイッチスタイル */
.form-check-input {
    cursor: pointer;
    width: 3rem;
    height: 1.5rem;
}

.form-check-label {
    cursor: pointer;
    margin-left: 0.5rem;
}

/* ボタンスタイル */
.btn {
    border-radius: 8px;
    padding: 0.625rem 1.5rem;
    font-weight: 500;
    transition: all 0.2s;
    touch-action: manipulation;
    user-select: none;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* 結果サマリーカード */
.summary-card-a {
    background: linear-gradient(135deg, rgba(13, 110, 253, 0.1) 0%, rgba(13, 110, 253, 0.05) 100%);
    border-left: 4px solid var(--stock-a-color);
}

.summary-card-b {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.1) 0%, rgba(255, 193, 7, 0.05) 100%);
    border-left: 4px solid var(--stock-b-color);
}

.summary-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #212529;
}

.summary-label {
    font-size: 0.875rem;
    color: #6c757d;
    margin-top: 0.25rem;
}

/* チャートコンテナ */
.chart-container {
    min-height: 400px;
    padding: 1rem;
    background: white;
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

/* トーストスタイル */
.toast {
    border-radius: 8px;
}

.toast-header {
    border-radius: 8px 8px 0 0;
}

/* 比較ラベル */
.vs-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 700;
    font-size: 1.25rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

/* モバイル最適化 */
@media (max-width: 767.98px) {
    .hero-section {
        padding: 2rem 0;
    }

    .hero-section h1 {
        font-size: 1.75rem;
    }

    .hero-section .lead {
        font-size: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    .mb-3 {
        margin-bottom: 1rem !important;
    }

    .summary-value {
        font-size: 1.5rem;
    }

    .chart-container {
        min-height: 300px;
        padding: 0.5rem;
    }

    .fab-container {
        bottom: 1rem;
        right: 1rem;
    }

    .fab {
        width: 48px;
        height: 48px;
    }

    .fab i {
        font-size: 1.25rem;
    }

    .vs-badge {
        display: none;
    }

    /* モバイルでのフォーム調整 */
    .form-control,
    .form-select {
        font-size: 16px;
        /* iOS のズームを防止 */
    }

    /* タッチデバイス最適化 */
    .btn {
        min-height: 44px;
        touch-action: manipulation;
    }

    /* テーブルのモバイル最適化 */
    .table-responsive {
        margin-bottom: 1rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        font-size: 0.75rem;
        min-width: 500px;
    }

    .table th,
    .table td {
        padding: 0.5rem 0.25rem;
        white-space: nowrap;
    }

    .table thead th {
        font-size: 0.7rem;
        padding: 0.5rem 0.25rem;
    }

    /* テーブルの列幅を最適化 */
    .table th:first-child,
    .table td:first-child {
        min-width: 60px;
        position: sticky;
        left: 0;
        background-color: #212529;
        z-index: 1;
    }

    .table tbody td:first-child {
        background-color: #fff;
        font-weight: 600;
    }

    .table-striped tbody tr:nth-of-type(odd) td:first-child {
        background-color: #f2f2f2;
    }

    .table th:not(:first-child),
    .table td:not(:first-child) {
        min-width: 90px;
    }

    /* ボタングループのモバイル最適化 */
    .card-header .btn-group {
        font-size: 0.75rem;
    }

    .card-header .btn-group .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.7rem;
    }

    .card-header .btn-group .btn i {
        font-size: 0.8rem;
    }

    /* スクロールヒント */
    .table-responsive::after {
        content: '→ 横スクロールできます';
        display: block;
        text-align: center;
        font-size: 0.7rem;
        color: #6c757d;
        padding: 0.25rem;
        background: linear-gradient(to right, transparent, #f8f9fa 20%, #f8f9fa 80%, transparent);
    }

    .table-responsive.scrolled::after {
        content: '';
    }
}

input[type="number"],
input[type="text"],
select {
    touch-action: manipulation;
    user-select: none;
}
}

/* タブレット最適化 */
@media (min-width: 768px) and (max-width: 991.98px) {
    .chart-container {
        min-height: 350px;
    }
}

/* 印刷スタイル */
@media print {

    .fab-container,
    .btn {
        display: none !important;
    }

    .card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* アクセシビリティ */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ダークモード対応（将来の拡張用） */
@media (prefers-color-scheme: dark) {
    /* ダークモードスタイルはここに追加 */
}

/* ローディングアニメーション */
.loading-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: #667eea;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ツールチップスタイル */
.tooltip-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    background: #6c757d;
    color: white;
    border-radius: 50%;
    text-align: center;
    font-size: 12px;
    line-height: 16px;
    cursor: help;
    margin-left: 0.25rem;
}

/* 結果エリアのフェードイン */
#result_all {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 広告コンテナ */
.ad-container {
    min-height: 100px;
    margin: 1.5rem 0;
    padding: 1rem;
    background-color: #f8f9fa;
    border: 1px dashed #dee2e6;
    border-radius: 8px;
}

/* レスポンシブ対応: 表示切替ボタン */
@media (max-width: 576px) {

    /* 小さい画面では年ごとテーブル切替ボタンのフォントサイズを縮小 */
    .btn-group-sm>.btn {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
        white-space: nowrap;
    }

    /* アイコンのサイズも調整 */
    .btn-group-sm .bi {
        font-size: 0.75rem;
    }
}

@media (max-width: 768px) and (min-width: 577px) {

    /* 中間サイズの画面では少し縮小 */
    .btn-group-sm>.btn {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
}

.ad-container ins {
    display: block !important;
}

/* 説明セクション */
.info-section {
    margin-top: 2rem;
}

.info-section .card {
    background: linear-gradient(to bottom, #ffffff 0%, #f8f9fa 100%);
}

.info-section h2 {
    color: #495057;
    border-bottom: 2px solid #0d6efd;
    padding-bottom: 0.5rem;
}

.info-section h3 {
    color: #6c757d;
    margin-top: 1rem;
}

.info-section ul li {
    padding: 0.5rem 0;
    line-height: 1.6;
}

.info-section ul li i {
    margin-right: 0.5rem;
}