/* ========================================
   ミライ予報 - スタイル
======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: sans-serif;
}

:root {
    --main-color: #4F8EF7;
    --background-color: #f5f7fa;
    --user-background-color: #f5f7fa;
    --card-color: #ffffff;
    --text-color: #222222;
    --sub-text-color: #666666;
    --border-color: #dddddd;
}

/* ========================================
   全体
======================================== */

html {
    width: 100%;
    min-height: 100%;
}

body {
    width: 100%;
    min-height: 100vh;

    background: var(--background-color);
    color: var(--text-color);

    transition:
        background-color .3s,
        color .3s;

    padding-bottom: 85px;
}


/* ========================================
   ヘッダー
======================================== */

header {
    width: 100%;
    height: 60px;

    display: flex;
    justify-content: center;
    align-items: center;

    background: var(--main-color);
    color: white;

    font-size: 20px;
    font-weight: bold;

    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    font-size: 21px;
}


/* ========================================
   ページ
======================================== */

.page {
    display: none;

    width: 100%;
    max-width: 700px;

    margin: 0 auto;

    padding: 18px 15px;
}

.page.active {
    display: block;
}

.page h2 {
    font-size: 24px;
    margin-bottom: 18px;
}


/* ========================================
   カード
======================================== */

.card {
    width: 100%;

    background: var(--card-color);

    padding: 17px;

    border-radius: 16px;

    margin-bottom: 15px;

    box-shadow:
        0 3px 10px rgba(0, 0, 0, .08);

    transition:
        background-color .3s,
        color .3s;

      color: var(--text-color);
  
}

.card h3 {
    margin-bottom: 8px;
}

.card p {
    font-size: 18px;
    font-weight: bold;
}

.empty-card {
    text-align: center;
    padding: 28px 15px;
}

.empty-text {
    color: var(--sub-text-color);
    font-size: 14px !important;
    font-weight: normal !important;
}


/* ========================================
   下部ナビゲーション
======================================== */

nav {
    position: fixed;

    left: 0;
    bottom: 0;

    width: 100%;
    height: 75px;

    display: flex;

    background: var(--card-color);

    border-top: 1px solid var(--border-color);

    box-shadow:
        0 -3px 12px rgba(0, 0, 0, .08);

    z-index: 1000;

    transition:
        background-color .3s;
}


/* ナビゲーションボタン */

nav button {
    flex: 1;

    min-width: 0;

    height: 75px;

    border: none;

    background: transparent;

    color: var(--sub-text-color);

    display: flex;

    flex-direction: column;

    justify-content: center;

    align-items: center;

    gap: 3px;

    cursor: pointer;

    -webkit-tap-highlight-color: transparent;

    transition:
        color .2s,
        background-color .2s;
}


/* アイコン */

.nav-icon {
    display: block;

    font-size: 21px;

    line-height: 1;
}


/* 文字 */

.nav-label {
    display: block;

    font-size: 11px;

    font-weight: bold;

    line-height: 1.2;

    white-space: nowrap;
}


/* 選択中 */

nav button.active {
    color: var(--main-color);

    background:
        rgba(79, 142, 247, .10);
}


/* タップ時 */

nav button:active {
    transform: scale(.94);
}


/* ========================================
   タイトル行
======================================== */

.page-title-row {
    display: flex;

    justify-content: space-between;
    align-items: center;

    gap: 10px;

    margin-bottom: 15px;
}

.page-title-row h2 {
    margin-bottom: 0;
}


/* ========================================
   追加ボタン
======================================== */

.add-button {
    border: none;

    background: var(--main-color);

    color: white;

    padding: 11px 15px;

    border-radius: 12px;

    font-size: 15px;

    font-weight: bold;

    white-space: nowrap;

    cursor: pointer;
}

.add-button:active {
    transform: scale(.96);
}


/* ========================================
   フォーム
======================================== */

.form-card {
    background: var(--card-color);

    padding: 18px;

    border-radius: 16px;

    margin-bottom: 18px;

    box-shadow:
        0 3px 10px rgba(0, 0, 0, .08);
}

.form-card h3 {
    margin-bottom: 15px;
}

.form-card label {
    display: block;

    margin-top: 12px;
    margin-bottom: 5px;

    font-weight: bold;

    font-size: 14px;
}

