/* ══════════════════════════════════════════════════════════
   Favorites System + Bookmark Hint
   ══════════════════════════════════════════════════════════ */

/* ── Star button on tool pages ── */
.fav-star-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    background: var(--color-bg-secondary);
    border: 1.5px solid var(--color-border);
    border-radius: 50%;
    color: var(--color-text-muted);
    font-size: 15px;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.fav-star-btn:hover {
    border-color: #F59E0B;
    color: #F59E0B;
    background: rgba(245, 158, 11, 0.08);
    transform: scale(1.08);
}

.fav-star-btn--active {
    border-color: #F59E0B;
    color: #F59E0B;
    background: rgba(245, 158, 11, 0.1);
}

@keyframes fav-star-pop {
    0%   { transform: scale(1); }
    30%  { transform: scale(1.45); }
    55%  { transform: scale(0.9); }
    75%  { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.fav-star-btn--pop {
    animation: fav-star-pop 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

/* ── Star button on tool cards ── */
.tool-card-fav-btn {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 50%;
    color: var(--color-text-muted);
    font-size: 11px;
    cursor: pointer;
    transition: all var(--transition-fast);
    z-index: 2;
    opacity: 0;
}

.tool-card:hover .tool-card-fav-btn,
.tool-card-fav-btn--active {
    opacity: 1;
}

.tool-card-fav-btn:hover,
.tool-card-fav-btn--active {
    border-color: #F59E0B;
    color: #F59E0B;
    background: rgba(245, 158, 11, 0.1);
    transform: scale(1.1);
}

@keyframes fav-card-pop {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.5); }
    70%  { transform: scale(0.92); }
    100% { transform: scale(1); }
}

.tool-card-fav-btn--pop {
    animation: fav-card-pop 0.42s ease;
}

/* Ensure tool-card has position:relative for the star overlay */
.tool-card { position: relative; }

/* ── Header My Tools button ── */
.fav-wrap {
    position: relative;
}

.fav-header-btn {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: 6px 12px;
    background: transparent;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-full);
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    font-family: inherit;
}

.fav-header-btn:hover {
    border-color: #F59E0B;
    color: #F59E0B;
    background: rgba(245, 158, 11, 0.07);
}

.fav-header-btn i {
    font-size: 12px;
    color: #F59E0B;
}

.fav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    background: #F59E0B;
    color: #fff;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

/* ── Favorites dropdown ── */
.fav-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 300px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
    z-index: 500;
    opacity: 0;
    transform: translateY(-8px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    overflow: hidden;
}

.fav-dropdown--open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.fav-dropdown-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: var(--color-bg-secondary);
    border-bottom: 1px solid var(--color-border);
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.fav-dropdown-header i { color: #F59E0B; }

.fav-dropdown-list {
    max-height: 280px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
}

.fav-empty {
    padding: var(--space-6) var(--space-4);
    text-align: center;
    color: var(--color-text-muted);
}

.fav-empty i {
    font-size: 2rem;
    color: var(--color-border);
    display: block;
    margin-bottom: var(--space-3);
}

.fav-empty p {
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
    margin: 0;
}

.fav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    text-decoration: none;
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border);
    transition: background var(--transition-fast);
}

.fav-item:last-child { border-bottom: none; }

.fav-item:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
    text-decoration: none;
}

.fav-item-star {
    font-size: 12px;
    color: #F59E0B;
    flex-shrink: 0;
}

.fav-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.fav-item-name {
    font-size: var(--text-sm);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fav-item-cat {
    font-size: 11px;
    color: var(--color-text-muted);
}

.fav-item-remove {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 50%;
    color: var(--color-text-subtle);
    font-size: 10px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition-fast);
    opacity: 0;
}

.fav-item:hover .fav-item-remove { opacity: 1; }
.fav-item-remove:hover { border-color: #EF4444; color: #EF4444; }

.fav-dropdown-footer {
    padding: var(--space-2) var(--space-4);
    border-top: 1px solid var(--color-border);
    background: var(--color-bg-secondary);
}

.fav-clear-btn {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
}

.fav-clear-btn:hover { border-color: #EF4444; color: #EF4444; }

/* ── Home page favorites section ── */
#fav-home-section {
    background: var(--color-bg-secondary);
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
}

.fav-home-card {
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: visible;
}

.fav-home-card-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
}

.fav-home-card-link:hover { color: inherit; text-decoration: none; }

.fav-home-card-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #F59E0B, #FCD34D);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 16px;
    margin-bottom: var(--space-3);
}

.fav-home-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 50%;
    color: var(--color-text-muted);
    font-size: 9px;
    cursor: pointer;
    transition: all var(--transition-fast);
    opacity: 0;
    z-index: 2;
}

.fav-home-card:hover .fav-home-remove { opacity: 1; }
.fav-home-remove:hover { border-color: #EF4444; color: #EF4444; }

/* ── PWA Install Button (header) ── */
.pwa-install-btn {
    display: none;
    align-items: center;
    gap: var(--space-1);
    padding: 6px 12px;
    background: linear-gradient(135deg, var(--color-accent), #7C3AED);
    border: none;
    border-radius: var(--radius-full);
    color: #fff;
    font-size: var(--text-xs);
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    font-family: inherit;
    box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}

.pwa-install-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.4); }
.pwa-install-btn i { font-size: 11px; }

/* ── Bookmark Hint ── */
.bookmark-hint {
    position: fixed;
    bottom: -80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9998;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #F1F5F9;
    border-radius: 14px;
    font-size: var(--text-sm);
    font-family: var(--font-primary);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.06);
    transition: bottom 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    max-width: min(90vw, 480px);
    white-space: nowrap;
}

.bookmark-hint--visible  { bottom: 28px; }
.bookmark-hint--hiding   { bottom: -80px; transition-timing-function: ease-in; }

.bookmark-hint-icon { font-size: 16px; flex-shrink: 0; }

.bookmark-hint-text { flex: 1; white-space: normal; line-height: 1.4; }

.bookmark-hint-text strong { color: #60A5FA; font-weight: 600; }

.bookmark-hint-close {
    background: none;
    border: none;
    color: #94A3B8;
    font-size: 14px;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
    line-height: 1;
}

.bookmark-hint-close:hover { color: #F1F5F9; background: rgba(255,255,255,0.12); }

/* ── Dark mode adjustments ── */
[data-theme="dark"] .fav-dropdown { box-shadow: 0 16px 48px rgba(0,0,0,0.4); }
[data-theme="dark"] .tool-card-fav-btn { background: var(--color-bg-secondary); }
[data-theme="dark"] .fav-home-remove { background: var(--color-bg-tertiary); }

/* ── Responsive ── */
@media (max-width: 768px) {
    .fav-header-label { display: none; }
    .fav-header-btn { padding: 6px 10px; }
    .fav-dropdown { right: auto; left: 50%; transform: translateX(-50%) translateY(-8px) scale(0.97); width: min(300px, 90vw); }
    .fav-dropdown--open { transform: translateX(-50%) translateY(0) scale(1); }

    .bookmark-hint {
        left: 12px;
        right: 12px;
        transform: none;
        max-width: none;
        bottom: -120px;
        white-space: normal;
    }
    .bookmark-hint--visible  { bottom: 16px; }
    .bookmark-hint--hiding   { bottom: -120px; }
}

@media (max-width: 480px) {
    .pwa-install-btn span { display: none; }
    .pwa-install-btn { padding: 6px 10px; }
}
