/* ===== CSS変数の定義 ===== */
:root {
    --main-text-color: #1f1f1f;
    --header-text-color: #333;
    --link-color: #1677ff;
    --link-hover-color: #1677ff;
    --active-link-bg-color: #1677ff;
    --active-link-text-color: #fff;
    --light-blue-gray: #d8dbe0;
    --very-light-blue-gray: #f0f4f8;
    --heading-bg-color: #fff;
    --border-color: #e0e0e0;
    --font-family-montserrat: "Montserrat", sans-serif;
    --font-family-noto-sans-jp: "Noto Sans JP", sans-serif;

    --unified-color: var(--light-blue-gray);

    --button-primary-bg: var(--unified-color);
    --button-secondary-bg: var(--unified-color);
    --button-info-bg: var(--unified-color);
    --button-text-color: var(--header-text-color);
}

/* ===== ページ全体のベース設定 ===== */
body {
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
    font-family: var(--font-family-noto-sans-jp);
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    box-sizing: border-box;
    padding-top: 50px;
    padding-bottom: 60px;
}

/* ===== ヘッダー ===== */
#main-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #1f1f1f;
    border-bottom: 1px solid #444;
    height: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    z-index: 20;
    box-sizing: border-box;
}

#main-header .logo {
    display: flex;
    align-items: center;
}

#main-header .header-image {
    width: 35px;
    height: 35px;
    margin-right: 10px;
}

#main-header .title {
    font-family: var(--font-family-montserrat);
    color: #fff;
    font-size: 1.3rem;
}

/* カメラ/画像表示エリア */
#camera,
#captured-image {
    position: absolute;
    top: 50px;
    left: 0;
    width: 100%;
    height: calc(100dvh - 50px - 60px);
    object-fit: cover;
    z-index: 1;
}

#captured-image {
     z-index: 2;
}

/* ボタンのコンテナ */
.button-container {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 5px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,0.8);
    z-index: 10;
    height: 60px;
    box-sizing: border-box;
    gap: 35px;
}

/* 共通ボタン スタイル */
#capture-button,
#preview-upload-button {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    outline: none;
    color: var(--button-text-color);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.6rem;
    padding: 0;
    margin: 0;
    background-color: var(--unified-color);
    position: relative;
}

/* 枚数表示バッジのスタイル */
#photo-count-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background-color: #dc3545;
    color: white;
    border-radius: 50%;
    padding: 2px 5px;
    font-size: 0.7rem;
    line-height: 1;
    min-width: 16px;
    text-align: center;
    box-shadow: 0 0 2px rgba(0,0,0,0.5);
    display: none;
}

/* canvasは非表示 */
#canvas {
    display: none;
}

/* プレビューコンテナ */
#upload-preview-container {
    position: absolute;
    top: 50px;
    left: 0;
    width: 100%;
    max-height: calc(100dvh - 50px - 60px);
    background-color: #f5f5f5;
    padding: 30px 10px 10px 10px;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    column-gap: 8px;
    row-gap: 20px;
    align-items: start;
    overflow-y: auto;
    z-index: 3;
}

.preview-image-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

#upload-preview-container img {
    width: 100%;
    max-width: 100px;
    height: auto;
    object-fit: contain;
    display: block;
    border: 1px solid #ddd;
    box-sizing: border-box;
    background-color: #eee;
}

.delete-preview-image {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 24px;
    height: 24px;
    background-color: #6c757d;
    color: white;
    border: none;
    outline: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    z-index: 5;
    transition: background-color 0.2s ease;
}
.delete-preview-image:hover {
    background-color: #5a6268;
    color: white;
}
.delete-preview-image i {
    pointer-events: none;
}

#upload-progress-text {
    position: sticky;
    top: 0;
    left: 0;
    grid-column: 1 / -1;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 8px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--header-text-color);
    z-index: 4;
    margin-bottom: 8px;
}

@media (max-width: 375px) {
    #main-header {
        height: 40px;
    }
    #main-header .header-image {
        width: 25px;
        height: 25px;
    }
    #main-header .title {
        font-size: 1.1rem;
    }

    .button-container {
        height: 60px;
        padding: 5px 0;
        gap: 30px;
    }
    #capture-button,
    #preview-upload-button {
        width: 45px;
        height: 45px;
        font-size: 1.5rem;
    }
     #photo-count-badge {
        top: -3px;
        right: -3px;
        padding: 1px 4px;
        font-size: 0.65rem;
        min-width: 15px;
     }

    body {
        padding-top: 40px;
        padding-bottom: 60px;
    }
    #camera,
    #captured-image,
    #upload-preview-container {
        top: 40px;
        max-height: calc(100dvh - 40px - 60px);
        height: calc(100dvh - 40px - 60px);
    }
    #upload-preview-container {
        column-gap: 5px;
        row-gap: 15px;
    }
    #upload-preview-container img {
        max-width: 90px;
    }
    .delete-preview-image {
        width: 20px;
        height: 20px;
        font-size: 1.3em;
        top: -9px;
        right: 3px;
    }
}

/* スピナーアニメーション */
.spinner {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
