/* ==========================================================================
   My Floating Sidebar - Frontend Styles (Pure Vanilla CSS)
   Замена Tailwind CSS и AOS со 100% сохранением дизайна и анимаций
   ========================================================================== */

/* Базовый сброс и изоляция для виджетов */
#sidebar-widget-container,
.mfsw-fab-global-wrapper {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    -webkit-font-smoothing: antialiased;
}

#sidebar-widget-container *,
#sidebar-widget-container *::before,
#sidebar-widget-container *::after,
.mfsw-fab-global-wrapper *,
.mfsw-fab-global-wrapper *::before,
.mfsw-fab-global-wrapper *::after {
    box-sizing: border-box;
}

/* Общие утилиты состояний */
.mfsw-no-link {
    cursor: default !important;
    pointer-events: none !important;
}

#sidebar-widget-container .hidden,
.mfsw-fab-global-wrapper .hidden {
    display: none !important;
}

/* ==========================================================================
   1. БОКОВОЕ МЕНЮ (SIDEBAR WIDGET)
   ========================================================================== */

#sidebar-trigger-container {
    position: fixed;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    z-index: 999999998 !important;
    pointer-events: none !important;
}

#open-sidebar-button {
    background-color: #0284c7; /* sky-600 */
    color: #ffffff;
    width: 3rem; /* 48px */
    height: 6rem; /* 96px */
    border-top-right-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    padding: 0;
    margin: 0;
    pointer-events: auto !important;
    transition: transform 150ms cubic-bezier(0.4, 0, 0.2, 1), background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

#open-sidebar-button:hover {
    transform: scale(1.05);
    background-color: #0369a1; /* sky-700 */
}

#open-sidebar-button:focus {
    outline: none;
    box-shadow: 0 0 0 4px #7dd3fc; /* ring-sky-300 */
}

#open-sidebar-button svg {
    width: 1.5rem;
    height: 1.5rem;
}

#sidebar-tooltip,
#widget-tooltip {
    background-color: rgba(15, 23, 42, 0.8); /* slate-900/80 */
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    color: #ffffff;
    font-size: 0.875rem;
    line-height: 1.25rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    pointer-events: none !important;
    transition: opacity 300ms ease-in-out, visibility 300ms ease-in-out;
}

#sidebar-tooltip {
    margin-left: 0.75rem;
}

#sidebar-tooltip.opacity-0,
#widget-tooltip.opacity-0 {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

#sidebar-tooltip.pointer-events-none,
#widget-tooltip.pointer-events-none {
    pointer-events: none !important;
}

#sidebar-backdrop {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background-color: rgba(0, 0, 0, 0.5); /* black/50 */
    transition: opacity 300ms ease-in-out;
    z-index: 999999998 !important;
}

#sidebar-backdrop.opacity-0 {
    opacity: 0;
    pointer-events: none !important;
}

#sidebar-panel {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 20rem; /* 320px */
    background-color: #ffffff;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    transition: transform 300ms ease-in-out;
    z-index: 999999999 !important;
    transform: translateX(0);
}

#sidebar-panel.-translate-x-full {
    transform: translateX(-100%);
}

#sidebar-panel .border-b {
    border-bottom: 1px solid #e2e8f0; /* slate-200 */
}

#sidebar-panel h2 {
    font-size: 1.25rem;
    line-height: 1.75rem;
    font-weight: 700;
    color: #1e293b; /* slate-800 */
    margin: 0;
}

#close-sidebar-button {
    padding: 0.5rem;
    border-radius: 9999px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 150ms ease;
}

#close-sidebar-button:hover {
    background-color: #f1f5f9; /* slate-100 */
}

#close-sidebar-button svg {
    width: 1.5rem;
    height: 1.5rem;
    color: #475569; /* slate-600 */
}

/* Навигационный список бокового меню */
#sidebar-panel ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

#sidebar-panel > ul {
    margin-top: 1.5rem;
    flex-grow: 1;
    overflow-y: auto;
}

#sidebar-panel > ul > li + li {
    margin-top: 0.5rem;
}

#sidebar-panel summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 600;
    color: #334155; /* slate-700 */
    list-style: none;
    transition: background-color 150ms ease;
}

#sidebar-panel summary::-webkit-details-marker {
    display: none;
}

#sidebar-panel summary:hover {
    background-color: #f1f5f9; /* slate-100 */
}

#sidebar-panel summary svg {
    width: 1.25rem;
    height: 1.25rem;
    transition: transform 300ms ease;
}

#sidebar-panel details[open] > summary svg {
    transform: rotate(90deg);
}

#sidebar-panel details ul {
    padding-left: 1.5rem;
    margin-top: 0.5rem;
    border-left: 2px solid #e2e8f0; /* slate-200 */
}

#sidebar-panel details ul > li + li {
    margin-top: 0.25rem;
}

#sidebar-panel a,
#sidebar-panel .mfsw-no-link {
    text-decoration: none;
}

#sidebar-panel details a,
#sidebar-panel details .mfsw-no-link {
    display: block;
    padding: 0.5rem;
    border-radius: 0.375rem;
    color: #475569; /* slate-600 */
    transition: background-color 150ms, color 150ms;
}

#sidebar-panel details a:hover {
    background-color: #f0f9ff; /* sky-50 */
    color: #0369a1; /* sky-700 */
}

