/* History Sidebar Styles */
.history-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 320px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.1);
}

.history-sidebar.active {
    transform: translateX(0);
}

.history-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.sync-indicator {
    font-size: 0.7rem;
    color: var(--sys-primary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    opacity: 0;
    transition: opacity 0.3s;
    margin-right: auto;
    margin-left: 0.75rem;
    pointer-events: none;
}

.sync-indicator.active {
    opacity: 1;
}

.sync-indicator::before {
    content: "";
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
    display: inline-block;
    animation: sync-pulse 1.5s infinite;
}

.sync-indicator::after {
    content: "최신화 중...";
}

@keyframes sync-pulse {
    0% { transform: scale(0.8); opacity: 0.4; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.8); opacity: 0.4; }
}

.history-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background 0.2s;
}

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

.history-search {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

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

.history-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.history-section-header {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 1rem 0.5rem 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.history-section-header::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border-color);
    opacity: 0.3;
}

.history-item {
    padding: 1rem;
    border-radius: 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

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

.history-item.active {
    border-color: var(--sys-primary);
    background: rgba(var(--sys-primary-rgb), 0.05);
}

.history-item.primary {
    border-color: var(--gold);
    background: rgba(234, 179, 8, 0.05);
    box-shadow: 0 0 15px rgba(234, 179, 8, 0.1);
}

.history-item.primary:hover {
    border-color: var(--gold);
    box-shadow: 0 4px 15px rgba(234, 179, 8, 0.2);
}

.primary-badge {
    position: absolute;
    top: -8px;
    right: 12px;
    background: var(--gold);
    color: #fff;
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 99px;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 2;
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.history-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.05rem;
    word-break: break-all;
    flex: 1;
}

.history-item-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.action-btn {
    padding: 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--hover-bg);
    color: var(--sys-primary);
}


.action-btn.delete:hover {
    color: #ff4d4d;
}

.history-info {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-top: 0.5rem;
    opacity: 0.9;
    font-weight: 500;
}

.history-gender {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-left: 0.4rem;
    font-weight: 400;
}

.history-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: right;
    margin-top: 0.4rem;
    opacity: 0.7;
}

.history-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.auth-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.auth-btn {
    width: 100%;
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.auth-icon-svg {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.btn-naver {
    background: #03C75A;
    color: white;
    border: none;
}

.btn-google {
    background: white;
    color: #333;
    border: 1px solid var(--border-color);
}

.btn-naver:hover {
    background: #02b351;
}

.btn-google:hover {
    background: #f8f9fa;
}

/* User Profile in Sidebar */
.user-profile {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.user-info-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

.user-avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 2px solid var(--border-color);
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.user-email {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

.logout-btn {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: var(--hover-bg);
    color: #ff4d4d;
    border-color: #ff4d4d;
}

.history-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(2px);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.history-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Sidebar Toggle Button */
.history-toggle {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 0.5rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.history-toggle:hover {
    background: var(--hover-bg);
}

/* Mobile responsive */
@media (max-width: 480px) {
    .history-sidebar {
        width: 85%;
        max-width: 300px;
    }

    .action-btn {
        padding: 12px;
        font-size: 1.1rem;
    }
}