/* ============================================
   ランダムサーチ - Tinder風UI
   ============================================ */

:root {
    --color-primary: #E53935;
    --color-primary-dark: #C62828;
    --color-like: #FF6B9D;
    --color-like-dark: #E91E63;
    --color-like-light: rgba(255, 107, 157, 0.15);
    --color-nope: #9E9E9E;
    --color-nope-light: rgba(158, 158, 158, 0.15);
    --color-text: #333;
    --color-text-light: #666;
    --color-text-muted: #999;
    --color-bg: #F5F5F5;
    --color-white: #FFF;
    --color-border: #E0E0E0;
    --color-star: #FFB300;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.16);
    --shadow-card: 0 10px 40px rgba(0,0,0,0.15);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 50%;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

/* ============================================
   アプリレイアウト
   ============================================ */
.app {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 500px;
    margin: 0 auto;
    background: linear-gradient(180deg, #FAFAFA 0%, #F0F0F0 100%);
}

/* ============================================
   ヘッダー
   ============================================ */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--color-white);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.header-back,
.header-help {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--color-text);
    text-decoration: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background 0.2s;
}

.header-back:hover,
.header-help:hover {
    background: var(--color-bg);
}

.header-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
}

/* ============================================
   カードコンテナ
   ============================================ */
.card-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    overflow: visible;
    z-index: 5;
}

/* 空状態 */
.empty-state {
    text-align: center;
    color: var(--color-text-muted);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.empty-link {
    display: inline-block;
    padding: 10px 20px;
    background: var(--color-primary);
    color: var(--color-white);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.875rem;
    transition: background 0.2s;
}

.empty-link:hover {
    background: var(--color-primary-dark);
}

/* ============================================
   カード
   ============================================ */
.card {
    position: absolute;
    width: calc(100% - 24px);
    max-width: 340px;
    background: var(--color-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    cursor: grab;
    touch-action: none;
    transition: box-shadow 0.3s;
    will-change: transform;
}

.card:active {
    cursor: grabbing;
}

.card.animating {
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.card.removing {
    transition: transform 0.5s ease-out, opacity 0.5s ease-out;
    pointer-events: none;
}

/* カードスタック効果 */
.card:nth-child(1) { z-index: 10; }
.card:nth-child(2) { z-index: 9; transform: scale(0.95) translateY(8px); }
.card:nth-child(3) { z-index: 8; transform: scale(0.9) translateY(16px); }
.card:nth-child(n+4) { z-index: 7; transform: scale(0.85) translateY(24px); opacity: 0; }

/* カード画像 */
.card-image-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    background: #F8F8F8;
    overflow: hidden;
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* LIKE/NOPEオーバーレイ */
.card-badge {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: 4px;
    color: #FFF;
    text-shadow: 0 2px 8px rgba(0,0,0,0.3);
    opacity: 0;
    transition: opacity 0.1s;
    z-index: 5;
    pointer-events: none;
}

.card-badge--like {
    background: rgba(255, 107, 157, 0.8);
}

.card-badge--nope {
    background: rgba(41, 182, 246, 0.8);
}

/* カード情報 */
.card-info {
    padding: 12px;
}

.card-name {
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--color-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 10px;
    min-height: 2.5em;
}

.card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.card-rating {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.card-stars {
    font-size: 0.7rem;
    color: var(--color-star);
    letter-spacing: -1px;
}

.card-review-count {
    font-size: 0.6rem;
    color: var(--color-text-muted);
}

.card-price {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-primary);
}

.card-buy-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: var(--color-white);
    text-align: center;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: var(--radius-md);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

/* ============================================
   アクションボタン（小さく）
   ============================================ */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 32px;
    padding: 10px 16px;
    flex-shrink: 0;
    background: transparent;
    pointer-events: none;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-md);
    pointer-events: auto;
}

.action-btn svg {
    width: 24px;
    height: 24px;
}

.action-btn:active {
    transform: scale(0.9);
}

.action-btn--skip {
    background: var(--color-white);
    color: var(--color-nope);
}

.action-btn--skip:hover {
    box-shadow: 0 4px 16px rgba(158, 158, 158, 0.4);
}

.action-btn--like {
    background: linear-gradient(135deg, #FF8FAB 0%, #FF6B9D 100%);
    color: var(--color-white);
}

.action-btn--like:hover {
    box-shadow: 0 4px 16px rgba(255, 107, 157, 0.5);
}

/* ============================================
   フッターナビ
   ============================================ */
.app-nav {
    display: flex;
    justify-content: space-around;
    padding: 6px 16px;
    padding-bottom: calc(6px + var(--safe-area-bottom));
    background: var(--color-white);
    border-top: 1px solid var(--color-border);
    flex-shrink: 0;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 20px;
    text-decoration: none;
    color: var(--color-text-muted);
    font-size: 0.6rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: color 0.2s, background 0.2s;
    position: relative;
}

.nav-item svg {
    width: 20px;
    height: 20px;
}

.nav-item--active {
    color: var(--color-primary);
}

.nav-item:hover {
    background: var(--color-bg);
}

.nav-badge {
    position: absolute;
    top: 0;
    right: 12px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--color-like);
    color: var(--color-white);
    font-size: 0.55rem;
    font-weight: 700;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-badge:empty,
.nav-badge[data-count="0"] {
    display: none;
}

/* ============================================
   チュートリアルオーバーレイ
   ============================================ */
.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.tutorial-overlay.show {
    opacity: 1;
    visibility: visible;
}

.tutorial-content {
    width: 90%;
    max-width: 340px;
    background: var(--color-white);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    animation: tutorialIn 0.4s ease;
}

@keyframes tutorialIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.tutorial-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border: none;
    background: var(--color-bg);
    color: var(--color-text-muted);
    font-size: 1.25rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background 0.2s;
}

.tutorial-close:hover {
    background: var(--color-border);
}

.tutorial-title {
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 20px;
    color: var(--color-text);
}

.tutorial-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.tutorial-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: var(--color-bg);
    border-radius: var(--radius-md);
}

