/* UX Polish and Mobile Improvements for 999DEX */
/* Addresses mobile UX complaints and adds visual polish */

/* ============================================================================
   MOBILE-FIRST IMPROVEMENTS
   ============================================================================ */

/* Larger touch targets for mobile */
@media (max-width: 768px) {
    button,
    a.btn,
    input[type="button"],
    input[type="submit"] {
        min-height: 48px;
        min-width: 48px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Larger input fields */
    input[type="text"],
    input[type="number"],
    input[type="url"],
    input[type="email"],
    textarea,
    select {
        min-height: 48px;
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px 16px;
    }

    /* Token cards - easier to tap */
    .token-card {
        min-height: 140px;
        padding: 20px;
        margin-bottom: 16px;
    }

    .token-card img {
        width: 80px;
        height: 80px;
    }

    /* Sticky trading panel on mobile */
    .trading-panel-mobile {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: linear-gradient(to top, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.95));
        backdrop-filter: blur(10px);
        padding: 16px;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
        z-index: 100;
        border-top: 1px solid rgba(139, 92, 246, 0.3);
    }

    /* Simplified charts on mobile */
    .price-chart {
        height: 220px !important;
    }

    /* Full-screen modals on mobile */
    .modal-mobile {
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }

    /* Bottom sheet style modals */
    .bottom-sheet {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 90vh;
        border-radius: 24px 24px 0 0;
        animation: slideUpSheet 0.3s ease-out;
    }

    @keyframes slideUpSheet {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }

    /* Hamburger menu spacing */
    .mobile-menu {
        padding: 20px;
    }

    .mobile-menu a {
        padding: 16px;
        display: block;
        font-size: 18px;
    }

    /* Better table scrolling */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -16px;
        padding: 0 16px;
    }

    /* Swipeable cards */
    .swipeable-card {
        touch-action: pan-y;
    }
}

/* Landscape mobile adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .hero-section {
        padding: 24px 0;
    }

    .price-chart {
        height: 180px !important;
    }
}

/* ============================================================================
   TOOLTIP ENHANCEMENTS
   ============================================================================ */

.info-icon {
    display: inline-flex;
    align-items: center;
    justify-center: center;
    width: 18px;
    height: 18px;
    margin-left: 6px;
    color: rgba(139, 92, 246, 0.8);
    cursor: help;
    transition: color 0.2s ease;
    vertical-align: middle;
}

.info-icon:hover {
    color: rgba(139, 92, 246, 1);
}

.info-icon svg {
    width: 16px;
    height: 16px;
}

/* Enhanced tooltip styles */
.enhanced-tooltip {
    position: relative;
    display: inline-block;
}

.enhanced-tooltip .tooltip-text {
    visibility: hidden;
    position: absolute;
    z-index: 10000;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: #fff;
    text-align: center;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    white-space: normal;
    width: max-content;
    max-width: 320px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(139, 92, 246, 0.3);
    opacity: 0;
    transition: opacity 0.3s, visibility 0.3s;
}

.enhanced-tooltip .tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: #1e293b transparent transparent transparent;
}

.enhanced-tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* ============================================================================
   LOADING STATES
   ============================================================================ */

/* Button loading state */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spinner 0.6s linear infinite;
}

@keyframes spinner {
    to {
        transform: rotate(360deg);
    }
}

/* Skeleton loading */
.skeleton-loading {
    background: linear-gradient(
        90deg,
        rgba(71, 85, 105, 0.3) 25%,
        rgba(71, 85, 105, 0.5) 50%,
        rgba(71, 85, 105, 0.3) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-wave 1.5s ease-in-out infinite;
    border-radius: 8px;
}

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

/* Pulsing loader */
.pulse-loader {
    display: inline-block;
}

.pulse-loader span {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin: 0 2px;
    background: rgba(139, 92, 246, 0.8);
    border-radius: 50%;
    animation: pulse-dot 1.4s infinite both;
}

.pulse-loader span:nth-child(2) {
    animation-delay: 0.2s;
}

.pulse-loader span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes pulse-dot {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============================================================================
   SUCCESS/ERROR STATES
   ============================================================================ */

/* Success animation */
.success-bounce {
    animation: success-bounce 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes success-bounce {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Error shake */
.error-shake {
    animation: error-shake 0.5s;
}

@keyframes error-shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-8px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(8px);
    }
}

/* Warning pulse */
.warning-pulse {
    animation: warning-pulse 2s ease-in-out infinite;
}

@keyframes warning-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(245, 158, 11, 0);
    }
}

