/* ======================================================
   Module Difabel / Accessibility Toolbar
====================================================== */

.difabel-toolbar {
    --difabel-maroon: #8f3118;
    --difabel-maroon-dark: #6f2412;
    --difabel-gold: #c89548;
    --difabel-gold-light: #f6e3be;
    --difabel-ink: #43352e;
    --difabel-body: #6f6258;
    position: fixed;
    right: 22px;
    bottom: 88px;
    z-index: 99999;
    font-family: inherit;
}

.difabel-icon,
.difabel-icon svg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.difabel-icon svg {
    width: 1em;
    height: 1em;
    stroke: currentColor;
    stroke-width: 1.9;
    fill: none;
}

/* Floating Button */
.difabel-toggle {
    width: 60px;
    height: 60px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 50%;
    background: linear-gradient(135deg, var(--difabel-maroon) 0%, var(--difabel-maroon-dark) 56%, var(--difabel-gold) 100%);
    color: #fff8ef;
    font-size: 26px;
    cursor: pointer;
    box-shadow:
        0 14px 28px rgba(62, 26, 15, 0.24),
        0 4px 12px rgba(200, 149, 72, 0.24);
    transition: all 0.25s ease;
}

.difabel-toggle:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow:
        0 18px 36px rgba(62, 26, 15, 0.28),
        0 6px 16px rgba(200, 149, 72, 0.30);
}

/* Panel */
.difabel-panel {
    position: fixed;
    right: 24px;
    top: 14px;
    width: 264px;
    max-height: calc(100vh - 28px);
    background:
        radial-gradient(circle at 100% 0%, rgba(243, 199, 86, 0.10) 0%, rgba(243, 199, 86, 0) 34%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.995) 0%, rgba(252, 247, 240, 0.99) 100%);
    border-radius: 22px;
    border: 1px solid rgba(15, 23, 42, 0.06);
    box-shadow:
        0 14px 36px rgba(15, 23, 42, 0.12),
        0 4px 10px rgba(15, 23, 42, 0.06);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px) scale(0.96);
    transition: all 0.25s ease;
}

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

/* Header */
.difabel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--difabel-maroon) 0%, var(--difabel-maroon-dark) 58%, var(--difabel-gold) 100%);
    color: #ffffff;
}

.difabel-header strong {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
}

.difabel-header strong .difabel-icon {
    font-size: 17px;
    color: #f6d79a;
}

.difabel-header button {
    border: none;
    background: rgba(255, 255, 255, 0.14);
    color: #fffdf8;
    cursor: pointer;
    font-size: 15px;
    opacity: 0.95;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.difabel-header button .difabel-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
}

.difabel-header button .difabel-icon svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2.2;
    fill: none;
}

.difabel-header button:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.22);
}

/* Actions */
.difabel-actions {
    padding: 12px;
    display: grid;
    gap: 8px;
    max-height: calc(100vh - 105px);
    overflow-y: auto;
}

.difabel-actions button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    border: 1px solid rgba(183, 133, 33, 0.12);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(251, 246, 239, 0.98) 100%);
    color: var(--difabel-ink);
    border-radius: 14px;
    padding: 10px 12px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.65),
        0 10px 20px rgba(93, 60, 36, 0.06);
    transition: all 0.2s ease;
}

.difabel-actions button .difabel-icon {
    width: 18px;
    text-align: center;
    color: var(--difabel-maroon);
    font-size: 14px;
    flex-shrink: 0;
}

.difabel-actions button:hover {
    background: linear-gradient(180deg, rgba(255, 247, 232, 0.98) 0%, rgba(252, 237, 213, 0.98) 100%);
    border-color: rgba(200, 149, 72, 0.30);
    transform: translateY(-1px);
}

/* Active State */
.difabel-actions button.is-active {
    background: linear-gradient(135deg, var(--difabel-maroon) 0%, var(--difabel-maroon-dark) 56%, var(--difabel-gold) 100%);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 10px 22px rgba(93, 41, 20, 0.22);
}

.difabel-actions button.is-active .difabel-icon {
    color: #ffffff;
}

