/**
 * user-history.css
 * Historyタブ（プロンプト履歴 + お気に入り）のスタイル
 */

/* ── パネルレイアウト ── */
.history-panel {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

/* ── サブタブ ── */
.history-sub-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 4px;
}

.history-sub-tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.history-sub-tab:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.history-sub-tab.active {
    background: var(--accent-primary);
    color: #fff;
}

/* ── 検索 ── */
.history-search {
    margin-bottom: 16px;
}

.history-search-input {
    width: 100%;
    padding: 10px 14px 10px 36px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.history-search-input:focus {
    border-color: var(--accent-primary);
}

.history-search-wrap {
    position: relative;
}

.history-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
    font-size: 0.9rem;
}

/* ── ヘッダーバー（検索 + クリアボタン） ── */
.history-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.history-toolbar .history-search-wrap {
    flex: 1;
}

.history-clear-btn {
    padding: 8px 14px;
    background: transparent;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.history-clear-btn:hover {
    border-color: var(--danger, #f44);
    color: var(--danger, #f44);
}

/* ── プロンプトカード ── */
.history-prompt-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 10px;
    transition: all 0.2s;
}

/* サムネ付きカード: 横並び */
.history-prompt-card--has-thumb {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.history-card-thumb {
    flex-shrink: 0;
    width: 100px;
    border-radius: 6px;
    overflow: hidden;
}

.history-card-thumb img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
}

.history-card-text {
    flex: 1;
    min-width: 0;
}

.history-prompt-card:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 2px 12px rgba(var(--accent-primary-rgb, 99, 102, 241), 0.1);
}

.history-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.history-card-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.history-mode-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.history-mode-badge[data-mode="detailed"] {
    background: rgba(99, 102, 241, 0.15);
    color: rgb(129, 132, 255);
}

.history-mode-badge[data-mode="simple"] {
    background: rgba(52, 211, 153, 0.15);
    color: rgb(52, 211, 153);
}

.history-mode-badge[data-mode="raw"] {
    background: rgba(251, 191, 36, 0.15);
    color: rgb(251, 191, 36);
}

/* フィールド行 */
.history-card-body {
    margin-bottom: 8px;
}

.history-field {
    display: flex;
    gap: 8px;
    margin-bottom: 3px;
    font-size: 0.8rem;
    line-height: 1.4;
}

.history-field-label {
    flex-shrink: 0;
    color: var(--text-secondary);
    font-weight: 500;
    min-width: 80px;
}

.history-field-value {
    color: var(--text-primary);
    word-break: break-all;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* パラメータ */
.history-card-params {
    font-size: 0.7rem;
    color: var(--text-tertiary, var(--text-secondary));
    margin-bottom: 8px;
    opacity: 0.7;
}

/* アクションボタン */
.history-card-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.history-action-btn {
    padding: 5px 12px;
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.history-action-btn:hover {
    background: var(--accent-primary);
    color: #fff;
    border-color: var(--accent-primary);
}

.history-action-btn--secondary {
    padding: 5px 8px;
}

.history-action-btn--danger:hover {
    background: var(--danger, #f44);
    border-color: var(--danger, #f44);
}

/* 削除アニメーション */
.history-card--removing {
    animation: historyCardRemove 0.3s ease forwards;
}

@keyframes historyCardRemove {
    to {
        opacity: 0;
        transform: translateX(20px);
        max-height: 0;
        padding: 0;
        margin: 0;
        overflow: hidden;
    }
}

/* ── お気に入りグリッド ── */
.history-fav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.history-fav-stats {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.history-fav-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.history-fav-card {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid var(--border-primary);
    transition: all 0.2s;
}

.history-fav-card:hover {
    border-color: var(--accent-primary);
    transform: scale(1.02);
}

.history-fav-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.history-fav-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 0.7rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-fav-card:hover .history-fav-remove {
    opacity: 1;
}

.history-fav-remove:hover {
    background: var(--danger, #f44);
}

/* ── 空状態 ── */
.history-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

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

/* ── レスポンシブ ── */
@media (max-width: 600px) {
    .history-panel {
        padding: 16px 12px;
    }

    .history-field-label {
        min-width: 60px;
        font-size: 0.7rem;
    }

    .history-fav-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}
