/* --- 1. A4用紙サイズと印刷設定 --- */
@page {
    size: A4 portrait;
    margin: 0;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f9f9f9;
    margin: 0;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    /* 上下に配置 */
    align-items: center;
    min-height: 100vh;
    box-sizing: border-box;
}

.pdf-btn:hover {
    background-color: #0056b3;
}

.pdf-btn:active {
    transform: scale(0.98);
}

/* A4用紙相当のメインコンテナ */
.a4-page {
    width: 210mm;
    height: 297mm;
    background-color: #fff;
    padding: 12mm 15mm;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 12mm;
    position: relative;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
}

/* --- 2. 一番上：テキストエリア --- */
.header-container {
    width: 100%;
}

.side-text-area {
    width: 100%;
    box-sizing: border-box;
}

.side-text-area input[type="text"] {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
    color: #333;
    background-color: #fff;
    box-sizing: border-box;
    outline: none;
}

.side-text-area input[type="text"]:focus {
    border-color: #888;
}

/* --- 3. メイン：2x2 グリッドレイアウト --- */
.content-grid {
    display: grid;
    /* grid-item の幅を現在より約10%大きくするため、比率を調整 (1.1fr : 0.9fr) */
    grid-template-columns: 1.1fr 1.1fr;
    gap: 12mm;
    flex: 1;
    width: 100%;
    min-height: 0;
}

/* 各セル要素共通設定 */
.grid-item {
    width: 100%;
    height: auto;
    /* 高さは内部の drop-area に合わせて自動決定 */
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: white;
    padding: 0;
    /* 隙間を無くすためパディングをゼロに */
    border: 1px solid #ddd;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
    /* 内部要素のはみ出しを防止 */
}

.grid-item img {
    width: 32px;
    height: 32px;
    object-fit: cover;
    margin-top: 2px;
    margin-bottom: 4px;
}

/* 写真ドロップエリアの設定 */
[id^="drop-area"] {
    width: 100%;
    /* grid-item の幅いっぱいに広げる */
    /* 左右・底辺のボーダー重複を防ぎ、隙間なくピッタリ重ねる設定 */
    margin: 0;
    border-top: 2px dashed #ccc;
    border-left: 1px dashed #ccc;
    border-right: 1px dashed #ccc;
    border-bottom: 2px dashed #ccc;

    /* 横:縦 = 1 : 1.1 のアスペクト比で固定 */
    aspect-ratio: 1 / 1.1;

    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 16px;
    position: relative;
    overflow: hidden;
    background-color: #fff;
    box-sizing: border-box;
}

[id^="drop-area"] img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* --- 4. マップの設定（下段右） --- */
#map {
    width: 100%;
    height: 100%;
    background-color: #e0e0e0;
    border: 1px solid #ccc;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- 5. 操作ボタンのコンテナ --- */
.button-container {
    display: none;
    flex-direction: row;
    gap: 8px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 255, 255, 0.95);
    padding: 8px;
    border: 1px solid #ddd;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    z-index: 1000;
}

.button-container button {
    width: 48px;
    text-align: center;
    padding: 6px 0;
    background-color: #fff;
    border: 2px solid #f00;
    border-radius: 4px;
    cursor: pointer;
    color: red;
    font-size: 12px;
}

#btn0delete {
    background-color: transparent;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: #777;
}

#btn0delete:hover {
    color: #111;
}

p {
    text-align: center;
    line-height: 1;
    margin: 0;
}

.grid-item a[href] img {
    cursor: pointer;
    transition: transform 0.2s;
}

.grid-item a[href] img:hover {
    transform: scale(1.1);
    filter: brightness(1.2);
}

/* --- 6. 印刷・PDF出力用メディアクエリ --- */
@media print {
    body {
        background-color: #fff;
        padding: 0;
    }

    .no-print,
    .action-bar,
    .button-container {
        display: none !important;
    }

    .a4-page {
        box-shadow: none;
        padding: 10mm 12mm;
        /* 印刷時の余白調整 */
    }

    /* 印刷時に隠す要素 */
    .no-print,
    .button-container {
        display: none !important;
    }

    /* 背景色や境界線を正確にPDF出力する設定 */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}