.form-card input,
.form-card select {
    width: 100%;

    padding: 12px;

    border: 1px solid var(--border-color);

    border-radius: 10px;

    font-size: 16px;

    background: var(--card-color);

    color: var(--text-color);

    outline: none;
}

.form-card input:focus,
.form-card select:focus {
    border-color: var(--main-color);
}


/* ========================================
   フォームボタン
======================================== */

.form-buttons {
    display: flex;

    gap: 10px;

    margin-top: 18px;
}

.form-buttons button {
    flex: 1;

    padding: 12px;

    border: none;

    border-radius: 10px;

    font-size: 16px;

    font-weight: bold;

    cursor: pointer;
}

.save-button {
    background: var(--main-color);

    color: white;
}

.cancel-button {
    background: #dddddd;

    color: #333333;
}


/* ========================================
   商品カード
======================================== */

.item-card {
    background: var(--card-color);

    padding: 16px;

    border-radius: 16px;

    margin-bottom: 14px;

    box-shadow:
        0 3px 10px rgba(0, 0, 0, .08);
}

.item-top {
    display: flex;

    justify-content: space-between;

    align-items: flex-start;

    gap: 10px;
}

.item-top h3 {
    font-size: 19px;

    margin-bottom: 5px;

    word-break: break-word;
}

.item-price {
    font-size: 20px !important;

    font-weight: bold !important;
}

.pin-button {
    border: none;

    background: transparent;

    color: var(--sub-text-color);

    font-size: 26px;

    padding: 3px 6px;

    cursor: pointer;

    flex-shrink: 0;
}

.pin-button.pinned {
    color: var(--main-color);
}

.item-info {
    display: flex;

    flex-direction: column;

    gap: 6px;

    margin-top: 12px;

    font-size: 14px;
}

.item-actions {
    display: flex;

    gap: 8px;

    margin-top: 14px;
}

.item-actions button {
    flex: 1;

    min-height: 42px;

    border: none;

    border-radius: 10px;

    padding: 9px 5px;

    background: var(--main-color);

    color: white;

    font-size: 13px;

    font-weight: bold;

    cursor: pointer;
}

.item-actions button:active {
    transform: scale(.97);
}

.item-actions .delete-button {
    background: #888888;
}


/* ========================================
   期限表示
======================================== */

.deadline-card {
    border-left: 4px solid var(--main-color);
}

.deadline-item {
    padding: 12px;

    border-radius: 10px;

    background: var(--card-color);

    margin-top: 8px;
}

.deadline-item strong {
    display: block;

    margin-bottom: 4px;
}

.deadline-normal {
    color: var(--main-color);
}

.deadline-today {
    color: #e67e22;
}

.deadline-expired {
    color: #d9534f;
}


/* /* ========================================
   設定
======================================== */

.settings-card {
    padding: 24px;
}

.settings-card h3 {
    margin: 0 0 10px 0;
    font-size: 22px;
    line-height: 1.4;
}

.setting-description {
    font-size: 15px !important;
    font-weight: normal !important;
    color: var(--sub-text-color);
    margin: 0 0 18px 0;
    line-height: 1.6;
}


/* 背景カラー */

.color-setting {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
}

#backgroundColor {
    width: 58px;
    height: 48px;

    padding: 2px;

    border: 1px solid var(--border-color);
    border-radius: 10px;

    background: transparent;
    cursor: pointer;
}

#backgroundColorText {
    font-size: 16px;
    font-family: monospace;
}


/* 設定ボタン */

.setting-button {
    width: 100%;

    min-height: 46px;

    margin-top: 8px;

    border: none;
    border-radius: 12px;

    background: var(--main-color);
    color: white;

    font-size: 15px;
    font-weight: bold;

    cursor: pointer;

    padding: 10px 16px;

    box-sizing: border-box;
}

#resetBackgroundColorButton {
    margin-bottom: 30px;
}

.setting-button:active {
    transform: scale(.98);
}


/* 設定画面の入力欄 */

.settings-card input[type="number"],
.settings-card input[type="text"] {
    width: 100%;

    min-height: 44px;

    box-sizing: border-box;

    padding: 8px 12px;

    border: 1px solid var(--border-color);
    border-radius: 10px;

    font-size: 16px;

    background: var(--card-color);
    color: var(--text-color);
}


/* 入力欄＋保存ボタン */

