/* ---------------------------------- */
/* 1. Basic Styles (Ver1) */
/* ---------------------------------- */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    background-color: #f8f9fa; /* オフホワイト */
    color: #333333; /* ダークグレー */
    margin: 0;
    padding: 0;
    /* フッターを最下部に固定するため */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    /* フッター固定ボタンの高さ分、bodyの底に余白を設ける */
    padding-bottom: 90px;
}

h2 {
    font-size: 1.5em;
    color: #34495e; /* スレートブルー */
    border-left: 5px solid #16a085; /* ダークミント */
    padding-left: 10px;
    margin: 20px 0 15px;
}

h3 {
    font-size: 1.2em;
    color: #2c3e50; /* ダークブルー */
    border-bottom: 2px solid #e8f8f5; /* ライトミント */
    padding-bottom: 5px;
    margin-top: 10px;
}

p.notice {
    font-size: 0.85em;
    color: #7f8c8d; /* ライトグレー */
    margin-top: 5px;
}

/* ---------------------------------- */
/* 2. Header */
/* ---------------------------------- */
.site-header {
    width: 100%;
    background-color: #ffffff; /* ホワイト背景 */
    color: #333333; 
    padding-top: 15px;
    padding-bottom: 15px; 
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); 
    z-index: 100; 
}
.header-content {
    width: 95%;
    max-width: 900px; 
    margin: 0 auto;
}
.site-header h1 {
    margin: 0;
    font-size: 1.8em;
    color: #1abc9c; /* ブライトミント */
}
.site-header .subtitle {
    color: #7f8c8d; /* ライトグレー */
    margin: 0;
    font-size: 1em;
}

/* ---------------------------------- */
/* 2.5. Breadcrumb (Moved inside container) */
/* ---------------------------------- */
.breadcrumb-nav {
    width: 100%;
    background-color: transparent;
    padding: 0 0 15px 0; /* 下に余白 */
    margin-bottom: 0;
    border-bottom: 1px solid #f0f0f0; /* 薄い区切り線 */
    margin-bottom: 20px;
}
.breadcrumb-content {
    width: 100%; /* コンテナ内なので100% */
    font-size: 0.9em; 
    color: #7f8c8d; 
}
.breadcrumb-content a {
    color: #7f8c8d;
    text-decoration: none;
    transition: color 0.3s;
}
.breadcrumb-content a:hover {
    color: #1abc9c;
    text-decoration: underline;
}
.breadcrumb-separator {
    margin: 0 8px;
    color: #7f8c8d;
}
.breadcrumb-current {
    color: #7f8c8d;
}

/* ---------------------------------- */
/* 3. Main Container */
/* ---------------------------------- */
.container {
    background-color: #ffffff; /* ホワイト */
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    width: 95%;
    max-width: 900px; 
    margin: 20px auto 20px auto; 
    /* フッターが追従するように */
    flex-grow: 1;
}

/* ---------------------------------- */
/* 4. Controls Section */
/* ---------------------------------- */
.controls-wrapper {
    display: flex;
    flex-wrap: wrap; 
    gap: 20px;
    align-items: center;
    background-color: #f8f9fa; /* オフホワイト */
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 25px;
}
.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-grow: 1;
}
.control-group label {
    font-weight: bold;
    color: #555555; /* ミドルグレー */
}
.control-group select {
    padding: 10px;
    font-size: 16px;
    border: 1px solid #dddddd; /* ボーダーグレー */
    border-radius: 5px;
    background-color: #ffffff;
    flex-grow: 1;
}
.main-btn {
    padding: 12px 20px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    background-color: #1abc9c; /* ブライトミント */
    color: #ffffff;
    transition: background-color 0.3s;
    min-width: 200px; 
    box-sizing: border-box;
}
.main-btn:hover {
    background-color: #16a085; /* ダークミント */
}

/* ---------------------------------- */
/* 5. Subscriptions Input Area */
/* ---------------------------------- */
#subscriptions-container {
    margin-top: 20px;
}
.category-group {
    margin-bottom: 25px;
    padding: 15px;
    border: 1px solid #e8f8f5; /* ライトミント */
    border-radius: 8px;
    background-color: #ffffff;
}

