/* ============================================================
   UI/UX IMPROVEMENTS - Underground Checker v3.1
   ============================================================ */

/* Glassmorphism Effects */
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Enhanced Shadows */
.shadow-glow-primary {
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.2),
                0 4px 12px rgba(0, 0, 0, 0.3);
}

.shadow-glow-danger {
    box-shadow: 0 0 20px rgba(244, 63, 94, 0.2),
                0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Animated Gradient Background */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 20% 50%, rgba(16, 185, 129, 0.03) 0%, transparent 50%),
                radial-gradient(circle at 80% 80%, rgba(6, 182, 212, 0.03) 0%, transparent 50%),
                radial-gradient(circle at 40% 20%, rgba(139, 92, 246, 0.02) 0%, transparent 50%);
    animation: gradientShift 20s ease infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes gradientShift {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(5%, -5%) rotate(120deg); }
    66% { transform: translate(-5%, 5%) rotate(240deg); }
}

.app-layout {
    position: relative;
    z-index: 1;
}

/* Enhanced Button Animations */
.btn {
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    position: relative;
    overflow: hidden;
}

.btn-primary::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    transform: rotate(45deg);
    animation: buttonShine 3s infinite;
}

@keyframes buttonShine {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.btn .spinner {
    margin-right: 6px;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-panel) 0%,
        var(--bg-hover) 50%,
        var(--bg-panel) 100%
    );
    background-size: 200% 100%;
    animation: skeleton 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

@keyframes skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Enhanced Card Hover */
.card-hover {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4),
                0 0 0 1px rgba(16, 185, 129, 0.1);
}

/* Pulse Animation for Live Stats */
.stat-pill.live .dot {
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 16px rgba(16, 185, 129, 0.8);
        transform: scale(1.1);
    }
}

/* Enhanced Terminal */
.terminal-wrapper {
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.3);
}

.terminal-body {
    position: relative;
}

.terminal-body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(16, 185, 129, 0.3),
        transparent
    );
    animation: scanline 4s linear infinite;
}

@keyframes scanline {
    0% { transform: translateY(0); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: translateY(400px); opacity: 0; }
}

/* Enhanced Results Table */
.results-table tbody tr {
    transition: all 0.2s ease;
}

.results-table tbody tr:hover {
    background: rgba(16, 185, 129, 0.03);
    transform: scale(1.01);
}

.results-table tbody tr.live {
    animation: fadeInGreen 0.5s ease;
}

.results-table tbody tr.die {
    animation: fadeInRed 0.5s ease;
}

@keyframes fadeInGreen {
    from {
        background: rgba(16, 185, 129, 0.2);
        transform: translateX(-10px);
        opacity: 0;
    }
    to {
        background: transparent;
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeInRed {
    from {
        background: rgba(244, 63, 94, 0.2);
        transform: translateX(-10px);
        opacity: 0;
    }
    to {
        background: transparent;
        transform: translateX(0);
        opacity: 1;
    }
}

/* Enhanced Badge */
.badge {
    position: relative;
    overflow: hidden;
}

.badge::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: left 0.5s;
}

.results-table tbody tr:hover .badge::before {
    left: 100%;
}

/* Enhanced Progress Bar */
.progress-fill {
    position: relative;
    overflow: hidden;
}

.progress-fill::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: progressShine 2s infinite;
}

@keyframes progressShine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Enhanced Input Focus */
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1),
                0 0 20px rgba(16, 185, 129, 0.05);
    transform: translateY(-1px);
}

/* Enhanced Sidebar */
.sidebar {
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
}

.nav-item {
    position: relative;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: var(--accent-primary);
    border-radius: 0 2px 2px 0;
    transition: height 0.3s ease;
}

.nav-item.active::before {
    height: 60%;
}

.nav-item:hover::before {
    height: 40%;
}

/* Enhanced Modal */
.modal {
    animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-overlay {
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Enhanced Toast */
.toast {
    animation: toastSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
               toastSlideOut 0.3s ease 3.7s forwards;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes toastSlideOut {
    to {
        opacity: 0;
        transform: translateX(100%) scale(0.8);
    }
}

/* Enhanced Chip */
.chip {
    position: relative;
    overflow: hidden;
}

.chip::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.4s, height 0.4s;
}

.chip:active::after {
    width: 100px;
    height: 100px;
}

/* Status Dot Animation */
.dot {
    position: relative;
}

.dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: inherit;
    transform: translate(-50%, -50%);
    animation: dotPulse 2s ease-out infinite;
}

@keyframes dotPulse {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(2);
    }
}

/* Enhanced Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(
        180deg,
        rgba(16, 185, 129, 0.3),
        rgba(6, 182, 212, 0.3)
    );
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(
        180deg,
        rgba(16, 185, 129, 0.5),
        rgba(6, 182, 212, 0.5)
    );
    background-clip: padding-box;
}

/* Micro-interactions */
.clickable {
    cursor: pointer;
    transition: transform 0.1s ease;
}

.clickable:active {
    transform: scale(0.95);
}

/* Enhanced Card Input */
.card-textarea {
    transition: all 0.3s ease;
}

.card-textarea:focus {
    box-shadow: inset 0 0 20px rgba(16, 185, 129, 0.05);
}

/* Enhanced Terminal Line */
.terminal-line {
    position: relative;
    padding-left: 4px;
}

.terminal-line::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 0;
    background: currentColor;
    opacity: 0.3;
    transition: height 0.2s ease;
}

.terminal-line:hover::before {
    height: 80%;
}

/* Loading State for Buttons */
.btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

.btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Enhanced Topbar */
.topbar {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    background: rgba(17, 24, 39, 0.8);
}

/* Enhanced Config Bar */
.config-bar {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    background: rgba(17, 24, 39, 0.6);
}

/* Floating Action Button (for mobile) */
.fab {
    position: fixed;
    bottom: 72px;
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-cyan));
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4),
                0 8px 24px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    z-index: 99;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fab:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.5),
                0 12px 32px rgba(0, 0, 0, 0.4);
}

.fab:active {
    transform: scale(0.95) rotate(90deg);
}

@media (min-width: 769px) {
    .fab { display: none; }
}

/* Enhanced Empty State */
.empty-state {
    animation: fadeIn 0.5s ease;
}

/* Tooltip */
.tooltip {
    position: relative;
}

.tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 6px 10px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1000;
}

.tooltip:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

/* Success Animation */
@keyframes successPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }
}

.success-pulse {
    animation: successPulse 1s ease-out;
}

/* Error Shake */
@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

.error-shake {
    animation: errorShake 0.5s ease;
}
