/**
 * Tools Ecosystem CSS
 * Minimal additions for tool-specific styling
 */

/* Tool-specific animations */
@keyframes slideInFromTop {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.animate-in {
    animation: slideInFromTop 0.3s ease-out;
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Toast notification styles */
.tool-toast {
    z-index: 9999;
    animation: slideInFromTop 0.3s ease-out;
}

/* Tool input focus states */
input:focus, select:focus, textarea:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.2);
}

/* Tool button hover effects */
.tool-btn-primary {
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.tool-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(168, 85, 247, 0.3);
}

/* Result display styles */
.result-display {
    font-variant-numeric: tabular-nums;
}

/* Copy button animation */
.copy-btn:active {
    transform: scale(0.95);
}

/* Retention badge styles */
.retention-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
}

/* Streak flame animation */
@keyframes flamePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.streak-flame {
    animation: flamePulse 1s ease-in-out infinite;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .tool-grid {
        grid-template-columns: 1fr;
    }
    
    .tool-input-group {
        flex-direction: column;
    }
}

/* Loading spinner */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner {
    animation: spin 1s linear infinite;
}

/* Tool card hover effects */
.tool-card {
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.tool-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

/* Input validation styles */
.input-error {
    border-color: #ef4444 !important;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Success state */
.input-success {
    border-color: #22c55e !important;
}

/* Character counter */
.char-counter {
    font-variant-numeric: tabular-nums;
}

.char-counter.warning {
    color: #f59e0b;
}

.char-counter.error {
    color: #ef4444;
}

/* Tool-specific color themes */
.tool-theme-purple {
    --tool-primary: #A855F7;
    --tool-secondary: rgba(168, 85, 247, 0.1);
}

.tool-theme-blue {
    --tool-primary: #00F3FF;
    --tool-secondary: rgba(0, 243, 255, 0.1);
}

.tool-theme-green {
    --tool-primary: #22C55E;
    --tool-secondary: rgba(34, 197, 94, 0.1);
}

.tool-theme-pink {
    --tool-primary: #EC4899;
    --tool-secondary: rgba(236, 72, 153, 0.1);
}

/* Tool readability pass */
main input,
main select,
main textarea {
    background-color: rgba(2, 6, 23, 0.82) !important;
    border-color: rgba(148, 163, 184, 0.28) !important;
    color: #f8fafc !important;
}

main input::placeholder,
main textarea::placeholder {
    color: #94a3b8 !important;
    opacity: 1;
}

main label,
main .text-slate-400 {
    color: #cbd5e1 !important;
}

main .text-slate-500,
main .text-slate-600 {
    color: #94a3b8 !important;
}

main:not(.accounting-engine-shell) .bg-neon-purple.text-black,
main:not(.accounting-engine-shell) .bg-neon-pink.text-black,
main:not(.accounting-engine-shell) button.bg-neon-purple.text-black,
main:not(.accounting-engine-shell) button.bg-neon-pink.text-black,
main:not(.accounting-engine-shell) a.bg-neon-purple.text-black,
main:not(.accounting-engine-shell) a.bg-neon-pink.text-black {
    color: #ffffff !important;
    text-shadow: 0 1px 10px rgba(0, 0, 0, 0.38);
}

main .hover\:bg-white:hover {
    color: #050505 !important;
    text-shadow: none !important;
}

main button,
main a {
    text-underline-offset: 3px;
}

main button:focus-visible,
main a:focus-visible,
main input:focus-visible,
main select:focus-visible,
main textarea:focus-visible {
    outline: 2px solid #00f3ff !important;
    outline-offset: 3px;
}

main .bg-cyber-gray\/30,
main .bg-white\/5 {
    border-color: rgba(255, 255, 255, 0.1) !important;
}

section#tools .group p,
section#tools .group a {
    color: #cbd5e1;
}

section#tools .group a[class*="text-neon"] {
    font-weight: 800;
}

/* Premium tools hub controls */
section#tools .tools-command-panel {
    position: relative;
    isolation: isolate;
    padding: 1.15rem;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 1.35rem;
    background:
        linear-gradient(135deg, rgba(8, 13, 27, 0.92), rgba(3, 9, 22, 0.76)),
        radial-gradient(circle at top left, rgba(0, 243, 255, 0.14), transparent 42%),
        radial-gradient(circle at 85% 10%, rgba(168, 85, 247, 0.18), transparent 38%);
    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.46),
        0 0 0 1px rgba(255, 255, 255, 0.035) inset,
        0 1px 0 rgba(255, 255, 255, 0.13) inset;
    overflow: hidden;
}