/* サブスクリプション入力行 */
.subscription-row {
    display: grid;
    /* サービス名(2fr), 料金(1fr), 周期(1fr), 削除(auto) */
    grid-template-columns: 2fr 1fr 1fr auto; 
    gap: 15px;
    align-items: flex-end; /* ラベルと入力欄の底を揃える */
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px dotted #dddddd; /* ボーダーグレー */
}
.subscription-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.input-item {
    display: flex;
    flex-direction: column;
}
.input-item label {
    font-size: 0.85em;
    color: #555555; /* ミドルグレー */
    margin-bottom: 3px;
}
.input-item input[type="text"],
.input-item input[type="number"],
.input-item select {
    padding: 8px;
    font-size: 15px;
    border: 1px solid #dddddd;
    border-radius: 5px;
    width: 100%;
    box-sizing: border-box;
}

/* 追加・削除ボタン */
.add-remove-btn {
    padding: 8px 10px;
    font-size: 14px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* [ + サービスを追加 ] ボタン */
button[data-control="add"] {
    background-color: #3498db; /* ブルー */
    color: #ffffff;
    font-weight: 500;
    margin-top: 10px;
    padding: 10px 15px;
    font-size: 15px;
}
button[data-control="add"]:hover {
    background-color: #2980b9;
}

/* [ 削除 ] ボタン */
button[data-control="remove"] {
    background-color: #f8f9fa;
    color: #e74c3c; /* レッド */
    border: 1px solid #dddddd;
    width: 38px;
    height: 38px;
    align-self: flex-end;
}
button[data-control="remove"]:hover {
    background-color: #e74c3c;
    color: #ffffff;
    border-color: #e74c3c;
}
/* 削除アイコン (×) */
.delete-cross-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    position: relative;
}
.delete-cross-icon::before,
.delete-cross-icon::after {
    content: '';
    position: absolute;
    left: 7px;
    top: 2px;
    width: 2px;
    height: 12px;
    background-color: currentColor;
}
.delete-cross-icon::before {
    transform: rotate(45deg);
}
.delete-cross-icon::after {
    transform: rotate(-45deg);
}

/* ---------------------------------- */
/* 6. Results Area */
/* ---------------------------------- */
.result-container {
    margin-top: 30px;
    padding-top: 15px;
    border-top: 2px solid #16a085; /* ダークミント */
}
#results {
    background-color: #e8f8f5; /* ライトミント */
    padding: 20px;
    border-radius: 8px;
}
.initial-message {
    text-align: center;
    color: #7f8c8d; /* ライトグレー */
    font-style: italic;
}

/* カテゴリ別集計 */
.result-item-category {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0 10px;
    border-bottom: 2px solid #16a085; /* ダークミント */
    margin-top: 15px;
}
.result-item-category:first-child {
    margin-top: 0;
}
.category-label {
    font-weight: bold;
    color: #34495e; /* スレートブルー */
    flex: 2;
}
.category-info {
    font-size: 0.9em;
    font-weight: normal;
    color: #555555;
    margin: 0;
}
.category-total-amount {
    font-size: 1.5em;
    font-weight: bold;
    color: #e74c3c; /* レッド */
    flex: 1;
    text-align: right;
    white-space: nowrap;
}
.category-total-amount .period-label {
    font-size: 0.6em;
    color: #e74c3c;
    display: block;
    line-height: 1;
    margin-bottom: 2px;
}

/* サービス別内訳 */
.result-item-minor {
    font-size: 0.9em;
    color: #555555;
    padding: 8px 5px;
    border-bottom: 1px dotted #95a5a6; /* アッシュグレー */
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 5px;
}
.service-cost-detail {
    color: #7f8c8d;
    font-family: monospace, sans-serif;
    white-space: nowrap;
}

/* 最終合計 */
.final-summary-box {
    margin-top: 35px;
    padding: 15px 0;
    border-top: none; 
    border-bottom: 2px solid #34495e; /* スレートブルー */
}
.final-summary-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.final-summary-total .total-label {
    font-size: 1.1em;
    color: #2c3e50; /* ダークブルー */
    font-weight: bold;
}
.final-summary-total .final-amount {
    font-size: 1.8em;
    color: #e74c3c; /* レッド */
    font-weight: bold;
}
.summary-period-info {
    font-size: 0.9em;
    color: #7f8c8d;
    margin-top: 5px;
    text-align: right;
}

