/* ====================================
    0. グローバルリセット & 基本レイアウト
    ==================================== */
body {
    font-family: 'Noto Sans JP', sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    /* 背景グラデーション */
    background: linear-gradient(180deg, #ff9b4a, #7fd5ff); 
    display: flex;
    flex-direction: column;
}

.header, .footer {
    /* フロストガラス効果 */
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px); /* Safari対応 */
}

.header {
    text-align: center;
    padding: 1em;
    font-size: 1.6em;
    color: white;
}

.container {
    flex: 1;
    /* 💥 修正: text-alignを削除し、左右のスペースはpaddingで確保 💥 */
    padding: 1.5em; 
    /* text-align: center; 👈 削除 */
}

h2 {
    color: white;
}

/* フォーム全体を中央に配置し、幅を制限する */
form {
    width: 90%; 
    max-width: 500px; 
    margin: 0 auto; /* フォーム全体を中央寄せ */
    text-align: center; 
    padding: 0;
}

/* ====================================
    1. フォーム & ボタン スタイル (中央寄せ修正済み)
    ==================================== */

/* フォームタイトル (list.htmlのh2と区別する場合) */
.container h2.form-title {
    color: #2c3e50;
    margin: 20px 0 30px;
    font-size: 1.8rem;
    font-weight: 700;
}

/* フォーム入力フィールドと submit ボタンの共通スタイル */
form input[type="text"], 
form input[type="date"], 
form button[type="submit"] {
    width: 80%; 
    max-width: 400px; 
    padding: 0.8em;
    
    /* 中央寄せのための必須設定 */
    display: block;  
    margin: 1em auto; 
    
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 1em;
    box-sizing: border-box;
}

/* submit ボタン固有のスタイル */
form button[type="submit"] {
    padding: 12px;
    background-color: #3498db; 
    color: white; 
    border: none; 
    cursor: pointer;
}

form button[type="submit"]:hover {
    background-color: #2980b9; 
}


/* 1-2. カメラ起動ボタン（カスタムファイルアップロード） */
#fileInput { 
    display: none !important; 
}

.custom-file-upload {
    /* 中央寄せと幅をフォームと統一 */
    width: 80%; 
    max-width: 400px; 
    
    /* 基本のボタンからスタイルを継承 */
    background: #2ecc71;
    color: white;
    border: none;
    padding: 0.8em 1.2em;
    border-radius: 12px;
    font-size: 1em;
    font-weight: bold;
    
    /* 💥 修正: display: block; と margin: auto で確実な中央寄せ 💥 */
    display: block; 
    cursor: pointer;
    text-align: center;
    margin: 0.5em auto; 
}

.custom-file-upload:hover {
    background: #27ae60;
}

/* ====================================
    2. フッター & ナビゲーション
    ==================================== */
.footer {
    padding: 0.5em;
    text-align: center;
}

.footer a {
    color: white;
    text-decoration: none;
    margin: 0 1em;
    font-size: 1.2em;
}

/* ====================================
    3. 一覧ページ (List) スタイル
    ==================================== */
.list-grid {
    /* CSS Gridによるレスポンシブなカード配置 */
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 20px;
    padding: 0 10px;
    max-width: 1200px; 
    margin: 0 auto;
}

.item-card {
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    cursor: pointer; 
    transition: transform 0.2s, box-shadow 0.2s;
    text-align: center;
}

.item-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
}

.item-card img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
    border-bottom: 1px solid #eee;
}

.item-info {
    padding: 10px;
}

.item-info p {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-date {
    font-size: 0.8rem;
    color: #7f8c8d;
    margin-top: 5px;
}

/* 期限切れカードの視覚的強調 */
.item-card.expired-card {
    border: 3px solid #e74c3c; 
    box-shadow: 0 4px 10px rgba(231, 76, 60, 0.4);
}
.expired-card .item-date:last-child {
    color: #e74c3c;
    font-weight: 700;
}


/* ====================================
    4. モーダル (Modal) スタイル
    ==================================== */
.modal {
    display: none; 
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    padding-top: 60px;
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

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

.modal-body img {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    border-radius: 8px;
    margin-bottom: 20px;
}

.modal-details p {
    margin: 10px 0;
    padding: 8px;
    border-bottom: 1px dashed #ecf0f1;
    display: flex;
    justify-content: space-between;
    font-size: 1rem;
}

.modal-details strong {
    color: #34495e;
    font-weight: 600;
}

.close-btn {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    transition: color 0.2s;
}

.close-btn:hover,
.close-btn:focus {
    color: #333;
    text-decoration: none;
    cursor: pointer;
}

.delete-form {
    text-align: center;
    margin-top: 20px;
}

.delete-form button {
    background-color: #e74c3c;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.delete-form button:hover {
    background-color: #c0392b;
}


/* ====================================
    5. レスポンシブ対応
    ==================================== */
@media (max-width: 600px) {
    .list-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
}


/* ====================================
    6. レシピページ専用デザイン強化
    ==================================== */

/* 既存の .list-grid を上書き（モバイル対応強化） */
.list-grid {
    display: grid;
    /* 250pxを最小幅として、画面幅に応じて列数を自動調整 */
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); 
    gap: 20px;
    padding: 0 1.5em; 
    max-width: 1200px; 
    margin: 0 auto; 
}

/* レシピカード全体 (recipe_search.htmlでitem-cardとrecipe-cardの両方が適用される) */
.recipe-card {
    display: flex; 
    flex-direction: column;
    height: 100%; /* グリッド内で高さを揃える */
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    text-align: left; /* レシピカードのテキストは左寄せ */
    cursor: default; 
}

.recipe-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

/* 画像エリア（代替画像用）の調整 */
.recipe-card img {
    width: 100%;
    height: 180px; /* 高さの強調 */
    object-fit: cover;
    background-color: #ecf0f1; /* 画像がない場合の背景色 */
    /* アクセントカラーを下に付けて、領域を強調 */
    border-bottom: 3px solid #f39c12; /* アクセントライン */
}

/* 情報エリアの調整 */
.item-info {
    padding: 15px;
    flex-grow: 1; 
    display: flex;
    flex-direction: column;
    justify-content: space-between; 
}

/* レシピタイトル */
.item-info p {
    font-size: 1.05rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 10px 0; 
    /* 2行で省略する設定 */
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2; 
    white-space: normal; /* list.htmlの「一行で省略」を解除 */
    text-overflow: clip; 
}

/* レシピを見るボタン */
.item-info a {
    display: block;
    text-align: center;
    padding: 10px;
    background-color: #3498db;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    margin-top: 15px;
    font-weight: 700;
    transition: background-color 0.2s;
}

.item-info a:hover {
    background-color: #2980b9;
}
.expiry-label {
  color: white;
  text-align: left;
  font-size: 14px;
  margin-bottom: 4px;
  display: block;
}
