/* Floating Tools Base Styles */
.andw-floating-tools {
    position: fixed;
    z-index: 999;
    display: flex;
    pointer-events: none;
}

.andw-floating-tools * {
    box-sizing: border-box;
}

/* Button Base Styles */
.andw-floating-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    min-height: 64px;
    border: none;
    border-radius: 12px;
    background: #2563eb;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    pointer-events: auto;
    font-size: 0;
    padding: 8px;
}

.andw-floating-button:hover {
    background: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.andw-floating-button:focus {
    outline: 2px solid #93c5fd;
    outline-offset: 2px;
}

.andw-floating-button:active {
    transform: translateY(0);
}

.andw-floating-button svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.andw-floating-button .andw-button-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    margin-top: 4px;
    line-height: 1.2;
    text-align: center;
}

/* Button Visibility */
.andw-scroll-trigger {
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
}

.andw-scroll-trigger.andw-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Layout: Desktop Stack Vertical Right Center */
@media (min-width: 1024px) {
    .andw-layout-stack-vertical-right-center {
        flex-direction: column;
        bottom: 0;
        transform: none;
        gap: 12px;
    }
}

/* Layout: Bottom Right Inline */
.andw-layout-bottom-right-inline {
    flex-direction: row;
    gap: 12px;
}

/* Mobile and Tablet always use bottom-right-inline */
@media (max-width: 1023px) {
    .andw-floating-tools {
        flex-direction: row;
        gap: 12px;
    }
}

/* Button Type Specific Styles */
.andw-button-contact {
    background: #1b5f4a;
}

.andw-button-contact:hover {
    background: #298065;
}

.andw-button-apply {
    background: #7d1a1a;
}

.andw-button-apply:hover {
    background: #9a2525;
}

.andw-button-toc {
    background: #21204b;
}

.andw-button-toc:hover {
    background: #302f6c;
}

.andw-button-top {
    background: #374151;
}

.andw-button-top:hover {
    background: #1f2937;
}

/* TOC Drawer */
.andw-toc-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 9999;
    display: flex;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.andw-toc-drawer[aria-hidden="false"] {
    visibility: visible;
    opacity: 1;
}

.andw-toc-backdrop {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.andw-toc-content {
    position: relative;
    margin-left: auto;
    width: 100%;
    max-width: 400px;
    background: white;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.2s ease;
}

.andw-toc-drawer.andw-toc-open .andw-toc-content {
    transform: translateX(0);
}

.andw-toc-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}

.andw-toc-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s ease;
}

.andw-toc-close:hover {
    background: #e5e7eb;
    color: #374151;
}

.andw-toc-close:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.andw-toc-close svg {
    width: 20px;
    height: 20px;
}

.andw-toc-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.andw-toc-nav {
    height: 100%;
}

.andw-toc-title {
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.andw-toc-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.andw-toc-list.andw-toc-nested {
    margin-left: 16px;
    margin-top: 8px;
}

.andw-toc-item {
    margin-bottom: 8px;
}

.andw-toc-item:last-child {
    margin-bottom: 0;
}

.andw-toc-link {
    display: block;
    padding: 8px 12px;
    color: #374151;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.4;
    transition: all 0.15s ease;
}

.andw-toc-link:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.andw-toc-link:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    background: #eff6ff;
}

.andw-toc-level-2 .andw-toc-link {
    font-weight: 500;
}

.andw-toc-level-3 .andw-toc-link {
    font-size: 13px;
    color: #6b7280;
}

.andw-toc-level-4 .andw-toc-link {
    font-size: 13px;
    color: #9ca3af;
}

/* Body scroll lock when drawer is open */
.andw-toc-drawer-open {
    overflow: hidden;
}

/* Anchor Sheet Styles */
.andw-toc-anchor-sheet {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 9999;
    pointer-events: none;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.andw-toc-anchor-sheet[aria-hidden="false"] {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.andw-toc-anchor-sheet .andw-toc-backdrop {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.3);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.andw-toc-anchor-sheet.andw-toc-open .andw-toc-backdrop {
    opacity: 1;
}

.andw-toc-sheet-content {
    position: fixed;
    background: white;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    max-width: var(--andw-sheet-max-width, 480px);
    max-height: var(--andw-max-height-vh, 33vh);
    min-height: 120px;
    width: calc(100vw - var(--andw-gap-left, 16px) - var(--andw-gap-right, 12px));
    overflow: hidden;
}

.andw-toc-anchor-sheet.andw-toc-open .andw-toc-sheet-content {
    transform: translateY(0);
}


.andw-toc-sheet-content .andw-toc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 12px 12px 0 0;
    flex-shrink: 0;
}

.andw-toc-sheet-content .andw-toc-handle {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
}

.andw-toc-sheet-content .andw-toc-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    flex: 1;
}