/* 印刷ボタン */
.print-result-btn {
    display: inline-block;
    margin-top: 20px;
    padding: 8px 15px;
    background-color: #95a5a6; /* アッシュグレー */
    color: #ffffff;
    text-decoration: none;
    border-radius: 5px;
    font-size: 0.9em;
    transition: background-color 0.3s;
}
.print-result-btn:hover {
    background-color: #7f8c8d;
}

/* ---------------------------------- */
/* 7. Usage Notes (New) */
/* ---------------------------------- */
.usage-notes {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #dddddd; /* ボーダーグレー */
}
.usage-notes h3 {
    font-size: 1em;
    color: #34495e; /* スレートブルー */
    border-bottom: none;
    margin-top: 0;
    margin-bottom: 10px;
    font-weight: bold;
}
.usage-notes ul {
    list-style-type: disc;
    padding-left: 20px;
    margin: 0;
    color: #555555; /* ミドルグレー */
    font-size: 0.85em;
}
.usage-notes li {
    margin-bottom: 5px;
    line-height: 1.5;
}

/* ---------------------------------- */
/* 8. Footer (Updated) */
/* ---------------------------------- */
.page-footer {
    width: 100%;
    background-color: #34495e; /* スレートブルー */
    color: #ddd;
    padding: 30px 0; /* 少し余白を広げる */
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.05);
    margin-top: auto; 
}

.footer-content {
    max-width: 900px;
    width: 95%;
    margin: 0 auto; 
    padding: 0 10px;
    display: flex;
    flex-direction: column; 
    gap: 15px;
}

/* 横並び用の行コンテナ */
.footer-links-row {
    display: flex;
    flex-wrap: wrap; /* スマホで折り返し */
    gap: 40px; /* 横並び時の間隔 */
    width: 100%;
    border-bottom: 1px solid #556c80; /* 下線はここに移動 */
    padding-bottom: 20px;
}

.footer-section {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none; 
    /* min-width削除: 横並び時に自然な幅にするため */
    min-width: auto; 
}

.footer-section .section-title {
    font-size: 1.1em;
    font-weight: bold;
    color: #1abc9c; /* ブライトミント */
    margin-bottom: 10px;
    margin-top: 0;
}
.footer-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.footer-section li {
    margin-bottom: 5px;
}
.footer-section li a {
    color: #ccc;
    text-decoration: none;
    font-size: 0.9em;
    transition: color 0.3s;
}
.footer-section li a:hover {
    color: #ffffff;
    text-decoration: underline;
}

.copyright {
    text-align: center;
    font-size: 0.8em;
    color: #95a5a6;
    margin-top: 10px;
    width: 100%;
}

/* ---------------------------------- */
/* 9. Fixed Action Bar */
/* ---------------------------------- */
.fixed-action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: rgba(255, 255, 255, 0.95); 
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    padding: 15px 0;
    z-index: 50;
    backdrop-filter: blur(5px); 
}
.fixed-action-content {
    max-width: 900px; 
    width: 95%;
    margin: 0 auto;
}
.fixed-btn {
    width: 100%;
    margin-top: 0; 
    min-width: auto; 
}


/* ---------------------------------- */
/* 10. Responsive */
/* ---------------------------------- */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .subscription-row {
        grid-template-columns: 1fr; 
        gap: 10px;
        padding-bottom: 15px;
        margin-bottom: 15px;
    }
    button[data-control="remove"] {
        width: 100%; 
        height: auto;
        padding: 10px;
        margin-top: 5px;
    }

    .controls-wrapper {
        flex-direction: column;
        gap: 15px;
    }
    .control-group {
        width: 100%;
    }
    .main-btn {
        width: 100%;
        min-width: auto; 
    }

    .result-item-category {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    .category-total-amount {
        text-align: left;
        margin-top: 5px;
    }
    .result-item-minor {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .fixed-action-bar {
        padding-left: 15px;
        padding-right: 15px;
        box-sizing: border-box; 
    }
    .fixed-action-content {
        width: 100%; 
    }

    /* Footer Mobile Adjustments */
    .footer-links-row {
        flex-direction: column; /* スマホでは縦積み */
        gap: 20px;
    }
}