/* Tool user widgets — favorites, recent visits, category nav */

:root {
    --site-header-height: 4.5rem;
}

.tool-user-widget {
    position: relative;
    display: inline-flex;
}

.tool-user-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #374151;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    white-space: nowrap;
    min-height: 2.75rem;
}

.tool-user-trigger:hover {
    border-color: #bfdbfe;
    background: #f8fafc;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
}

.tool-user-trigger__icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tool-user-trigger__icon {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
}

.tool-user-trigger__icon--favorites {
    background: #fdf2f8;
    color: #db2777;
}

.tool-user-trigger__icon--recent {
    background: #eff6ff;
    color: #2563eb;
}

.tool-user-badge {
    position: absolute;
    top: -4px;
    inset-inline-start: -4px;
    min-width: 1.125rem;
    height: 1.125rem;
    padding: 0 0.25rem;
    border-radius: 9999px;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: #fff;
    font-size: 0.625rem;
    font-weight: 700;
    line-height: 1.125rem;
    text-align: center;
    border: 2px solid #fff;
    pointer-events: none;
}

.tool-user-badge--favorites {
    background: linear-gradient(135deg, #db2777, #ec4899);
}

.tool-user-badge.hidden {
    display: none !important;
}

.tool-user-panel[aria-hidden="true"]:not(.is-open) {
    display: none !important;
}

.tool-user-panel.is-open,
.tool-user-panel[aria-hidden="false"] {
    display: flex;
}

.tool-user-panel {
    position: fixed;
    z-index: 65;
    width: min(22rem, calc(100vw - 2rem));
    max-height: min(24rem, calc(100vh - var(--site-header-height, 4.5rem) - 2rem));
    overflow: hidden;
    display: none;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.14);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0.2s;
}

.tool-user-panel.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.tool-user-panel__handle {
    display: none;
}

.tool-user-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem;
    border-bottom: 1px solid #f1f5f9;
    background: linear-gradient(to left, #f8fafc, #fff);
    flex-shrink: 0;
}

.tool-user-panel__header-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.tool-user-panel__header-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
}