#sidebar-panel > ul > li > a,
#sidebar-panel > ul > li > .mfsw-no-link {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-weight: 600;
    color: #334155; /* slate-700 */
    transition: background-color 150ms;
}

#sidebar-panel > ul > li > a:hover {
    background-color: #f1f5f9; /* slate-100 */
}

/* ==========================================================================
   2. ПЛАВАЮЩАЯ КНОПКА (FAB WIDGET)
   ========================================================================== */

.mfsw-fab-global-wrapper {
    position: fixed;
    bottom: 1.5rem;
    right: 0;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    pointer-events: none;
    z-index: 999999999 !important;
}

/* Ярлычок восстановления */
#restore-fab {
    position: absolute;
    bottom: 0.5rem;
    right: 0;
    transform: translateX(100%);
    width: 2.5rem; /* 40px */
    height: 3.5rem; /* 56px */
    background-color: rgba(2, 132, 199, 0.9); /* sky-600/90 */
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    color: #ffffff;
    border-top-left-radius: 0.75rem;
    border-bottom-left-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 0 0 0.5rem;
    border: none;
    cursor: pointer;
    pointer-events: auto;
    transition: all 500ms ease-in-out;
}

#restore-fab:hover {
    background-color: #0369a1; /* sky-700 */
    width: 3rem; /* 48px */
}

#restore-fab.translate-x-0 {
    transform: translateX(0);
}

#restore-fab.translate-x-full {
    transform: translateX(100%);
}

#restore-fab svg {
    width: 1.5rem;
    height: 1.5rem;
}

/* Контейнер виджета */
#floating-widget-container {
    position: relative;
    padding-right: 1.5rem;
    display: flex;
    align-items: center;
    transition: all 500ms ease-in-out;
    transform: translateX(0);
    opacity: 1;
    pointer-events: none !important;
}

#floating-widget-container.translate-x-0 {
    transform: translateX(0);
}

#floating-widget-container.opacity-100 {
    opacity: 1;
}

#floating-widget-container[class*="translate-x-[150%]"],
#floating-widget-container.translate-x-150 {
    transform: translateX(150%);
}

#floating-widget-container.opacity-0 {
    opacity: 0;
}

#widget-fab-container {
    position: relative;
    margin-left: 0.75rem;
    pointer-events: auto !important;
}

/* Кнопка сворачивания */
#minimize-fab {
    position: absolute;
    top: -0.5rem;
    right: -0.5rem;
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    padding: 0 !important;
    margin: 0 !important;
    background-color: #ffffff;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    transition: background-color 150ms ease;
    z-index: 20;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    outline: none;
}

#minimize-fab:hover {
    background-color: #f1f5f9; /* slate-100 */
}

/* Основная круглая кнопка FAB */
#widget-fab {
    width: 4rem; /* 64px */
    height: 4rem;
    background-color: #0284c7; /* sky-600 */
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    border: none;
    cursor: pointer;
    padding: 0;
    margin: 0;
    transition: all 300ms ease-in-out;
}

#widget-fab:hover {
    background-color: #0369a1; /* sky-700 */
    transform: scale(1.1);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

#widget-fab:focus {
    outline: none;
    box-shadow: 0 0 0 4px #7dd3fc; /* ring-sky-300 */
}

#widget-icon-open,
#widget-icon-close {
    width: 2rem;
    height: 2rem;
    color: #ffffff;
    stroke: #ffffff;
    transition: opacity 300ms ease;
}

#widget-icon-close {
    position: absolute;
}

#widget-icon-open.opacity-0,
#widget-icon-close.opacity-0 {
    opacity: 0;
}

/* Всплывающее меню калькуляторов */
#widget-menu {
    position: absolute;
    bottom: calc(100% + 0.75rem);
    right: 1.5rem;
    width: 20rem; /* 320px */
    background-color: rgba(255, 255, 255, 0.8);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid #e2e8f0;
    padding: 1rem;
    transform-origin: bottom right;
    transition: all 300ms cubic-bezier(0, 0, 0.2, 1);
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto !important;
}

#widget-menu.opacity-0 {
    opacity: 0;
}

#widget-menu.scale-95 {
    transform: scale(0.95);
}

#widget-menu.-translate-y-2 {
    transform: translateY(-0.5rem);
}

#widget-menu.scale-95.-translate-y-2 {
    transform: scale(0.95) translateY(-0.5rem);
}

#widget-menu p {
    padding: 0 0.5rem 0.5rem 0.5rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    font-weight: 600;
    color: #475569; /* slate-600 */
    margin: 0;
}

#widget-menu .grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    max-height: 15rem; /* 240px */
    overflow-y: auto;
    padding-right: 0.5rem;
}

#widget-menu a {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem;
    border-radius: 0.75rem;
    text-decoration: none;
    transition: background-color 150ms ease;
}

#widget-menu a:hover {
    background-color: #e0f2fe; /* sky-100 */
}

#widget-menu img {
    width: 4rem;
    height: 4rem;
    object-fit: contain;
}

#widget-menu span {
    margin-top: 0.5rem;
    font-weight: 600;
    color: #334155; /* slate-700 */
    font-size: 0.75rem;
    line-height: 1rem;
    text-align: center;
}