section#tools .tools-command-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(115deg, rgba(0, 243, 255, 0.52), rgba(168, 85, 247, 0.42), rgba(236, 72, 153, 0.28), rgba(255, 255, 255, 0.08));
    -webkit-mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0.7;
}

section#tools .tools-command-panel::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 18px);
    opacity: 0.28;
    pointer-events: none;
}

section#tools .tools-search-wrap,
section#tools .tools-filter-dock {
    position: relative;
    z-index: 1;
}

section#tools .tools-search-wrap {
    filter: drop-shadow(0 16px 30px rgba(0, 0, 0, 0.28));
    width: 100%;
}

section#tools .tools-search-wrap input#tool-search {
    display: block;
    width: 100%;
    height: 3.5rem;
    min-height: 3.35rem;
    box-sizing: border-box;
    padding: 0 3.25rem !important;
    line-height: 1.2 !important;
    vertical-align: middle;
    border-color: rgba(0, 243, 255, 0.18) !important;
    background:
        linear-gradient(180deg, rgba(15, 23, 42, 0.88), rgba(2, 6, 23, 0.92)) !important;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.04) inset,
        0 16px 38px rgba(0, 0, 0, 0.3) inset,
        0 0 34px rgba(0, 243, 255, 0.07);
}

section#tools .tools-search-wrap input#tool-search:focus {
    border-color: rgba(0, 243, 255, 0.52) !important;
    box-shadow:
        0 0 0 1px rgba(0, 243, 255, 0.22) inset,
        0 0 0 4px rgba(0, 243, 255, 0.08),
        0 18px 46px rgba(0, 0, 0, 0.34) inset,
        0 0 38px rgba(168, 85, 247, 0.14);
}

section#tools .tools-search-icon {
    top: 50% !important;
    bottom: auto !important;
    left: 1rem !important;
    width: 1.25rem;
    height: 1.25rem;
    padding-left: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-50%);
}

section#tools .tools-search-icon svg {
    display: block;
    width: 1.25rem;
    height: 1.25rem;
}

section#tools .tools-clear-button {
    top: 50% !important;
    bottom: auto !important;
    right: 0.75rem !important;
    width: 2rem;
    height: 2rem;
    padding: 0 !important;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    transform: translateY(-50%);
}

section#tools .tools-clear-button.hidden {
    display: none !important;
}

section#tools .tools-clear-button:not(.hidden) {
    display: flex !important;
}

section#tools .tools-filter-dock {
    margin-inline: auto;
    width: fit-content;
    max-width: 100%;
    column-gap: 0.72rem !important;
    row-gap: 0.65rem !important;
    padding: 0.45rem;
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 1.1rem;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.025)),
        rgba(2, 6, 23, 0.52);
    box-shadow:
        0 18px 46px rgba(0, 0, 0, 0.32),
        0 1px 0 rgba(255, 255, 255, 0.1) inset;
    backdrop-filter: blur(18px);
}

section#tools .tools-filter-dock .filter-btn {
    position: relative;
    min-height: 2.35rem;
    border-color: rgba(255, 255, 255, 0.1) !important;
    border-radius: 0.85rem;
    color: #cbd5e1 !important;
    background: rgba(15, 23, 42, 0.2) !important;
    text-shadow: 0 1px 14px rgba(0, 0, 0, 0.55);
    box-shadow: none !important;
}

section#tools .tools-filter-dock .filter-btn:hover {
    color: #ffffff !important;
    border-color: rgba(0, 243, 255, 0.3) !important;
    background: rgba(15, 23, 42, 0.66) !important;
    box-shadow:
        0 12px 28px rgba(0, 0, 0, 0.26),
        0 0 22px rgba(0, 243, 255, 0.12) !important;
}

section#tools .tools-filter-dock .filter-btn.active {
    color: #ffffff !important;
    border-color: rgba(0, 243, 255, 0.42) !important;
    background:
        linear-gradient(135deg, rgba(0, 243, 255, 0.2), rgba(168, 85, 247, 0.3)) !important;
    box-shadow:
        0 14px 38px rgba(0, 0, 0, 0.32),
        0 0 28px rgba(0, 243, 255, 0.18),
        0 0 0 1px rgba(255, 255, 255, 0.12) inset !important;
}

@media (max-width: 640px) {
    section#tools .tools-command-panel {
        padding: 0.85rem;
        border-radius: 1.1rem;
    }

    section#tools .tools-filter-dock {
        width: 100%;
        column-gap: 0.55rem !important;
        row-gap: 0.55rem !important;
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
    }

    section#tools .tools-filter-dock::-webkit-scrollbar {
        display: none;
    }

    section#tools .tools-filter-dock .filter-btn {
        flex: 0 0 auto;
        padding-inline: 1rem;
    }
}

/* Mobile-first polish for the tools hub */
section#tools {
    overflow-x: clip;
}