/* ============================================================================
   PRICE IMPACT WARNINGS
   ============================================================================ */

.price-impact-low {
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.price-impact-medium {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.price-impact-high {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    animation: warning-pulse 2s ease-in-out infinite;
}

/* ============================================================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================================================ */

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid #8b5cf6;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Skip to main content link */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: #8b5cf6;
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 0 0 4px 0;
    z-index: 100000;
}

.skip-to-main:focus {
    top: 0;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================================================
   TRUST INDICATORS
   ============================================================================ */

.security-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 8px;
    color: #10b981;
    font-size: 14px;
    font-weight: 600;
}

.security-badge svg {
    width: 20px;
    height: 20px;
}

.verified-badge {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    color: #3b82f6;
}

.audit-badge {
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.3);
    color: #8b5cf6;
}

/* ============================================================================
   EMPTY STATES
   ============================================================================ */

.empty-state {
    padding: 64px 24px;
    text-align: center;
}

.empty-state-icon {
    width: 96px;
    height: 96px;
    margin: 0 auto 24px;
    color: rgba(139, 92, 246, 0.3);
}

.empty-state-title {
    font-size: 24px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 12px;
}

.empty-state-description {
    font-size: 16px;
    color: #94a3b8;
    margin-bottom: 24px;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

/* ============================================================================
   NOTIFICATION BADGES
   ============================================================================ */

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #0f172a;
    animation: badge-pop 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes badge-pop {
    0% {
        transform: scale(0);
    }
    100% {
        transform: scale(1);
    }
}

/* ============================================================================
   PROGRESSIVE DISCLOSURE
   ============================================================================ */

.collapsible-section {
    transition: max-height 0.3s ease;
    overflow: hidden;
}

.collapsible-section.collapsed {
    max-height: 0 !important;
}

.expand-icon {
    transition: transform 0.3s ease;
}

.expand-icon.expanded {
    transform: rotate(180deg);
}

/* ============================================================================
   SMOOTH TRANSITIONS
   ============================================================================ */

.smooth-transition {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-in-right {
    animation: slideInRight 0.4s ease-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============================================================================
   COPY BUTTON
   ============================================================================ */

.copy-button {
    position: relative;
    padding: 6px 12px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 6px;
    color: #8b5cf6;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-button:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.5);
}

.copy-button.copied {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
    color: #10b981;
}

.copy-button.copied::after {
    content: "Copied!";
    position: absolute;
    top: -32px;
    left: 50%;
    transform: translateX(-50%);
    background: #10b981;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    animation: fadeInOut 2s ease;
}

@keyframes fadeInOut {
    0%, 100% {
        opacity: 0;
    }
    10%, 90% {
        opacity: 1;
    }
}

/* ============================================================================
   GRADIENT PROGRESS BAR
   ============================================================================ */

.gradient-progress {
    background: linear-gradient(
        90deg,
        #8b5cf6 0%,
        #06b6d4 50%,
        #10b981 100%
    );
    background-size: 200% 100%;
    animation: gradient-shift 3s ease infinite;
}

@keyframes gradient-shift {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
    .no-print,
    header,
    footer,
    .floating-help-btn,
    #floatingHelpBtn,
    button,
    .modal {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }
}

/* ============================================================================
   REDUCED MOTION
   ============================================================================ */

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

/* ============================================================================
   HIGH CONTRAST MODE
   ============================================================================ */

@media (prefers-contrast: high) {
    * {
        border-color: currentColor !important;
    }

    button,
    a {
        text-decoration: underline;
    }
}
