/* ==========================================================================
   配当・分配金シミュレーター - モダンスタイル v2.0
   ========================================================================== */

/* カラーパレット */
:root {
    --primary-color: #0d6efd;
    --success-color: #198754;
    --info-color: #0dcaf0;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-bg: #f8f9fa;
    --dark-text: #212529;
    --muted-text: #6c757d;
    --border-color: #dee2e6;
    --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --shadow-md: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
}

/* 基本スタイル */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--dark-text);
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
}

.main-content {
    background-color: transparent;
}

/* ナビゲーションバー */
.navbar {
    backdrop-filter: blur(10px);
    background-color: rgba(248, 249, 250, 0.95) !important;
}

.navbar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color) !important;
}

/* ヘッダー */
.page-title {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem 1.5rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    font-size: 1.75rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    animation: fadeInDown 0.6s ease-out;
}

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

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

.lead {
    font-size: 1.125rem;
    font-weight: 400;
}

.badge {
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-weight: 500;
}

/* カードスタイル */
.card {
    border: none;
    border-radius: 1rem;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-header {
    font-weight: 600;
    border-bottom: none;
    padding: 1rem 1.5rem;
}

.card-body {
    padding: 1.5rem;
}

/* 設定グループ */
.setting-group {
    position: relative;
    padding: 1rem 0;
}

.divider {
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border-color), transparent);
    margin: 1.5rem 0;
}

/* フォームラベル */
.col-form-label {
    font-weight: 600;
    color: var(--dark-text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-left: none;
    padding-left: 0;
}

.col-form-label i {
    font-size: 1.25rem;
}

/* フォーム要素 */
.form-control,
.form-select {
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.625rem 0.875rem;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

.form-control.fw-bold {
    font-size: 1.125rem;
}

.input-group-text {
    background-color: var(--light-bg);
    border: 2px solid var(--border-color);
    border-left: none;
    font-weight: 500;
    color: var(--muted-text);
}

/* ボタンスタイル */
.btn {
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.btn-outline-secondary {
    border-color: var(--border-color);
    color: var(--muted-text);
    min-width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.375rem 0.625rem;
    white-space: nowrap;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn-outline-secondary:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

.btn-outline-secondary:active {
    transform: scale(0.95);
}

.btn-outline-danger {
    border-color: var(--danger-color);
    color: var(--danger-color);
}

.btn-outline-danger:hover {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
    color: white;
}

.calculate-btn {
    min-width: 360px;
    padding: 1rem 2rem;
    font-size: 1.25rem;
    font-weight: 600;
    border-radius: 0.75rem;
    background: linear-gradient(135deg, #668eea 0%, #667eea 100%);
    border: none;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
}

.calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 1rem 3rem rgba(102, 126, 234, 0.4);
}

.calculate-btn:active {
    transform: translateY(0);
}

/* スライダー */
.form-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #dee2e6;
    outline: none;
    padding: 0;
    margin: 10px 0;
}

/* Webkit (Chrome, Safari, Edge) */
.form-range::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    cursor: pointer;
    background: transparent;
    border-radius: 5px;
}

.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d6efd 0%, #0056b3 100%);
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    margin-top: -8px;
    /* (24px - 8px) / 2 */
}

.form-range::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Firefox */
.form-range::-moz-range-track {
    width: 100%;
    height: 8px;
    cursor: pointer;
    background: transparent;
    border-radius: 5px;
    border: none;
}

.form-range::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d6efd 0%, #0056b3 100%);
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.form-range::-moz-range-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* IE/Edge */
.form-range::-ms-track {
    width: 100%;
    height: 8px;
    cursor: pointer;
    background: transparent;
    border-color: transparent;
    color: transparent;
}

.form-range::-ms-fill-lower {
    background: #0d6efd;
    border-radius: 5px;
}

.form-range::-ms-fill-upper {
    background: #dee2e6;
    border-radius: 5px;
}

.form-range::-ms-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d6efd 0%, #0056b3 100%);
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.slider-preset-values {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    font-size: 0.75rem;
    color: var(--muted-text);
    font-weight: 500;
}

/* 結果表示 */
.results-section {
    animation: slideInUp 0.6s ease-out;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

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

.result-period {
    padding: 1rem 2rem;
    border-radius: 0.75rem;
    display: inline-block;
}

.result_kingaku {
    color: #0056b3;
    font-weight: 700;
}

.table {
    margin-bottom: 1rem;
}

.table td,
.table th {
    white-space: nowrap;
}

.table-hover tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 0.5rem;
}

.table-container {
    border-radius: 0.5rem;
    overflow: hidden;
}

/* グラフエリア */
#chart_div_annual,
#chart_div_cumulative,
#tr_chart_div,
#investment_chart_div {
    border-radius: 0.5rem;
    overflow: hidden;
}

/* 広告セクション */
.ad-section {
    text-align: center;
    padding: 1rem;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 0.75rem;
}

/* フッター */
.footer {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    margin-top: auto;
}

.footer a:hover {
    text-decoration: underline !important;
}

/* エラーメッセージ */
.validate_err_msg {
    color: var(--danger-color);
    font-size: 0.875rem;
    font-weight: 500;
    margin-top: 0.5rem;
}

/* アラート */
.alert {
    border: none;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-sm);
}

.alert-link {
    font-weight: 600;
}

/* レスポンシブデザイン */
@media (max-width: 767.98px) {
    .page-title {
        font-size: 1.4rem;
        padding: 1.5rem 1rem;
    }

    .lead {
        font-size: 1rem;
    }

    .badge {
        font-size: 0.75rem;
        padding: 0.375rem 0.625rem;
    }

    .card-body {
        padding: 1rem;
    }

    .col-form-label {
        margin-bottom: 0.5rem;
        font-size: 0.95rem;
    }

    .form-control,
    .form-select {
        font-size: 16px;
        /* iOS自動ズーム防止 */
    }

    .calculate-btn {
        min-width: calc(100%-20px);
        font-size: 1.125rem;
        padding: 0.875rem 1.5rem;
    }

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

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

    /* 列数が少ないテーブルは横スクロール不要 */
    .table-narrow-columns {
        min-width: auto;
    }

    .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;
        z-index: 1;
    }

    .table thead th:first-child {
        background-color: #f8f9fa;
        z-index: 2;
    }

    .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;
    }

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

    /* 税引前/税引後トグルボタン */
    .btn-group label.btn {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }

    /* 内訳を見るリンク */
    a[data-bs-toggle="collapse"] {
        font-size: 0.875rem;
    }

    /* 年率リターンの注釈 */
    .text-muted.small {
        font-size: 0.7rem;
    }

    /* スクロールヒント */
    .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: '';
    }

    .slider-preset-values {
        font-size: 0.65rem;
    }

    .setting-group {
        padding: 0.5rem 0;
    }

    .divider {
        margin: 0.75rem 0;
    }
}

@media (min-width: 768px) {
    .page-title {
        font-size: 2rem;
    }

    .col-form-label {
        text-align: right;
        padding-right: 1rem;
    }
}

@media (min-width: 992px) {
    .page-title {
        font-size: 2.25rem;
    }
}

/* レスポンシブ対応: 表示切替ボタン */
@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;
    }
}