section#tools #tools-grid {
    align-items: stretch;
}

section#tools #tools-grid .tool-card {
    min-height: 16rem;
}

@media (max-width: 767px) {
    section#tools {
        padding-top: 1rem !important;
        padding-bottom: 6rem !important;
    }

    section#tools > .container {
        width: 100%;
        max-width: 100%;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    section#tools .text-center {
        margin-bottom: 0.9rem !important;
    }

    section#tools h1 {
        font-size: clamp(1.65rem, 8vw, 2.15rem) !important;
        line-height: 1 !important;
        margin-bottom: 0.2rem !important;
    }

    section#tools .text-center p {
        margin-bottom: 0 !important;
        font-size: 0.65rem !important;
    }

    section#tools .tools-command-panel {
        width: 100%;
        max-width: none !important;
        margin-bottom: 1.2rem !important;
        padding: 0.9rem !important;
        border-radius: 1.15rem !important;
        row-gap: 0.8rem !important;
        box-shadow:
            0 18px 54px rgba(0, 0, 0, 0.42),
            0 0 0 1px rgba(255, 255, 255, 0.045) inset;
    }

    section#tools .tools-command-panel::after {
        opacity: 0.18;
    }

    section#tools .tools-search-wrap {
        max-width: none !important;
        filter: none;
    }

    section#tools .tools-search-wrap input#tool-search {
        height: 3.15rem;
        min-height: 3.15rem;
        padding-left: 2.85rem !important;
        padding-right: 2.85rem !important;
        border-radius: 0.95rem !important;
        font-size: 16px !important;
        line-height: 1.2 !important;
        text-overflow: ellipsis;
    }

    section#tools .tools-search-icon {
        left: 0.95rem !important;
    }

    section#tools .tools-clear-button {
        right: 0.6rem !important;
    }

    section#tools .tools-filter-dock {
        width: calc(100% + 0.4rem);
        max-width: calc(100% + 0.4rem);
        margin-left: -0.2rem;
        margin-right: -0.2rem;
        padding: 0.45rem 0.45rem 0.55rem;
        gap: 0.5rem !important;
        border-radius: 0.95rem;
        overflow-x: auto;
        overflow-y: hidden;
        flex-wrap: nowrap !important;
        justify-content: flex-start !important;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
        mask-image: linear-gradient(90deg, transparent, #000 7%, #000 92%, transparent);
    }

    section#tools .tools-filter-dock .filter-btn {
        flex: 0 0 auto;
        min-height: 2.45rem;
        padding: 0.68rem 0.9rem !important;
        border-radius: 0.8rem !important;
        font-size: 0.68rem !important;
        line-height: 1 !important;
        white-space: nowrap;
        scroll-snap-align: start;
        transform: none !important;
    }

    section#tools #tools-grid {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 0.95rem !important;
    }

    section#tools #tools-grid .tool-card {
        min-height: 11.75rem;
        border-radius: 1rem !important;
        padding: 1rem !important;
        transform: none !important;
    }

    section#tools #tools-grid .tool-card .mb-5 {
        margin-bottom: 0.85rem !important;
    }

    section#tools #tools-grid .tool-card [class*="p-3"] {
        padding: 0.72rem !important;
        border-radius: 0.8rem !important;
    }

    section#tools #tools-grid .tool-card svg {
        width: 1.25rem;
        height: 1.25rem;
    }

    section#tools #tools-grid .tool-card h3 {
        font-size: 1rem !important;
        line-height: 1.25 !important;
        margin-bottom: 0.4rem !important;
    }

    section#tools #tools-grid .tool-card p {
        font-size: 0.84rem !important;
        line-height: 1.45 !important;
        margin-bottom: 1rem !important;
    }

    section#tools #tools-grid .tool-card a {
        min-height: 2rem;
        align-items: center;
        letter-spacing: 0.06em !important;
    }

    section#tools #no-results {
        padding: 2.25rem 1rem !important;
        border-radius: 1rem !important;
    }

    a.fixed.bottom-6.left-6[href*="wa.me"] {
        left: 1rem !important;
        bottom: 1rem !important;
        padding: 0.75rem !important;
    }

    a.fixed.bottom-6.left-6[href*="wa.me"] svg {
        width: 1.45rem !important;
        height: 1.45rem !important;
    }
}

@media (max-width: 380px) {
    section#tools > .container {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    section#tools .tools-command-panel {
        padding: 0.72rem !important;
    }

    section#tools .tools-filter-dock .filter-btn {
        padding-inline: 0.75rem !important;
    }

    section#tools #tools-grid .tool-card {
        min-height: 11rem;
    }
}

/* Shared shell for newer utility tools */
.quick-tool-shell {
    overflow-x: clip;
}

