/* ===== History Page Styles ===== */

/* Main Tabs (History / Admin toggle) */
.main-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.main-tab {
    padding: 10px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.main-tab:hover {
    border-color: var(--text-muted);
    background: var(--bg-input);
}

.main-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.main-tab.admin-only {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
}

.main-tab.admin-only:hover {
    opacity: 0.9;
}

.main-tab.admin-only.active {
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Tab Panels */
.tab-panel {
    display: block;
}

/* History Item - Card style */
.history-item {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.history-item:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.history-thumb {
    width: 64px;
    height: 64px;
    border-radius: var(--radius);
    object-fit: cover;
    flex-shrink: 0;
}

.history-thumb-empty {
    width: 64px;
    height: 64px;
    border-radius: var(--radius);
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

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

.history-type {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-bottom: 4px;
}

.history-type.note {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.history-type.product {
    background: rgba(249, 115, 22, 0.2);
    color: #f97316;
}

.history-title-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 4px;
}

.history-title-row.ai {
    opacity: 0.9;
}

/* Horizontal layout for history items */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.history-titles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.history-title-col {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    background: var(--bg-input);
    border-radius: var(--radius);
}

.history-title-col.ai {
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.history-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.history-title {
    font-size: 0.95rem;
    font-weight: 500;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-title.ai {
    color: #8B5CF6;
}

.history-time {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.history-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0;
    transition: var(--transition);
    border-radius: 4px;
}

.history-item:hover .history-delete {
    opacity: 1;
}

.history-delete:hover {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

/* Filter Section */
.filter-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.filter-tabs {
    display: flex;
    gap: 8px;
}

.filter-tab {
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

.filter-tab:hover {
    border-color: var(--text-muted);
}

.filter-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.btn-danger {
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--error);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* History List */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* History Item */
.history-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: var(--transition);
}

.history-item:hover {
    border-color: var(--text-muted);
}

.history-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 12px;
}

.history-thumb {
    width: 80px;
    height: 80px;
    border-radius: var(--radius);
    object-fit: cover;
    flex-shrink: 0;
}

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

.history-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.history-type {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.history-type.note {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.history-type.product {
    background: rgba(249, 115, 22, 0.2);
    color: #f97316;
}

.history-content {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 12px;
}

.history-actions {
    display: flex;
    gap: 8px;
}

.history-btn {
    padding: 6px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
}

.history-btn:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.history-btn.delete {
    color: var(--error);
}

.history-btn.delete:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.empty-state h2 {
    font-size: 1.25rem;
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* Loading State */
.loading-state {
    text-align: center;
    padding: 60px 20px;
}

.loading-state .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

.loading-state p {
    color: var(--text-muted);
}

/* Search Box */
.filter-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-wrapper {
    position: relative;
}

.search-input {
    width: 200px;
    padding: 8px 12px 8px 36px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

/* Record Detail Panel */
.record-detail {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.detail-back {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 8px 16px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.detail-back:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.detail-time {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.detail-section {
    margin-bottom: 16px;
}

.detail-label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.detail-link a {
    color: var(--accent);
    font-size: 0.875rem;
    word-break: break-all;
}

.detail-link a:hover {
    text-decoration: underline;
}

.detail-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.detail-column {
    background: var(--bg-input);
    border-radius: var(--radius);
    padding: 16px;
}

.detail-column.ai {
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.detail-column-header {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.detail-content {
    font-size: 0.95rem;
    line-height: 1.6;
    word-break: break-word;
}

.detail-content.content-box {
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
}

.detail-content.ai-text {
    color: #A78BFA;
}

/* Responsive */
@media (max-width: 768px) {
    .filter-section {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-tabs {
        justify-content: center;
    }

    .filter-actions {
        flex-direction: column;
        gap: 8px;
    }

    .search-input {
        width: 100%;
    }

    .history-thumb {
        width: 60px;
        height: 60px;
    }

    .detail-columns {
        grid-template-columns: 1fr;
    }
}
/* Title Pair Layout (Original vs AI) */
.title-pair {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
}

.title-pair.ai {
    color: #A78BFA;
}

.title-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.title-pair.ai .title-label {
    color: #8B5CF6;
}

.title-text {
    font-size: 0.95rem;
    line-height: 1.4;
    word-break: break-word;
}

.history-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-left: auto;
}

.history-titles {
    margin-top: 8px;
}