.tutorial-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    width: 40px;
    text-align: center;
}

.tutorial-text strong {
    display: block;
    font-size: 0.8rem;
    color: var(--color-text);
    margin-bottom: 2px;
}

.tutorial-text p {
    font-size: 0.7rem;
    color: var(--color-text-light);
    margin: 0;
}

.tutorial-start-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--color-like) 0%, var(--color-like-dark) 100%);
    color: var(--color-white);
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s;
}

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

/* ============================================
   ライク一覧ページ
   ============================================ */
.likes-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--color-white);
    border-bottom: 1px solid var(--color-border);
}

.likes-title {
    font-size: 1.125rem;
    font-weight: 700;
}

.likes-count {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.likes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

.like-item {
    background: var(--color-white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
}

.like-item:active {
    transform: scale(0.98);
}

.like-item__image-wrap {
    width: 100%;
    aspect-ratio: 1;
    background: #F8F8F8;
}

.like-item__image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.like-item__info {
    padding: 10px;
}

.like-item__name {
    font-size: 0.75rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

.like-item__price {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--color-primary);
}

.like-item__remove {
    display: block;
    width: 100%;
    padding: 8px;
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.2s, color 0.2s;
}

.like-item__remove:hover {
    background: #FFEBEE;
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.likes-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
    color: var(--color-text-muted);
}

.likes-empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

.likes-empty p {
    margin-bottom: 12px;
}

/* ============================================
   管理画面
   ============================================ */
.admin-body {
    height: auto;
    overflow: auto;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--color-text);
    color: var(--color-white);
}

.admin-header h1 {
    font-size: 1.125rem;
}

.admin-header a {
    color: var(--color-white);
    text-decoration: none;
    opacity: 0.8;
    font-size: 0.875rem;
}

.admin-header a:hover {
    opacity: 1;
}

.admin-main {
    padding: 16px;
    max-width: 600px;
    margin: 0 auto;
}

.admin-section {
    background: var(--color-white);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.admin-section__title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
}

/* フォーム */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 10px;
    color: var(--color-text);
}

.form-input,
.form-select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--color-primary);
}