.is-inner-page main.quick-tool-shell > .container:first-child,
main.quick-tool-shell > .container:first-child {
    padding-top: 0 !important;
}

.quick-tool-hero {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.quick-tool-icon {
    flex: 0 0 auto;
    padding: 0.95rem;
    border: 1px solid rgba(34, 211, 238, 0.22);
    border-radius: 1rem;
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.14), rgba(168, 85, 247, 0.1));
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.26);
}

.quick-tool-panel {
    position: relative;
    padding: 1.25rem;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 1.25rem;
    background:
        linear-gradient(135deg, rgba(8, 13, 27, 0.92), rgba(2, 6, 23, 0.84)),
        radial-gradient(circle at top left, rgba(34, 211, 238, 0.13), transparent 42%);
    box-shadow:
        0 26px 80px rgba(0, 0, 0, 0.44),
        0 1px 0 rgba(255, 255, 255, 0.1) inset;
}

.quick-tool-field {
    display: grid;
    gap: 0.5rem;
    color: #cbd5e1;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.quick-tool-input,
.quick-tool-textarea {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.9rem;
    background: rgba(2, 6, 23, 0.72);
    color: #ffffff;
    font-size: 0.95rem;
    line-height: 1.55;
    padding: 0.85rem 1rem;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18) inset;
}

.quick-tool-input:focus,
.quick-tool-textarea:focus {
    border-color: rgba(34, 211, 238, 0.55) !important;
    box-shadow:
        0 0 0 4px rgba(34, 211, 238, 0.08),
        0 12px 28px rgba(0, 0, 0, 0.2) inset;
}

.quick-tool-textarea {
    min-height: 10rem;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.quick-tool-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.quick-tool-primary,
.quick-tool-secondary {
    min-height: 2.75rem;
    border-radius: 999px;
    padding: 0.75rem 1.15rem;
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    transition: transform 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.quick-tool-primary {
    border: 1px solid rgba(34, 211, 238, 0.62);
    background: #22d3ee;
    color: #020617;
}

.quick-tool-secondary {
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.045);
    color: #e2e8f0;
}

.quick-tool-primary:hover,
.quick-tool-secondary:hover {
    transform: translateY(-1px);
}

.quick-preview-card,
.quick-code-output,
.quick-diff-output {
    min-height: 16rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    background: rgba(2, 6, 23, 0.7);
    padding: 1.15rem;
    overflow-wrap: anywhere;
}

.quick-code-output,
.quick-diff-output {
    white-space: pre-wrap;
    color: #e2e8f0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 0.9rem;
    line-height: 1.55;
}

.quick-stat {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.85rem;
    background: rgba(255, 255, 255, 0.045);
    padding: 0.8rem;
}

.quick-stat span {
    display: block;
    color: #94a3b8;
    font-size: 0.72rem;
    margin-bottom: 0.2rem;
}

.quick-stat strong {
    color: #ffffff;
    font-size: 1.15rem;
}

.diff-same,
.diff-remove,
.diff-add {
    padding: 0.2rem 0.45rem;
    border-radius: 0.45rem;
}

.diff-remove {
    color: #fecaca;
    background: rgba(239, 68, 68, 0.12);
}

.diff-add {
    color: #bbf7d0;
    background: rgba(34, 197, 94, 0.12);
}

.quick-tool-status {
    min-height: 1.25rem;
    margin-top: 1rem;
    color: #94a3b8;
    font-size: 0.9rem;
}

.quick-tool-status.is-ok {
    color: #67e8f9;
}

.quick-tool-status.is-error {
    color: #fca5a5;
}

@media (max-width: 767px) {
    .quick-tool-shell {
        padding-top: 7rem !important;
        padding-bottom: 6rem !important;
    }

    .quick-tool-shell > .container:first-child {
        margin-top: 0 !important;
        margin-bottom: 1.25rem !important;
    }

    .quick-tool-hero {
        display: block;
    }

    .quick-tool-icon {
        display: inline-flex;
        margin-bottom: 1rem;
    }

    .quick-tool-panel {
        padding: 0.95rem;
        border-radius: 1rem;
    }

    .quick-tool-input,
    .quick-tool-textarea {
        border-radius: 0.8rem;
        font-size: 16px;
        padding: 0.8rem 0.9rem;
    }

    .quick-tool-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.65rem;
    }

    .quick-tool-primary,
    .quick-tool-secondary {
        width: 100%;
        min-height: 2.65rem;
        padding-inline: 0.8rem;
        letter-spacing: 0.08em;
    }

    .quick-preview-card,
    .quick-code-output,
    .quick-diff-output {
        min-height: 12rem;
        padding: 0.95rem;
    }
}