/* Primary TTS Button */
.difabel-actions button[data-action="speak"] {
    background: linear-gradient(135deg, rgba(255, 248, 230, 0.98) 0%, rgba(254, 243, 199, 0.98) 100%);
    border-color: rgba(200, 149, 72, 0.28);
}

.difabel-actions button[data-action="speak"]:hover {
    background: linear-gradient(135deg, var(--difabel-maroon) 0%, var(--difabel-maroon-dark) 56%, var(--difabel-gold) 100%);
    color: #ffffff;
    border-color: transparent;
}

.difabel-actions button[data-action="speak"]:hover .difabel-icon {
    color: #ffffff;
}

/* TTS Active / Sedang Membaca */
.difabel-actions button[data-action="speak"].is-active {
    background: linear-gradient(135deg, var(--difabel-maroon) 0%, var(--difabel-maroon-dark) 56%, var(--difabel-gold) 100%) !important;
    color: #ffffff !important;
    border-color: transparent !important;
    box-shadow: 0 10px 22px rgba(93, 41, 20, 0.28);
}

.difabel-actions button[data-action="speak"].is-active .difabel-icon,
.difabel-actions button[data-action="speak"].is-active span {
    color: #ffffff !important;
}

.difabel-actions button[data-action="speak"].is-active:hover {
    background: linear-gradient(135deg, #7c2914 0%, #63200f 56%, #b88335 100%) !important;
    color: #ffffff !important;
}

/* Reset */
.difabel-actions .difabel-reset {
    background: #fafafa;
    color: #6b5f58;
    border-color: rgba(143, 49, 24, 0.12);
    box-shadow: none;
}

.difabel-actions .difabel-reset .difabel-icon {
    color: #8f3118;
}

.difabel-actions .difabel-reset:hover {
    background: #fff1e7;
    color: #8f3118;
    border-color: rgba(143, 49, 24, 0.18);
    box-shadow: none;
}

/* Supaya toolbar tidak ikut membesar */
html.difabel-font-1 .difabel-toolbar,
html.difabel-font-2 .difabel-toolbar,
html.difabel-font-3 .difabel-toolbar {
    transform: none !important;
}

/* Contrast */
body.difabel-contrast {
    background: #000000 !important;
    color: #ffffff !important;
}

body.difabel-contrast * {
    background-color: #000000 !important;
    color: #ffffff !important;
    border-color: #ffffff !important;
}

body.difabel-contrast a,
body.difabel-contrast button {
    color: #ffff00 !important;
}

/* Highlight Links */
body.difabel-highlight-links a {
    background: #ffff00 !important;
    color: #000000 !important;
    text-decoration: underline !important;
    padding: 2px 4px;
    border-radius: 4px;
}

/* Readable Text */
body.difabel-readable-text {
    line-height: 1.95 !important;
    letter-spacing: 0.8px !important;
    word-spacing: 2px !important;
}

body.difabel-readable-text p,
body.difabel-readable-text li,
body.difabel-readable-text span,
body.difabel-readable-text a {
    line-height: 1.95 !important;
}

/* Pause Animation */
body.difabel-pause-animation *,
body.difabel-pause-animation *::before,
body.difabel-pause-animation *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}

/* Speaking Animation */
.difabel-speaking .difabel-icon {
    animation: difabelPulse 1s infinite;
}

@keyframes difabelPulse {
    0% {
        transform: scale(1);
        opacity: 0.75;
    }

    50% {
        transform: scale(1.18);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 0.75;
    }
}

/* Scrollbar */
.difabel-actions::-webkit-scrollbar {
    width: 6px;
}

.difabel-actions::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.15);
    border-radius: 20px;
}

/* Mobile */
@media (max-width: 480px) {
    .difabel-toolbar {
        right: 8px;
        bottom: 74px;
    }

    .difabel-toggle {
        width: 52px;
        height: 52px;
        font-size: 22px;
    }

    .difabel-panel {
        right: 8px;
        top: 10px;
        width: 270px;
        max-width: calc(100vw - 16px);
        max-height: calc(100vh - 20px);
    }

    .difabel-actions {
        max-height: calc(100vh - 105px);
    }

    .difabel-actions button {
        padding: 10px 12px;
        font-size: 13px;
    }
}
