/* TextClean v1.2.8 | Luxury Dashboard Refinement */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    --bg-body: #F8FAFC;
    --bg-card: #FFFFFF;
    --border: #E2E8F0;
    --primary: #4F46E5;
    --primary-glow: rgba(79, 70, 229, 0.4);
    --text-main: #0F172A;
    --sb-thumb: #CBD5E1;
    --sb-track: #F1F5F9;
}

.dark {
    --bg-body: #0B0F1A;
    --bg-card: #161B26;
    --border: #1E293B;
    --primary-glow: rgba(79, 70, 229, 0.2);
    --text-main: #F8FAFC;
    --sb-thumb: #334155;
    --sb-track: #0B0F1A;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    transition: background 0.3s ease;
    overflow-x: hidden;
}

/* Global Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--sb-track); }
::-webkit-scrollbar-thumb { 
    background: var(--sb-thumb); 
    border-radius: 100px;
    border: 3px solid var(--sb-track);
}
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* Luxury Magic Button */
.btn-magic {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    box-shadow: 0 8px 15px -3px rgba(79, 70, 229, 0.3);
    border: none;
    z-index: 1;
    animation: magic-pulse 3s infinite;
}

@keyframes magic-pulse {
    0% { box-shadow: 0 8px 15px -3px rgba(79, 70, 229, 0.3); }
    50% { box-shadow: 0 12px 25px 2px rgba(124, 58, 237, 0.5); }
    100% { box-shadow: 0 8px 15px -3px rgba(79, 70, 229, 0.3); }
}

.btn-magic::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #7C3AED 0%, #4F46E5 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: -1;
}

.btn-magic:hover::before { opacity: 1; }

.btn-magic:hover {
    box-shadow: 0 12px 20px -3px rgba(79, 70, 229, 0.5);
    transform: translateY(-2px) scale(1.02);
}

/* Custom Scrollbar for Textareas */
.text-area::-webkit-scrollbar { width: 6px; }
.text-area::-webkit-scrollbar-track { background: transparent; }
.text-area::-webkit-scrollbar-thumb { 
    background: var(--sb-thumb); 
    border-radius: 10px; 
    border: none;
}
.text-area::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* Force Symmetrical Workspace */
.workspace-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    padding: 2rem;
    min-height: 65vh;
}

/* Prevent long unbroken tokens from forcing grid columns wider than viewport */
.workspace-grid > * {
    min-width: 0;
}

@media (max-width: 1024px) {
    .workspace-grid { grid-template-columns: 1fr; }
}

.editor-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    min-height: 500px;
    min-width: 0;
    position: relative;
    transition: all 0.3s ease;
}

.editor-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.1);
}

.text-area {
    width: 100%;
    height: 100%;
    flex-grow: 1;
    background: transparent;
    border: none;
    outline: none;
    padding: 2rem;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 15px;
    line-height: 1.6;
    resize: none;
    color: inherit;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: pre-wrap;
    min-width: 0;
}

/* Status Bar Logic */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.02);
    border-bottom-left-radius: 24px;
    border-bottom-right-radius: 24px;
}

.dark .status-bar {
    background: rgba(255, 255, 255, 0.02);
}

.stat-item {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-main);
    opacity: 0.6;
    letter-spacing: 0.05em;
}

.stat-item b {
    font-weight: 800;
    color: var(--primary);
    opacity: 1;
}

/* Floating Bottom Dock - FORCED FIXED */
.bottom-dock {
    position: fixed;
    bottom: 5.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 0.75rem 1.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 9999;
    min-width: fit-content;
}

.dark .bottom-dock {
    background: rgba(30, 41, 59, 0.85);
    border-color: rgba(255, 255, 255, 0.05);
}

footer {
    height: 56px;
}

/* Compact Mode Overrides */
.compact-mode #app-wrapper { padding-bottom: 24px; }
.compact-mode header { padding: 1rem 2rem; }
.compact-mode .workspace-grid { padding: 1rem; gap: 1rem; min-height: 50vh; }
.compact-mode .editor-box { min-height: 300px; border-radius: 16px; }
.compact-mode .text-area { padding: 1rem; font-size: 13px; }
.compact-mode .bottom-dock { bottom: 4rem; padding: 0.4rem 0.8rem; transform: translateX(-50%) scale(0.9); }
.compact-mode .accent-line { height: 16px; }
.compact-mode footer { position: static; padding: 1rem 2rem; pointer-events: auto; background: var(--bg-card); border-top: 1px solid var(--border); }

/* Badges & Accents */
.accent-line { width: 3px; height: 24px; border-radius: 10px; }
.bg-indigo { background-color: #6366f1; }
.bg-emerald { background-color: #10b981; }

.btn-luxury {
    padding: 0.5rem 1rem;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-luxury:hover { transform: translateY(-2px); }
.btn-luxury:active { transform: scale(0.95); }

/* Custom Badge */
.tag-redacted {
    background: #FEE2E2;
    color: #DC2626;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 800;
    font-size: 10px;
}
.dark .tag-redacted { background: #7F1D1D; color: #FCA5A5; }

/* Mobile-first dock cleanup */
@media (max-width: 768px) {
    #app-wrapper {
        padding-bottom: 170px;
    }

    header {
        padding: 0.9rem 1rem !important;
    }

    .workspace-grid {
        padding: 0.75rem;
        gap: 0.75rem;
        min-height: auto;
    }

    .editor-box {
        min-height: 42vh;
        border-radius: 16px;
    }

    .text-area {
        padding: 1rem;
        font-size: 13px;
    }

    .bottom-dock {
        left: 0.5rem;
        right: 0.5rem;
        bottom: calc(env(safe-area-inset-bottom, 0px) + 0.5rem);
        transform: none;
        min-width: 0;
        width: auto;
        border-radius: 16px;
        padding: 0.5rem;
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "magic advanced"
            "tools tools";
        gap: 0.45rem;
    }

    .bottom-dock > .w-px {
        display: none;
    }

    #action-magic {
        grid-area: magic;
        width: 100%;
        justify-content: center;
        padding: 0.55rem 0.7rem !important;
        font-size: 10px;
    }

    .bottom-dock > .relative.group {
        grid-area: advanced;
        justify-self: end;
    }

    #adv-tools-toggle {
        padding: 0.55rem 0.7rem;
        font-size: 10px;
        white-space: nowrap;
    }

    #tool-hub {
        grid-area: tools;
        max-width: 100% !important;
        width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 0.1rem;
        gap: 0.35rem !important;
        -webkit-overflow-scrolling: touch;
    }

    #tool-hub .btn-luxury {
        flex: 0 0 auto;
        padding: 0.45rem 0.6rem;
        font-size: 10px;
        border-radius: 10px;
    }

    #adv-tools-menu {
        position: fixed;
        left: 0.5rem;
        right: 0.5rem;
        bottom: calc(env(safe-area-inset-bottom, 0px) + 4.5rem);
        margin: 0;
        min-width: 0;
        max-height: 52vh;
        overflow-y: auto;
        border-radius: 14px;
        padding: 0.45rem;
    }

    .compact-mode .bottom-dock {
        bottom: calc(env(safe-area-inset-bottom, 0px) + 0.5rem);
        padding: 0.45rem;
        transform: none;
    }

    .compact-mode #app-wrapper {
        padding-bottom: 170px;
    }

    footer {
        position: static !important;
        padding: 0.75rem 1rem !important;
        pointer-events: auto;
        background: var(--bg-card);
        border-top: 1px solid var(--border);
        height: auto;
    }
}
