/* --- ベース設定 --- */
:root {
    --primary-color: #2563eb; /* Blue 600 */
    --primary-hover: #1d4ed8; /* Blue 700 */
    --bg-color: #f9fafb;      /* Gray 50 */
    --text-color: #1f2937;    /* Gray 800 */
    --border-color: #d1d5db;  /* Gray 300 */
    --white: #ffffff;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.2;
}

/* --- ヘッダー --- */
.app-header {
    background-color: var(--primary-color);
    color: var(--white);
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-title {
    font-size: 1.25rem;
    font-weight: bold;
    flex-grow: 1;
    text-align: center;
    margin: 0;
}

.btn-reset {
    background-color: var(--white);
    color: var(--primary-color);
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    font-weight: bold;
    text-decoration: none;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    transition: background-color 0.2s;
}

.btn-reset:hover {
    background-color: #f3f4f6;
}

.hidden {
    display: none !important;
}

/* --- メインコンテンツ --- */
.main-container {
    max-width: 48rem; /* 768px */
    margin: 0 auto;
    padding: 0rem;
    padding-bottom: 0.5rem;
}

/* --- 検索画面 (全画面) --- */
.search-screen {
    min-height: 90vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.search-card {
    background-color: var(--white);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

/* フォームレイアウト */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.0rem;
}

@media (min-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr 1fr;
    }
    .col-span-2 {
        grid-column: span 2;
    }
}

/* フォーム要素共通 */
.form-group label {
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    font-weight: bold;
    color: #374151;
    margin-bottom: 0.5rem;
}

.help-icon {
    color: #9ca3af;
    margin-left: 0.5rem;
    cursor: pointer;
}

.help-icon:hover {
    color: var(--primary-color);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 0.75rem;
    color: #9ca3af;
    z-index: 10;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    padding-left: 2.5rem; /* アイコン分 */
    padding-right: 3rem;  /* ボタン分 */
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: var(--white);
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* 場所指定エリアのスタイル */
.location-group {
    background-color: #eff6ff; /* Blue 50 */
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid #dbeafe;
}

.radio-group {
    display: flex;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-right: 1rem;
}

.radio-label input {
    margin-right: 0.25rem;
    accent-color: var(--primary-color);
}

.btn-current-loc {
    position: absolute;
    right: 0.25rem;
    top: 0.25rem;
    bottom: 0.25rem;
    background-color: #f3f4f6;
    color: #4b5563;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    padding: 0 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-current-loc:hover {
    background-color: #e5e7eb;
}

.address-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.address-grid .form-control {
    padding-left: 0.75rem; /* アイコンなし */
    padding-right: 0.75rem;
}

/* ジャンル入力 */
.genre-select-wrapper .form-control {
    padding-left: 0.75rem;
}

/* ラジオボタングループ (件数、口コミ数) */
.radio-options {
    display: flex;
    align-items: center;
    height: 42px;
    gap: 1rem;
}

.radio-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.chip-label {
    flex: 1;
    min-width: 60px;
    cursor: pointer;
}

.chip-label input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.chip-text {
    display: block;
    text-align: center;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    font-size: 0.75rem; /* text-xs */
    transition: all 0.2s;
}

.chip-label:hover .chip-text {
    background-color: #f9fafb;
}

.chip-label input:checked + .chip-text {
    background-color: #dbeafe; /* Blue 100 */
    border-color: var(--primary-color);
    color: #1d4ed8;
}

/* 検索ボタン */
.btn-search-main {
    width: 100%;
    margin-top: 2rem;
    background-color: var(--primary-color);
    color: var(--white);
    font-weight: bold;
    font-size: 1.125rem;
    padding: 1rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-search-main:hover {
    background-color: var(--primary-hover);
}

.btn-search-main i {
    margin-right: 0.5rem;
}

/* --- 進捗ログ --- */
.status-log {
    background-color: #1f2937;
    color: var(--white);
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    font-family: monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    box-shadow: var(--shadow);
}

.log-title {
    font-weight: bold;
    border-bottom: 1px solid #4b5563;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    color: #d1d5db;
}

.log-content {
    height: 10rem; /* h-40 */
    overflow-y: auto;
}

.log-item {
    color: #93c5fd;
    animation: fadeIn 0.3s ease-out forwards;
}
.log-item.success { color: #4ade80; font-weight: bold; }
.log-item.error { color: #f87171; font-weight: bold; }
.log-item.warn { color: #facc15; }

/* スクロールバーカスタマイズ */
.log-content::-webkit-scrollbar { width: 6px; }
.log-content::-webkit-scrollbar-thumb { background-color: #4b5563; border-radius: 3px; }

/* --- 結果エリア --- */
.map-wrapper {
    background-color: var(--white);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 1.5rem;
    border: 1px solid #e5e7eb;
}

#map {
    height: 350px;
    width: 100%;
}

@media (min-width: 768px) {
    #map { height: 450px; }
}

.result-title {
    font-size: 1.125rem;
    font-weight: bold;
    color: var(--text-color);
    margin-bottom: 0.75rem;
    padding-left: 0.75rem;
    border-left: 4px solid var(--primary-color);
}

.result-list {
    max-height: 600px;
    overflow-y: auto;
}

/* カードスタイル (JSで生成される要素用) */
.restaurant-card {
    background-color: var(--white);
    padding: 0.75rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    border: 1px solid #f3f4f6;
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: transform 0.1s, background-color 0.2s;
}

.restaurant-card:hover {
    background-color: #eff6ff;
    transform: translateY(-2px);
}

.card-img-wrapper {
    position: relative;
    width: 6rem;
    height: 6rem;
    flex-shrink: 0;
}

.card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0.25rem;
    background-color: #e5e7eb;
}

.card-rank {
    position: absolute;
    top: 0;
    left: 0;
    background-color: var(--primary-color);
    color: var(--white);
    font-weight: bold;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    border-bottom-right-radius: 0.25rem;
}

.card-content {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card-title {
    font-weight: bold;
    font-size: 1.125rem;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.card-rating {
    display: flex;
    align-items: center;
    color: #eab308; /* Yellow 500 */
    font-size: 0.875rem;
    margin: 0.25rem 0;
}

.card-rating-count {
    color: #9ca3af;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.card-vicinity {
    font-size: 0.75rem;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-footer {
    margin-top: 0.5rem;
    text-align: right;
}

.card-link {
    color: var(--primary-color);
    font-size: 0.75rem;
    font-weight: bold;
    text-decoration: none;
}

.card-link:hover {
    text-decoration: underline;
}

/* --- アニメーション --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

/* --- モーダル --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: rgba(17, 24, 39, 0.5); /* Gray 900 / 0.5 */
}

.modal-container {
    background-color: var(--white);
    width: 90%;
    max-width: 28rem;
    border-radius: 0.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    z-index: 50;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-content {
    padding: 1.5rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 0.75rem;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: bold;
    color: #374151;
    margin: 0;
}

.modal-close {
    cursor: pointer;
    font-size: 1.25rem;
    color: #6b7280;
}

.modal-close:hover {
    color: #ef4444;
}

.modal-body {
    margin: 1.25rem 0;
    font-size: 0.875rem;
    color: #4b5563;
    line-height: 1.6;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 0.5rem;
}

.btn-close {
    background-color: var(--primary-color);
    color: var(--white);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    font-weight: bold;
}

.btn-close:hover {
    background-color: var(--primary-hover);
}


/* --- PWA関連 --- */

/* iOS用インストール案内 */
.ios-prompt {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 350px;
    background-color: var(--white);
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    border-radius: 10px;
    padding: 1rem;
    z-index: 10000;
    border: 1px solid var(--primary-color);
    animation: slideUp 0.5s ease-out;
}

.ios-prompt-content {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-color);
}

.ios-instructions {
    margin: 10px 0;
    font-weight: bold;
    color: var(--primary-color);
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.btn-close-prompt {
    background: #f3f4f6;
    border: none;
    padding: 5px 15px;
    border-radius: 15px;
    font-size: 0.8rem;
    color: #6b7280;
    cursor: pointer;
}

@keyframes slideUp {
    from { transform: translate(-50%, 100px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

/* Android/PC用 インストールボタン */
.btn-pwa-install {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 50px;
    padding: 12px 20px;
    font-weight: bold;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    z-index: 9999;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: fadeIn 1s;
}

.btn-pwa-install:hover {
    background-color: var(--primary-hover);
}