/* static/css/multi_simulator.css */

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100%;
    background: #f6f8fb;
    color: #111827;
    font-family: 'M PLUS 1p', sans-serif;
}

.page {
    width: 90%;
    max-width: 84rem;
    margin: 0 auto;
    padding: 0.75rem 1rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.loan-header-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(18rem, 32vw);
    gap: 1rem;
    align-items: start;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.loan-header-left,
.loan-header-right {
    min-width: 0;
}

.loan-header-left {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.page-header {
    display: block !important;
    width: auto !important;
    padding: 0 !important;
    box-shadow: none !important;
    justify-content: normal !important;
    align-items: normal !important;
}

.page-header h1 {
    margin: 0 0 0.5rem;
    font-size: 2.5rem;
    line-height: 1.3;
    color: #111827;
}

.page-header p {
    margin: 0 0 0.5rem;
    color: #1f2a44;
    line-height: 1.6;
    font-size: 1rem;
}

.loan-notice-card {
    background: #ffffff;
    border-radius: 1rem;
    box-shadow: 0 0.125rem 0.5rem rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.loan-notice-accordion {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.loan-notice-accordion::after {
    content: "▲";
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: #4b5563;
}

.loan-notice-accordion.is-collapsed::after {
    content: "▼";
}

.loan-notice-title {
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    font-weight: 700;
    color: #374151;
    border-bottom: 0.0625rem solid #edf2f7;
    background: #fbfdff;
}

.loan-notice-body {
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    line-height: 1.8;
    color: #4b5563;
}

.loan-notice-body p {
    margin: 0;
}

.loan-notice-accordion.is-collapsed .loan-notice-body {
    display: none;
}

.loan-notice-accordion.is-collapsed .loan-notice-title {
    border-bottom: none;
}

.loan-ad-slot {
    width: 100%;
    min-height: 6.25rem;
    border: 0.0625rem dashed #cfc7a4;
    border-radius: 0.75rem;
    background: #ffffff;
    padding: 0.75rem;
    box-sizing: border-box;
}

.loan-adsense {
    display: block;
    width: 100%;
    min-height: 5.5rem;
}

.card {
    background: #ffffff;
    border-radius: 1.25rem;
    padding: 1rem;
    box-shadow: 0 0.125rem 0.5rem rgba(15, 23, 42, 0.08);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.card-header h2 {
    margin: 0 0 0.35rem;
    font-size: 1.1rem;
    color: #222222;
}

.card-header p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #4b5563;
}

.loan-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.split-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(16rem, 1fr);
    gap: 1rem;
    align-items: start;
}

.split-input {
    min-width: 0;
}

.split-help {
    min-width: 0;
    background: #f8fbff;
    border: 0.0625rem solid #dbe4f0;
    border-radius: 1rem;
    padding: 1rem;
    box-sizing: border-box;
}

.split-help h3 {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
    color: #1f2a44;
}

.split-help p {
    margin: 0 0 0.75rem;
    font-size: 0.85rem;
    line-height: 1.7;
    color: #4b5563;
}

.split-help p:last-child {
    margin-bottom: 0;
}

.help-note {
    font-weight: 700;
    color: #1d4ed8;
    background: #eef4ff;
    border-radius: 0.625rem;
    padding: 0.625rem;
}

.loan-form-fields p {
    margin: 0 0 0.875rem;
}

.loan-form-fields p:last-child {
    margin-bottom: 0;
}

.loan-form-fields label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.9rem;
    font-weight: 700;
    color: #374151;
}

.loan-form-fields input,
.loan-form-fields select {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    border: 0.0625rem solid #d6deeb;
    border-radius: 0.5rem;
    padding: 0.75rem 0.9375rem;
    background: #ffffff;
    color: #1f2a44;
    font-size: 0.9375rem;
    line-height: 1.4;
    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        background-color 0.15s ease;
}

.loan-form-fields input:focus,
.loan-form-fields select:focus {
    outline: none;
    border-color: #9eb8ef;
    box-shadow: 0 0 0 0.1875rem rgba(47, 106, 230, 0.18);
}

.primary-btn,
.secondary-btn,
.secondary-link-btn,
button[type="button"],
button[type="submit"] {
    border-radius: 0.5rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.15s ease;
}

.primary-btn,
button[type="submit"]:not(.secondary-btn) {
    width: 100%;
    border: 0.0625rem solid #2f6ae6;
    background: #2f6ae6;
    color: #ffffff;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    box-shadow: 0 0.25rem 0.75rem rgba(47, 106, 230, 0.18);
}

.primary-btn:hover,
button[type="submit"]:not(.secondary-btn):hover {
    background: #2559c7;
    border-color: #2559c7;
    transform: translateY(-0.0625rem);
}

.secondary-btn,
.secondary-link-btn,
button[type="button"] {
    flex: 0 0 auto;
    border: 0.0625rem solid #2f6ae6;
    background: #ffffff;
    color: #2f6ae6;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
}

.secondary-btn:hover,
.secondary-link-btn:hover,
button[type="button"]:hover {
    background: #eef4ff;
    transform: translateY(-0.0625rem);
}

.card-header {
    flex-wrap: wrap;
}

button.add-loan-btn {
    flex: 1 1 100%;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border: none;
    border-radius: 0.5rem;
    background: linear-gradient(135deg, #ff9f43, #ff7a1a);
    color: #ffffff;
    font-weight: 700;
    font-size: 0.9rem;
    line-height: 1;
    padding: 0.75rem 1.1rem;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 0.3rem 0.9rem rgba(255, 122, 26, 0.35);
    animation: add-loan-pulse 2.2s ease-in-out infinite;
    transition:
        background 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.15s ease;
}

button.add-loan-btn:hover,
button.add-loan-btn:focus-visible {
    background: linear-gradient(135deg, #ff8f2a, #f5680a);
    box-shadow: 0 0.4rem 1.1rem rgba(255, 122, 26, 0.45);
    transform: translateY(-0.0625rem);
    animation-play-state: paused;
}

@keyframes add-loan-pulse {
    0%, 100% {
        box-shadow: 0 0.3rem 0.9rem rgba(255, 122, 26, 0.35);
    }
    50% {
        box-shadow: 0 0.3rem 0.9rem rgba(255, 122, 26, 0.35), 0 0 0 0.3rem rgba(255, 122, 26, 0.18);
    }
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.25rem;
}

.secondary-link-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.form-actions-row {
    display: flex;
    gap: 0.75rem;
}

.form-actions-row > a,
.form-actions-row > button {
    flex: 1 1 0;
    width: auto;
}

.loan-chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.loan-chart-wrap {
    background: #fbfdff;
    border: 0.0625rem solid #dbe4f0;
    border-radius: 1rem;
    padding: 0.875rem;
}

.loan-chart-title {
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
    color: #222222;
    text-align: center;
}

.loan-chart-wrap canvas {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
}

@media (max-width: 48rem) {
    .loan-chart-grid {
        grid-template-columns: 1fr;
    }
}

.added-loans-card {
    margin-top: 1rem;
}

.loan-entry-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.875rem;
}

.loan-empty-message {
    grid-column: 1 / -1;
}

.loan-empty-message {
    background: #fbfdff;
    border: 0.0625rem dashed #cbd5e1;
    border-radius: 1rem;
    padding: 1rem;
    color: #64748b;
    font-size: 0.9rem;
    text-align: center;
}

.loan-entry {
    background: #fbfdff;
    border: 0.0625rem solid #dbe4f0;
    border-radius: 1rem;
    padding: 1rem;
    box-sizing: border-box;
}

.loan-entry dl {
    display: grid;
    grid-template-columns: 8rem minmax(0, 1fr);
    gap: 0.5rem 0.75rem;
    margin: 0;
}

.loan-entry dt {
    color: #64748b;
    font-size: 0.85rem;
    font-weight: 700;
}

.loan-entry dd {
    margin: 0;
    color: #1f2937;
    font-size: 0.9rem;
    word-break: break-word;
}

.remove-loan {
    width: 100%;
    margin-top: 0.875rem;
    border: 0.0625rem solid #f1c0c0;
    background: #fffafa;
    color: #b42318;
    padding: 0.625rem 0.875rem;
    font-size: 0.8125rem;
}

.remove-loan:hover {
    background: #fff1f1;
    border-color: #e19a9a;
    transform: translateY(-0.0625rem);
}

.result-card h3 {
    margin: 1.25rem 0 0.75rem;
    font-size: 1rem;
    color: #222222;
}

.loan-schedule-block {
    margin-top: 1.25rem;
}

.loan-schedule-block:first-of-type {
    margin-top: 0;
}

.table-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    margin: 0.875rem 0 0;
    border: 0.0625rem solid #dbe4f0;
    border-radius: 0.625rem;
    background: #f8fbff;
    color: #1f2a44;
    font-weight: 700;
    font-size: 0.9rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
}

.table-toggle-btn:hover {
    background: #eef4ff;
}

.table-toggle-icon {
    transition: transform 0.15s ease;
}

.table-toggle-btn.is-open .table-toggle-icon {
    transform: rotate(180deg);
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    margin-top: 0.875rem;
}

.table-wrap.is-collapsed {
    display: none;
}

.result-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    background: #ffffff;
}

.result-table th,
.result-table td {
    border: 0.0625rem solid #d1d5db;
    padding: 0.75rem;
    vertical-align: top;
    box-sizing: border-box;
    font-size: 0.9rem;
}

.result-table th {
    background: #f2f2f2;
    text-align: center;
    font-weight: 700;
    color: #222222;
    position: sticky;
    top: 0;
    z-index: 1;
}

.result-table td {
    color: #1f2937;
    text-align: left;
}

.guide-link {
    margin: 0.5rem 0 0;
    text-align: center;
    color: #4b5563;
}

.guide-link a {
    color: #2f6ae6;
    font-weight: 700;
}

@media (max-width: 48rem) {
    .page {
        width: auto;
        padding: 0.625rem 0.75rem 1rem;
        gap: 0.875rem;
    }

    .loan-header-layout {
        grid-template-columns: 1fr;
        margin-top: 1rem;
    }

    .loan-header-right {
        order: -1;
    }

    .page-header h1 {
        font-size: 2rem;
    }

    .card {
        padding: 0.75rem;
        border-radius: 1rem;
    }

    .card-header {
        flex-direction: column;
        align-items: stretch;
    }

    .secondary-btn,
    .secondary-link-btn,
    button[type="button"] {
        width: 100%;
    }

    .split-layout {
        grid-template-columns: minmax(0, 1.35fr) minmax(8rem, 1fr);
        gap: 0.75rem;
    }

    .split-help {
        padding: 0.75rem;
        border-radius: 0.875rem;
    }

    .split-help h3 {
        font-size: 0.85rem;
        margin-bottom: 0.5rem;
    }

    .split-help p {
        font-size: 0.75rem;
        line-height: 1.5;
        margin-bottom: 0.5rem;
    }

    .help-note {
        padding: 0.5rem;
    }

    .loan-entry-list {
        grid-template-columns: 1fr;
    }

    .loan-entry dl {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }

    .loan-entry dt {
        margin-top: 0.4rem;
    }

    .loan-entry dt:first-child {
        margin-top: 0;
    }

    .result-table {
        min-width: 42rem;
    }
}

@media (max-width: 36rem) {
    .page-header h1 {
        font-size: 1.75rem;
    }

    .split-layout {
        grid-template-columns: minmax(0, 1.25fr) minmax(7rem, 1fr);
        gap: 0.5rem;
    }

    .split-help {
        padding: 0.625rem;
    }

    .split-help h3 {
        font-size: 0.8rem;
    }

    .split-help p {
        font-size: 0.7rem;
        line-height: 1.45;
    }

    .loan-form-fields input,
    .loan-form-fields select {
        font-size: 0.875rem;
        padding: 0.625rem 0.75rem;
    }

    .primary-btn,
    .secondary-btn,
    .secondary-link-btn,
    .remove-loan,
    button[type="button"],
    button[type="submit"] {
        font-size: 0.875rem;
    }

    .result-table th,
    .result-table td {
        padding: 0.5rem;
        font-size: 0.8125rem;
    }
}

/* 印刷時は、返済スケジュールの結果部分だけをA4に収まるよう表示する */
@media print {
    nav,
    footer,
    .loan-header-right,
    .loan-notice-card,
    .loan-form,
    .guide-link {
        display: none !important;
    }

    .page {
        width: auto;
        max-width: none;
        padding: 0;
        gap: 0.5rem;
    }

    .loan-header-layout {
        grid-template-columns: 1fr;
        margin-top: 0;
    }

    .result-card {
        box-shadow: none;
        border: 0.0625rem solid #d1d5db;
    }

    .table-toggle-btn {
        display: none !important;
    }

    .table-wrap.is-collapsed {
        display: block !important;
    }

    .loan-chart-grid {
        grid-template-columns: 1fr 1fr;
        break-inside: avoid;
    }

    .result-table tr {
        break-inside: avoid;
    }
}