:root {
    --brand-green: #00ED64;
    --brand-blue: #3b82f6;
    --brand-yellow: #f59e0b;
    --brand-red: #ef4444;
    --brand-indigo: #818cf8;
    --bg-dark-primary: #0b0f17;
    --bg-dark-secondary: #151c28;
    --bg-dark-elevated: #1b2434;
    --border-color: #2a3649;
    --text-primary: #F9FAFB;
    --text-secondary: #9ca3af;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-dark-primary);
    background-image: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(0, 237, 100, 0.07), transparent);
    color: var(--text-primary);
}

.font-mono, code, pre {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Custom Scrollbars */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2d3a4f; border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: #415370; }

.brand-green { color: var(--brand-green); }
.brand-dark-bg { background-color: var(--bg-dark-secondary); }
.brand-border { border-color: var(--border-color); }

.glass-header {
    background: rgba(15, 21, 32, 0.85);
    backdrop-filter: blur(12px);
}

.glass-toolbar {
    background: rgba(11, 15, 23, 0.88);
    backdrop-filter: blur(12px);
}

.surface-card {
    background-color: var(--bg-dark-secondary);
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 24px -6px rgba(0, 0, 0, 0.35);
}

.kbd-hint {
    padding: 0.1rem 0.4rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.68rem;
    background: #1a2230;
    border: 1px solid #324056;
    border-radius: 4px;
    color: #cbd5e1;
}

/* Markdown Styling inside AI Summaries */
.markdown-content pre {
    background-color: #090d14;
    border: 1px solid #232e40;
    padding: 0.85rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.5rem 0;
}
.markdown-content code {
    background-color: rgba(255, 255, 255, 0.07);
    color: #e2e8f0;
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    font-size: 0.82em;
}
.markdown-content p {
    margin-bottom: 0.5rem;
    line-height: 1.62;
}
.markdown-content p:last-child {
    margin-bottom: 0;
}

.hidden { display: none !important; }

/* Modals */
.modal-overlay { transition: opacity 0.22s cubic-bezier(0.4, 0, 0.2, 1); }
.modal-content { transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1); }
.sidebar-section { border-top: 1px solid var(--border-color); padding-top: 1.15rem; }