.form-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

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

.btn--primary {
    background: var(--color-primary);
    color: var(--color-white);
}

.btn--primary:hover {
    background: var(--color-primary-dark);
}

.btn--primary:disabled {
    background: var(--color-border);
    cursor: not-allowed;
}

.btn--full {
    width: 100%;
}

/* プログレス */
.progress-wrap {
    margin-top: 16px;
    display: none;
}

.progress-wrap.show {
    display: block;
}

.progress-bar {
    height: 8px;
    background: var(--color-bg);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    width: 0%;
    transition: width 0.3s;
}

.progress-text {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-align: center;
}

/* アラート */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.875rem;
}

.alert--success {
    background: #E8F5E9;
    color: #2E7D32;
}

.alert--error {
    background: #FFEBEE;
    color: var(--color-primary);
}

/* 商品プレビュー */
.product-preview {
    display: none;
    margin-top: 16px;
    padding: 16px;
    background: var(--color-bg);
    border-radius: var(--radius-md);
}

.product-preview.show {
    display: block;
}

.product-preview__list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.product-preview__item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--color-white);
    border-radius: var(--radius-sm);
}

.product-preview__image {
    width: 60px;
    height: 60px;
    object-fit: contain;
    background: #F8F8F8;
    border-radius: var(--radius-sm);
}

.product-preview__info {
    flex: 1;
    min-width: 0;
}

.product-preview__name {
    font-size: 0.75rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

.product-preview__meta {
    font-size: 0.625rem;
    color: var(--color-text-muted);
}

.product-preview__price {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--color-primary);
}

/* 登録済み商品数 */
.stats-box {
    display: flex;
    justify-content: space-around;
    padding: 16px;
    background: var(--color-bg);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

.stats-item {
    text-align: center;
}

.stats-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
}

.stats-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* ============================================
   アニメーション
   ============================================ */
@keyframes cardIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.card-new {
    animation: cardIn 0.3s ease;
}

/* ============================================
   レスポンシブ
   ============================================ */
@media (min-width: 500px) {
    .app {
        border-left: 1px solid var(--color-border);
        border-right: 1px solid var(--color-border);
    }
}

/* チュートリアル紹介文 */
.tutorial-intro {
    background: linear-gradient(135deg, #FFF5F5 0%, #FFF0F5 100%);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 16px;
}

.tutorial-intro p {
    font-size: 0.85rem;
    line-height: 1.6;
    color: #555;
    margin: 0;
}

.tutorial-intro p + p {
    margin-top: 8px;
}

.tutorial-divider {
    height: 1px;
    background: #E0E0E0;
    margin: 16px 0;
}

.tutorial-subtitle {
    font-size: 0.9rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 12px;
}

/* チュートリアル紹介文 */
.tutorial-intro {
    background: linear-gradient(135deg, #FFF5F5 0%, #FFF0F5 100%);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 16px;
}

.tutorial-intro p {
    font-size: 0.85rem;
    line-height: 1.6;
    color: #555;
    margin: 0;
}

.tutorial-intro p + p {
    margin-top: 8px;
}

.tutorial-divider {
    height: 1px;
    background: #E0E0E0;
    margin: 16px 0;
}

.tutorial-subtitle {
    font-size: 0.9rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 12px;
}

/* ヘルプボタンSVG修正 */
.header-help svg {
    color: #666;
    stroke: #666;
}

.header-help:hover svg {
    color: #333;
    stroke: #333;
}

/* ヘルプボタンSVG修正 */
.header-help svg {
    color: #666;
    stroke: #666;
}

.header-help:hover svg {
    color: #333;
    stroke: #333;
}

/* 戻るボタン */
.action-btn--undo {
    width: 50px;
    height: 50px;
    background: #FFF;
    color: #CCC;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.action-btn--undo.active {
    color: #FF9800;
}

.action-btn--undo:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-btn--undo svg {
    width: 20px;
    height: 20px;
}

/* 戻るアニメーション */
.card-undo {
    animation: cardUndo 0.3s ease-out;
}

@keyframes cardUndo {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}