.settings-card input + .setting-button {
    margin-top: 8px;
}


/* 設定項目同士の間隔 */

.settings-card > div {
    margin-bottom: 20px;
}


/* ダークモードなどの区切り */

.settings-card hr {
    margin: 24px 0;

    border: none;

    border-top: 1px solid var(--border-color);
}

/* ========================================
   スマホ向け調整
======================================== */

@media (max-width: 480px) {

    header {
        height: 56px;
    }

    header h1 {
        font-size: 19px;
    }

    .page {
        padding: 16px 12px;
    }

    .page h2 {
        font-size: 22px;
    }

    nav {
        height: 72px;
    }

    nav button {
        height: 72px;
    }

    .nav-icon {
        font-size: 20px;
    }

    .nav-label {
        font-size: 10px;
    }

    .item-actions button {
        font-size: 12px;
    }

}


/* ========================================
   とても小さいスマホ
======================================== */

@media (max-width: 360px) {

    .nav-icon {
        font-size: 18px;
    }

    .nav-label {
        font-size: 9px;
    }

    .page {
        padding-left: 10px;
        padding-right: 10px;
    }

}
/* ==============================
   スマホ用・下部ナビゲーション
============================== */

nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 72px;

    display: flex;
    align-items: stretch;

    background: rgba(255, 255, 255, 0.96);

    border-top: 1px solid #ddd;

    box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.08);

    z-index: 1000;
}


/* 6個のボタン */

nav button {
    flex: 1;
    min-width: 0;

    border: none;

    background: transparent;

    color: #666;

    font-size: 11px;
    font-weight: bold;

    display: flex;
    flex-direction: column;

    justify-content: center;
    align-items: center;

    gap: 4px;

    padding: 5px 2px;

    cursor: pointer;

    transition:
        background 0.2s,
        color 0.2s,
        transform 0.1s;
}


/* ボタンを押したとき */

nav button:active {
    transform: scale(0.94);
}


/* 選択中のページ */

nav button.active {
    color: #4F8EF7;

    background: rgba(79, 142, 247, 0.10);

}


/* 選択中のボタンを少し強調 */

nav button.active::after {
    content: "";

    position: absolute;

    bottom: 0;

    width: 28px;
    height: 3px;

    background: #4F8EF7;

    border-radius: 3px 3px 0 0;
}


/* ==============================
   スマホ表示
============================== */

@media (max-width: 600px) {

    nav {
        height: 70px;
    }

    nav button {
        font-size: 10px;
        gap: 3px;
    }

}


/* ==============================
   ミライ予報 ダイアログ
============================== */

.custom-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.custom-dialog {
    width: 85%;
    max-width: 360px;
    background: white;
    border-radius: 16px;
    padding: 24px 20px;
    box-sizing: border-box;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

#customDialogMessage {
    margin: 0 0 24px;
    font-size: 16px;
    line-height: 1.6;
    text-align: center;
}

.custom-dialog-buttons {
    display: flex;
    gap: 10px;
}

.custom-dialog-buttons button {
    flex: 1;
    border: none;
    border-radius: 10px;
    padding: 12px;
    font-size: 15px;
    cursor: pointer;
}

.dialog-cancel-button {
    background: #e5e7eb;
}

.dialog-ok-button {
    background: #6c63ff;
    color: white;
}


/* ==============================
   設定画面の各項目をカード分け
================================ */

.settings-card {
    width: 100%;
    background: var(--card-color);
    padding: 24px;
    border-radius: 20px;
    margin-bottom: 20px;

    box-shadow:
        0 3px 10px rgba(0, 0, 0, .08);

    transition:
        background-color .3s,
        color .3s;
}

/* 設定カード内の最後の要素の余白を調整 */
.settings-card > *:last-child {
    margin-bottom: 0;
}

/* ==============================
   設定画面の入力欄の枠
================================ */

/* 背景カラー選択ボタン */
#backgroundColor {
    border: 3px solid #ffffff;
    border-radius: 8px;
}

/* 今月の予算入力欄 */
#monthlyBudgetInput {
    border: 3px solid #ffffff;
    border-radius: 12px;
}

/* 背景色が白の場合は黒い枠にする */
body.background-white #backgroundColor,
body.background-white #monthlyBudgetInput {
    border-color: #000000;
}