/* Eye of Sauron Scanner Animation */
.sauron-eye-container {
    position: relative;
    width: 112px;
    height: 112px;
    overflow: hidden;
    border-radius: 9999px;
}
.sauron-eye {
    position: absolute;
    inset: 12px;
    background: radial-gradient(circle, #ff4500 8%, #ff8c00 22%, #ffd700 34%, #090d14 62%);
    border-radius: 50% / 32%;
    animation: pulse-eye 3.2s infinite ease-in-out;
}
.sauron-eye::before {
    content: '';
    position: absolute;
    top: 22%;
    left: 46%;
    width: 8%;
    height: 56%;
    background: #05070b;
    border-radius: 50%;
    box-shadow: 0 0 8px #ff4500;
}
.scan-beam {
    position: absolute;
    top: 48%;
    left: -25%;
    width: 150%;
    height: 6px;
    background: linear-gradient(90deg, transparent, rgba(0, 237, 100, 0.65), transparent);
    transform-origin: center;
    animation: sweep 2.6s ease-in-out infinite alternate;
}

@keyframes pulse-eye {
    0%, 100% { transform: scale(0.97); box-shadow: 0 0 14px rgba(255, 140, 0, 0.55); }
    50% { transform: scale(1.04); box-shadow: 0 0 26px rgba(255, 69, 0, 0.85), 0 0 42px rgba(255, 140, 0, 0.45); }
}
@keyframes sweep {
    from { transform: rotate(-22deg); }
    to { transform: rotate(22deg); }
}

/* Smooth Non-Clipping Card Entrance */
@keyframes card-enter {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.99);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
.card-enter-animation {
    animation: card-enter 0.32s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.feed-card {
    background-color: var(--bg-dark-secondary);
    border: 1px solid var(--border-color);
    transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
}
.feed-card:hover {
    border-color: #3b4d68;
    transform: translateY(-3px);
    box-shadow:
        0 16px 36px -12px rgba(0, 0, 0, 0.62),
        0 0 0 1px rgba(0, 237, 100, 0.08),
        0 0 26px -8px rgba(0, 237, 100, 0.22);
}
.feed-card.summary-pending {
    border-left: 3px solid var(--brand-yellow);
    animation: pending-pulse 2.1s ease-in-out infinite;
}
@keyframes pending-pulse {
    0%, 100% { border-left-color: rgba(245, 158, 11, 0.5); }
    50% { border-left-color: rgba(245, 158, 11, 1); }
}

.scanning-source {
    background-color: rgba(0, 237, 100, 0.08) !important;
    border-color: rgba(0, 237, 100, 0.55) !important;
    box-shadow: inset 0 0 12px rgba(0, 237, 100, 0.12);
}

/* Multi-Source Scan Tabs */
.scan-tab {
    padding: 0.45rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(21, 28, 40, 0.7);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    white-space: nowrap;
    transition: all 0.18s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}
.scan-tab:hover {
    color: var(--text-primary);
    border-color: #435674;
}
.scan-tab.active-scan-tab {
    color: #062814;
    background: var(--brand-green);
    border-color: var(--brand-green);
    box-shadow: 0 0 14px rgba(0, 237, 100, 0.25);
}
.scan-tab .tab-count {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.68rem;
    padding: 0.05rem 0.4rem;
    border-radius: 9999px;
    background: rgba(0, 0, 0, 0.22);
}

/* Interactive JSON Mapper */
.preview-tab-btn {
    padding: 0.4rem 0.85rem;
    border-radius: 8px;
    background-color: #131a26;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    transition: all 0.18s ease;
}
.preview-tab-btn.active-tab {
    background-color: #2563eb;
    border-color: #3b82f6;
    color: white;
    font-weight: 600;
}
.json-key { color: #7dd3fc; }
.json-string { color: #fca5a5; }
.json-number { color: #bef264; }
.json-boolean { color: #93c5fd; }
.json-null { color: #94a3b8; }
.json-value {
    cursor: pointer;
    border-radius: 4px;
    padding: 1px 4px;
    display: inline-block;
    transition: background-color 0.15s;
}
.json-value:hover { background-color: rgba(59, 130, 246, 0.28); }
.selected-json-path {
    background-color: rgba(59, 130, 246, 0.5) !important;
    outline: 1px solid #60a5fa;
}
.regex-match {
    background-color: rgba(0, 237, 100, 0.28);
    color: #a7f3d0;
    border-bottom: 2px solid var(--brand-green);
    border-radius: 2px;
    padding: 0 2px;
    font-weight: 600;
}

body.path-selected .mapping-target-btn {
    animation: pulse-blue 1.4s infinite;
}
@keyframes pulse-blue {
    0%, 100% { background-color: #1f2937; box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
    50% { background-color: #2563eb; color: white; box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.28); }
}

.json-entry-label {
    display: flex;
    align-items: baseline;
    cursor: pointer;
    width: 100%;
    border-radius: 4px;
    padding: 2px 4px;
}
.json-entry-label:hover { background-color: rgba(255, 255, 255, 0.04); }
.json-checkbox {
    margin-right: 0.6rem;
    accent-color: var(--brand-green);
    width: 13px;
    height: 13px;
    transform: translateY(2px);
}

/* Navigation View Tabs */
.view-tab-btn {
    position: relative;
    padding: 0.75rem 1.1rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: color 0.2s ease-in-out;
    white-space: nowrap;
}
.view-tab-btn::after {
    content: '';
    position: absolute;
    left: 50%;
    right: 50%;
    bottom: -1px;
    height: 2px;
    border-radius: 2px;
    background: var(--brand-green);
    box-shadow: 0 0 10px rgba(0, 237, 100, 0.5);
    transition: left 0.26s cubic-bezier(0.4, 0, 0.2, 1), right 0.26s cubic-bezier(0.4, 0, 0.2, 1);
}
.view-tab-btn:hover { color: var(--text-primary); }
.view-tab-btn:hover::after { left: 22%; right: 22%; }
.view-tab-btn.active-view-tab {
    color: var(--brand-green);
}
.view-tab-btn.active-view-tab::after { left: 0; right: 0; }

/* Dashboard Table */
.stats-table { border-collapse: collapse; width: 100%; }
.stats-table th, .stats-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}
.stats-table thead { background-color: rgba(255, 255, 255, 0.03); }
.stats-table th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 600;
}
.stats-table th.sortable { cursor: pointer; user-select: none; }
.stats-table th.sortable:hover { color: white; background-color: rgba(255, 255, 255, 0.05); }
.stats-table tbody tr:hover { background-color: rgba(255, 255, 255, 0.025); }

#config-status-btn .fa-chevron-down { transition: transform 0.2s ease-in-out; }
#config-status-btn.open .fa-chevron-down { transform: rotate(180deg); }

.summary-snippet {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@keyframes pulse-paused {
    0%, 100% { transform: scale(1); opacity: 0.88; }
    50% { transform: scale(1.05); opacity: 1; }
}

#controls-container {
    background-color: var(--bg-dark-secondary);
    background-image: radial-gradient(circle at center, rgba(0, 237, 100, 0.11) 0%, transparent 65%);
    border: 1px solid rgba(0, 237, 100, 0.32);
    box-shadow: inset 0 0 24px rgba(0, 237, 100, 0.12), 0 8px 24px rgba(0, 0, 0, 0.3);
}
#controls-container .scan-paused-animation {
    animation: pulse-paused 2.2s infinite ease-in-out;
}

/* Hybrid Mode Active Button */
.hybrid-mode-active {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.35), rgba(124, 58, 237, 0.35)) !important;
    border-color: #818cf8 !important;
    color: #e0e7ff !important;
    box-shadow: 0 0 16px rgba(99, 102, 241, 0.25);
    animation: hybrid-glow 2.6s ease-in-out infinite;
}
@keyframes hybrid-glow {
    0%, 100% { box-shadow: 0 0 14px rgba(99, 102, 241, 0.22); }
    50% { box-shadow: 0 0 22px rgba(129, 140, 248, 0.45); }
}

/* =====================================================================
   UI/UX POLISH LAYER — micro-interactions, tactile feedback, a11y
   Everything below is additive and respects prefers-reduced-motion.
   ===================================================================== */

/* Tactile press + consistent easing on every button */
button {
    transition: transform 0.12s ease, box-shadow 0.22s ease,
                background-color 0.2s ease, border-color 0.2s ease, color 0.16s ease, opacity 0.2s ease;
}
button:not(:disabled):active {
    transform: translateY(1px) scale(0.985);
}
button:disabled {
    cursor: not-allowed;
}

/* Small card action buttons lift gently on hover */
.copy-summary-btn:hover:not(:disabled),
.send-to-slack-btn:hover:not(:disabled),
.find-related-btn:hover:not(:disabled),
.edit-btn:hover,
.remove-btn:hover,
.scan-single-source-btn:hover {
    transform: translateY(-1px);
}

/* Keyboard-visible focus rings (idiot-proof navigation, no mouse-focus noise) */
button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--brand-green);
    outline-offset: 2px;
    border-radius: 7px;
}

/* Soft focus glow on text controls (layers on top of Tailwind border colors) */
input:focus,
select:focus,
textarea:focus {
    box-shadow: 0 0 0 3px rgba(0, 237, 100, 0.12);
}

/* Links get a smooth colour transition */
a { transition: color 0.16s ease; }

/* Toggle switch knob/track eased for a satisfying flip */
.source-scan-toggle + div,
.source-scan-toggle + div::after {
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Quota meter bars fill smoothly */
#quota-watchers-bar, #quota-sources-bar, #quota-scans-bar, #quota-searches-bar {
    transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Status pill dot soft entrance */
#status-dot { transition: background-color 0.25s ease, box-shadow 0.25s ease; }

/* Count/badge pills pop when they change */
.tab-count,
#live-feed-count-pill,
#watchers-count-badge,
#sources-count-badge,
#mstash-scans-pill {
    transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s ease;
}

/* Animated sheen sweep across the primary scan CTA (id persists through re-render) */
#global-scan-control-btn {
    position: relative;
    overflow: hidden;
}
#global-scan-control-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -130%;
    width: 60%;
    height: 100%;
    background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.18), transparent);
    transform: skewX(-20deg);
    transition: left 0.6s ease;
    pointer-events: none;
}
#global-scan-control-btn:hover::before { left: 150%; }

/* Toast entrance gets a colour-coded accent edge */
#toast-container > div {
    border-left-width: 3px;
    box-shadow: 0 12px 32px -10px rgba(0, 0, 0, 0.7);
}

/* Modal backdrop fade + content springy entrance */
.modal-overlay { transition: opacity 0.24s cubic-bezier(0.4, 0, 0.2, 1); }
.modal-content { transition: transform 0.26s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.24s ease; }

/* Surface cards get a soft hover lift in the dashboard */
.surface-card { transition: box-shadow 0.25s ease, transform 0.25s cubic-bezier(0.22, 1, 0.36, 1); }

/* Empty-state radar icon gently breathes to signal "ready & waiting" */
#placeholder .fa-radar { animation: radar-breathe 3.4s ease-in-out infinite; }
@keyframes radar-breathe {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.08); opacity: 1; }
}

/* Spinners keep a consistent accent everywhere */
.fa-circle-notch.fa-spin { filter: drop-shadow(0 0 4px rgba(0, 237, 100, 0.25)); }

/* Respect users who prefer less motion — disable non-essential animation */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .feed-card:hover,
    .copy-summary-btn:hover,
    .send-to-slack-btn:hover,
    .find-related-btn:hover,
    button:active {
        transform: none !important;
    }
}