.tool-user-panel__header-icon--favorites {
    background: linear-gradient(145deg, #fdf2f8, #fce7f3);
    color: #db2777;
}

.tool-user-panel__header-icon--recent {
    background: linear-gradient(145deg, #eff6ff, #dbeafe);
    color: #2563eb;
}

.tool-user-panel__header-title {
    display: block;
    font-weight: 700;
    font-size: 0.9375rem;
    color: #111827;
    line-height: 1.3;
}

.tool-user-panel__header-sub {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: #64748b;
    margin-top: 0.125rem;
}

.tool-user-panel__close {
    width: 2.75rem;
    height: 2.75rem;
    border: none;
    border-radius: 0.5rem;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-user-panel__close:hover {
    background: #f3f4f6;
    color: #374151;
}

.tool-user-panel__body {
    overflow-y: auto;
    padding: 0.75rem;
    flex: 1;
    overscroll-behavior: contain;
}

.tool-user-panel__row {
    display: flex;
    align-items: stretch;
    gap: 0.375rem;
}

.tool-user-panel__row + .tool-user-panel__row {
    margin-top: 0.5rem;
}

.tool-user-panel__row .tool-user-panel__item {
    flex: 1;
    min-width: 0;
}

.tool-user-panel__item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 0.875rem;
    border: 1px solid #f1f5f9;
    background: #fafafa;
    color: #374151;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.tool-user-panel__item:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #2563eb;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.08);
}

.tool-user-panel__item-icon {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.625rem;
    background: linear-gradient(145deg, #eff6ff, #dbeafe);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #2563eb;
    font-size: 0.875rem;
}

.tool-user-panel__item-name {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tool-user-panel__remove {
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid transparent;
    border-radius: 0.625rem;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.tool-user-panel__remove:hover {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}

.tool-user-panel__empty {
    padding: 2rem 1rem;
    text-align: center;
    font-size: 0.875rem;
    color: #64748b;
    line-height: 1.7;
    background: #f8fafc;
    border-radius: 0.875rem;
    border: 1px dashed #e2e8f0;
}

.tool-user-panel__footer {
    padding: 0.5rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #f3f4f6;
    flex-shrink: 0;
}

.tool-user-panel__clear {
    width: 100%;
    min-height: 2.75rem;
    padding: 0.5rem;
    border: none;
    border-radius: 0.5rem;
    background: #f9fafb;
    color: #6b7280;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
}

.tool-user-panel__clear:hover {
    background: #f3f4f6;
    color: #374151;
}

/* Header layout with widgets */
.site-header-tool-actions {
    display: none;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

@media (min-width: 1024px) {
    .site-header-tool-actions {
        display: flex;
    }
}

@media (min-width: 1024px) and (max-width: 1279px) {
    .site-header-nav {
        gap: 0.75rem;
    }
}

.site-header-tool-actions .tool-user-trigger {
    padding: 0;
    width: 2.75rem;
    height: 2.75rem;
    min-height: 2.75rem;
    justify-content: center;
    gap: 0;
}

.site-header-mobile-tool-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

@media (min-width: 1024px) {
    .site-header-mobile-tool-actions {
        display: none;
    }
}

.site-header-mobile-tool-actions .tool-user-trigger {
    padding: 0;
    font-size: inherit;
    width: 2.75rem;
    height: 2.75rem;
    min-height: 2.75rem;
    justify-content: center;
    gap: 0;
}

.site-header-mobile-tool-actions .tool-user-trigger__label {
    display: none;
}

/* Mobile bottom sheet — above PWA bottom nav (z-index 9000) */
@media (max-width: 1023px) {
    .tool-user-panel--sheet {
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100%;
        max-height: min(85vh, calc(100dvh - var(--site-header-height, 4.5rem)));
        border-radius: 1.25rem 1.25rem 0 0;
        transform: translateY(100%);
        z-index: 9600;
    }

    .tool-user-panel--sheet.is-open {
        transform: translateY(0);
    }

    .tool-user-panel__handle {
        display: block;
        flex-shrink: 0;
        width: 2.5rem;
        height: 0.25rem;
        margin: 0.625rem auto 0.25rem;
        border-radius: 9999px;
        background: #d1d5db;
    }

    .tool-user-sheet-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        backdrop-filter: blur(2px);
        z-index: 9550;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.25s ease, visibility 0.25s;
    }

    body.tool-user-sheet-open .tool-user-sheet-backdrop {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    body.tool-user-sheet-open {
        overflow: hidden;
        overscroll-behavior: none;
    }
}

@media (min-width: 1024px) {
    .tool-user-sheet-backdrop {
        display: none;
    }

    .tool-user-panel__handle {
        display: none !important;
    }
}

/* Favorite button on tool page */
.tool-favorite-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #374151;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.tool-favorite-btn--sidebar {
    width: 100%;
    height: auto;
    min-height: 3rem;
    padding: 0.625rem 0.75rem;
    gap: 0.75rem;
    justify-content: flex-start;
    border-color: #e5e7eb;
    background: #fff;
    font-weight: 600;
    border-radius: 0.75rem;
}

.tool-favorite-btn--sidebar .tool-favorite-btn__icon {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    flex-shrink: 0;
    color: #6b7280;
}

.tool-favorite-btn__text {
    color: #374151;
    font-size: 0.875rem;
}

.tool-favorite-btn:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #2563eb;
}

.tool-favorite-btn--sidebar:hover .tool-favorite-btn__icon {
    background: #dbeafe;
    color: #2563eb;
}

.tool-favorite-btn--active {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #2563eb;
}

.tool-favorite-btn--sidebar.tool-favorite-btn--active {
    background: linear-gradient(to left, #eff6ff, #dbeafe);
}

.tool-favorite-btn--sidebar.tool-favorite-btn--active .tool-favorite-btn__icon {
    background: #bfdbfe;
    color: #2563eb;
}

.tool-favorite-btn--active .tool-favorite-btn__text {
    color: #2563eb;
}

.tool-favorite-btn--active i {
    animation: toolFavPop 0.3s ease;
}

@keyframes toolFavPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* Category sidebar — aligned with site card style */
.tool-categories-sidebar {
    position: sticky;
    top: calc(var(--site-header-height, 4.5rem) + 1rem);
    padding: 1.25rem;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    background: #fff;
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
}

.tool-categories-sidebar__head {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f1f5f9;
}

.tool-categories-sidebar__subtitle {
    margin: 0.25rem 0 0;
    color: #64748b;
    font-size: 0.75rem;
    line-height: 1.6;
}

.tool-categories-sidebar__title {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 700;
    color: #111827;
    line-height: 1.4;
}

.tool-categories-sidebar__head-text {
    min-width: 0;
}

.tool-categories-sidebar__head-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #2563eb;
    background: linear-gradient(145deg, #eff6ff, #dbeafe);
    font-size: 0.9375rem;
}

.tool-categories-sidebar__list {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.tool-categories-sidebar__item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.75rem;
    border-radius: 0.75rem;
    color: #374151;
    text-decoration: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    border: 1px solid transparent;
}

.tool-categories-sidebar__item:hover {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #2563eb;
}

.tool-categories-sidebar__item--active {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
    font-weight: 700;
}

.tool-categories-sidebar__item--active:hover {
    color: #1d4ed8;
    background: #eff6ff;
}

.tool-categories-sidebar__label {
    flex: 1;
    min-width: 0;
    font-size: 0.8125rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tool-categories-sidebar__icon {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    background: linear-gradient(145deg, #eff6ff, #dbeafe);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #2563eb;
    font-size: 0.8125rem;
}

.tool-categories-sidebar__item--active .tool-categories-sidebar__icon {
    background: linear-gradient(145deg, #dbeafe, #bfdbfe);
    color: #1d4ed8;
}

.tool-categories-sidebar__count {
    margin-inline-start: auto;
    flex-shrink: 0;
    font-size: 0.6875rem;
    font-weight: 700;
    color: #2563eb;
    background: #eff6ff;
    border: 1px solid #dbeafe;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    min-width: 1.5rem;
    text-align: center;
}

.tool-categories-sidebar__item--active .tool-categories-sidebar__count {
    background: #fff;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.tool-categories-sidebar__all-btn {
    margin-top: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.625rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.8125rem;
    font-weight: 700;
    text-decoration: none;
    color: #fff;
    background: linear-gradient(to left, #2563eb, #0ea5e9);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.22);
    transition: opacity 0.2s, transform 0.2s;
}

.tool-categories-sidebar__all-btn:hover {
    opacity: 0.95;
    transform: translateY(-1px);
    color: #fff;
}

/* Mobile category bar */
.tool-categories-mobile-bar {
    position: sticky;
    top: var(--site-header-height, 4.5rem);
    z-index: 40;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #e5e7eb;
    margin: 0 -1rem 0.5rem;
    padding: 0.75rem 1rem;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
}

@media (min-width: 1024px) {
    .tool-categories-mobile-bar {
        display: none;
    }
}

.tool-categories-mobile-bar__scroll {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
    scroll-snap-type: x proximity;
    mask-image: linear-gradient(to left, transparent, #000 12px, #000 calc(100% - 12px), transparent);
    -webkit-mask-image: linear-gradient(to left, transparent, #000 12px, #000 calc(100% - 12px), transparent);
}

.tool-categories-mobile-bar__scroll::-webkit-scrollbar {
    display: none;
}

.tool-categories-mobile-bar__chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    min-height: 2.75rem;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #374151;
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
    flex-shrink: 0;
    scroll-snap-align: start;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, color 0.15s;
}

.tool-categories-mobile-bar__chip:hover {
    border-color: #93c5fd;
    background: #eff6ff;
    color: #2563eb;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.12);
}

.tool-categories-mobile-bar__chip--active {
    border-color: transparent;
    background: linear-gradient(to left, #2563eb, #0ea5e9);
    color: #fff;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

.tool-categories-sidebar-wrap {
    display: none;
}

.tool-sidebar-actions,
.tool-sidebar-share {
    min-width: 0;
    max-width: 100%;
}

.tool-sidebar-share .tool-share--sidebar {
    margin-bottom: 0;
    border: none;
    background: transparent;
    box-shadow: none;
}

.tool-sidebar-share .tool-share--sidebar .tool-share-inner {
    padding: 0;
}

.tool-sidebar-share .tool-share--sidebar .tool-share-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.375rem;
}

.tool-sidebar-share .tool-share--sidebar .tool-share-item {
    padding: 0.375rem;
}

.tool-sidebar-share .tool-share--sidebar .tool-share-item__icon {
    width: 2.25rem;
    height: 2.25rem;
}

.tool-sidebar-share .tool-share-item__icon--telegram {
    background: #0088cc !important;
    border: 0 !important;
    box-shadow: none !important;
}

.tool-sidebar-share .tool-share-item__icon--telegram i {
    color: #fff !important;
}

.tool-sidebar-share .tool-share-item__icon--whatsapp {
    background: #25D366 !important;
    border: 0 !important;
    box-shadow: none !important;
}

.tool-sidebar-share .tool-share-item__icon--whatsapp i {
    color: #fff !important;
}

.tool-sidebar-share .tool-share-item__icon--rubika {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}

.footer-categories-list {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.footer-categories-list--scroll {
    max-height: 16rem;
    overflow-y: auto;
    padding-inline-start: 0.125rem;
    scrollbar-width: thin;
    scrollbar-color: #475569 transparent;
}

.footer-category-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.35rem 0;
    color: #cbd5e1;
    text-decoration: none;
    transition: color 0.2s, transform 0.2s;
}

.footer-category-link:hover {
    color: #fff;
    transform: translateX(-2px);
}

.footer-category-link__icon {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #93c5fd;
    background: rgba(59, 130, 246, 0.12);
    font-size: 0.75rem;
    transition: background 0.2s, color 0.2s;
}

.footer-category-link:hover .footer-category-link__icon {
    background: rgba(59, 130, 246, 0.22);
    color: #bfdbfe;
}

.footer-category-link span:last-child {
    font-size: 0.9375rem;
    line-height: 1.5;
}

.footer-categories-list::-webkit-scrollbar {
    width: 4px;
}

.footer-categories-list::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}

/* Mobile drawer widget triggers */
.site-header-mobile-drawer-widgets {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #f3f4f6;
    margin-top: 0.5rem;
}

.site-header-mobile-drawer-widgets .tool-user-drawer-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    min-height: 2.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    background: #fff;
    color: #374151;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    text-align: right;
}

.site-header-mobile-drawer-widgets .tool-user-drawer-btn:hover {
    background: #f8fafc;
    border-color: #bfdbfe;
}

@media (max-width: 480px) {
    .site-header-mobile-tool-actions {
        gap: 0.375rem;
    }

    .site-header-mobile-tool-actions .tool-user-trigger {
        width: 2.75rem;
        height: 2.75rem;
    }
}

@media (min-width: 1024px) {
    .tool-categories-sidebar-wrap {
        display: block;
    }
}

/* Tool rating modal — shared across all tool pages */
.rating-stars-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.35rem;
    margin: 0 auto 1rem;
    max-width: 320px;
}

.rating-star-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: transform 0.15s, background 0.15s;
}

.rating-star-btn .rating-star-icon {
    font-size: 2rem;
    line-height: 1;
    color: #d1d5db;
    transition: color 0.15s, transform 0.15s;
}

.rating-star-btn:hover,
.rating-star-btn:focus-visible {
    transform: scale(1.08);
    outline: none;
    background: rgba(251, 191, 36, 0.12);
}

.rating-star-btn.is-filled .rating-star-icon,
.rating-star-btn:hover .rating-star-icon {
    color: #fbbf24;
}

.rating-star-btn.is-selected {
    background: rgba(251, 191, 36, 0.18);
}

@media (max-width: 380px) {
    .rating-star-btn {
        width: 2.5rem;
        height: 2.5rem;
    }

    .rating-star-btn .rating-star-icon {
        font-size: 1.65rem;
    }
}