.andw-toc-sheet-content .andw-toc-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s ease;
}

.andw-toc-sheet-content .andw-toc-close:hover {
    background: #e5e7eb;
    color: #374151;
}

.andw-toc-sheet-content .andw-toc-close:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.andw-toc-sheet-content .andw-toc-close svg {
    width: 18px;
    height: 18px;
}

.andw-toc-sheet-content .andw-toc-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.andw-toc-sheet-content .andw-toc-nav {
    height: 100%;
}

/* Body scroll lock when sheet is open */
.andw-toc-sheet-open {
    overflow: hidden;
}

/* Responsive adjustments */
@media (max-width: 767px) {
    .andw-floating-button {
        min-width: 56px;
        min-height: 56px;
        padding: 6px;
    }

    .andw-floating-button svg {
        width: 18px;
        height: 18px;
    }

    .andw-floating-button .andw-button-label {
        font-size: 10px;
        margin-top: 2px;
    }

    .andw-floating-tools {
        gap: 8px;
    }

    .andw-toc-content {
        max-width: 320px;
    }

    .andw-toc-body {
        padding: 16px;
    }
}

/* Preset Styles */

/* Light Preset */
.andw-preset-light .andw-floating-button {
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
}

.andw-preset-light .andw-floating-button:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.andw-preset-light .andw-button-apply {
    background: white;
    color: #059669;
    border-color: #059669;
}

.andw-preset-light .andw-button-apply:hover {
    background: #ecfdf5;
}

.andw-preset-light .andw-button-contact {
    background: white;
    color: #dc2626;
    border-color: #dc2626;
}

.andw-preset-light .andw-button-contact:hover {
    background: #fef2f2;
}

.andw-preset-light .andw-button-toc {
    background: white;
    color: #7c3aed;
    border-color: #7c3aed;
}

.andw-preset-light .andw-button-toc:hover {
    background: #faf5ff;
}

/* Dark Preset */
.andw-preset-dark .andw-floating-button {
    background: #111827;
    color: white;
    border: 1px solid #374151;
}

.andw-preset-dark .andw-floating-button:hover {
    background: #1f2937;
    border-color: #4b5563;
}

/* Square Presets */
.andw-preset-square-small .andw-floating-button,
.andw-preset-square-medium .andw-floating-button,
.andw-preset-square-large .andw-floating-button {
    border-radius: 8px;
}

.andw-preset-square-small .andw-floating-button {
    width: 44px;
    height: 44px;
}

.andw-preset-square-medium .andw-floating-button {
    width: 56px;
    height: 56px;
}

.andw-preset-square-large .andw-floating-button {
    width: 64px;
    height: 64px;
}

/* Round Size Presets */
.andw-preset-round-small .andw-floating-button {
    width: 44px;
    height: 44px;
}

.andw-preset-round-medium .andw-floating-button {
    width: 56px;
    height: 56px;
}

.andw-preset-round-large .andw-floating-button {
    width: 64px;
    height: 64px;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .andw-floating-button,
    .andw-toc-drawer,
    .andw-toc-content,
    .andw-toc-anchor-sheet,
    .andw-toc-sheet-content,
    .andw-scroll-trigger {
        transition: none;
    }

    .andw-floating-button:hover {
        transform: none;
    }

    .andw-floating-button:active {
        transform: none;
    }

    .andw-scroll-trigger {
        transform: none;
    }

    .andw-scroll-trigger.andw-visible {
        transform: none;
    }
}

/* High Contrast Support */
@media (prefers-contrast: high) {
    .andw-floating-button {
        border: 2px solid;
    }

    .andw-toc-drawer {
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }

    .andw-toc-backdrop {
        background: rgba(0, 0, 0, 0.8);
    }
}

/* Print Styles */
@media print {
    .andw-floating-tools,
    .andw-toc-drawer,
    .andw-toc-anchor-sheet {
        display: none !important;
    }
}