/* =====================================================================
 *  CUSTOM APPLICATION CSS
 * =====================================================================
 *  Role      : Handles edge-cases that Tailwind utilities cannot address:
 *              custom scrollbars, code editor styling, selection colors,
 *              and focus states. Kept minimal for maximum performance.
 * ===================================================================== */

/* ─── GLOBAL SELECTION ─────────────────────────────────────────────── */
::selection {
    background-color: rgb(99 102 241 / 0.3);
    color: inherit;
}

.dark ::selection {
    background-color: rgb(99 102 241 / 0.4);
}

/* ─── CUSTOM SCROLLBARS (Code Editors & Textareas) ─────────────────── */
.tool-input,
.tool-output {
    scrollbar-width: thin;
    scrollbar-color: rgb(148 163 184 / 0.3) transparent;
}

.dark .tool-input,
.dark .tool-output {
    scrollbar-color: rgb(71 85 105 / 0.5) transparent;
}

.tool-input::-webkit-scrollbar,
.tool-output::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.tool-input::-webkit-scrollbar-track,
.tool-output::-webkit-scrollbar-track {
    background: transparent;
}

.tool-input::-webkit-scrollbar-thumb,
.tool-output::-webkit-scrollbar-thumb {
    background-color: rgb(148 163 184 / 0.3);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.dark .tool-input::-webkit-scrollbar-thumb,
.dark .tool-output::-webkit-scrollbar-thumb {
    background-color: rgb(71 85 105 / 0.5);
}

.tool-input::-webkit-scrollbar-thumb:hover,
.tool-output::-webkit-scrollbar-thumb:hover {
    background-color: rgb(148 163 184 / 0.5);
}

.dark .tool-input::-webkit-scrollbar-thumb:hover,
.dark .tool-output::-webkit-scrollbar-thumb:hover {
    background-color: rgb(71 85 105 / 0.7);
}

/* ─── CODE EDITOR FOCUS STATES ─────────────────────────────────────── */
.tool-input:focus,
.tool-output:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px rgb(99 102 241 / 0.5);
}

.dark .tool-input:focus,
.dark .tool-output:focus {
    box-shadow: inset 0 0 0 2px rgb(99 102 241 / 0.6);
}

/* ─── MONOSPACE FONT ENHANCEMENTS ──────────────────────────────────── */
.tool-input,
.tool-output {
    font-variant-ligatures: none;
    tab-size: 4;
    -moz-tab-size: 4;
    line-height: 1.6;
    letter-spacing: -0.01em;
}

/* ─── TOAST NOTIFICATIONS ──────────────────────────────────────────── */
.toast {
    pointer-events: auto;
    animation: toast-slide-in 0.2s ease-out;
}

.toast.toast-exit {
    animation: toast-slide-out 0.15s ease-in forwards;
}

@keyframes toast-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toast-slide-out {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ─── DETAILS/SUMMARY ACCORDION (FAQ) ──────────────────────────────── */
details summary::-webkit-details-marker {
    display: none;
}

details summary {
    list-style: none;
}

/* ─── KEYBOARD SHORTCUT HINTS ──────────────────────────────────────── */
kbd {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
    font-size: 0.75rem;
    line-height: 1;
}

/* ─── LOADING SKELETON ─────────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(
        90deg,
        rgb(226 232 240) 0%,
        rgb(241 245 249) 50%,
        rgb(226 232 240) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

.dark .skeleton {
    background: linear-gradient(
        90deg,
        rgb(30 41 59) 0%,
        rgb(51 65 85) 50%,
        rgb(30 41 59) 100%
    );
    background-size: 200% 100%;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ─── ACCESSIBILITY: REDUCED MOTION ────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ─── PRINT STYLES ─────────────────────────────────────────────────── */
@media print {
    header,
    footer,
    .tool-action-btn,
    #toast-container {
        display: none !important;
    }

    .tool-input,
    .tool-output {
        border: 1px solid #000 !important;
        page-break-inside: avoid;
    }
}