/* =============================================================================
   NARRATIVE PROFILE TOKEN TABLE STYLES
   Dedicated styles for token table in narrative profile pages
   ============================================================================= */

/* Navigation Tab Integration for Narrative Profile */
body.narrative-profile .tab-container {
    margin-bottom: 0;
    border-bottom: none;
}

body.narrative-profile .custom-tabs {
    margin-bottom: 0;
}

body.narrative-profile .content-container {
    margin-top: 0 !important;
    border-top: none !important;
    border-radius: 0 0 12px 12px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Token Table Container */
.narrative-token-table-container {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    background: white;
}

/* Token Table Base Styling */
.narrative-token-table {
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
}

.narrative-token-table thead th {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: none;
    font-weight: 600;
    font-size: 0.85rem;
    color: #495057;
    padding: 16px 12px;
    text-align: left;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Token table headers styling to match top tokens widget */
.token-table thead th {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: none;
    font-weight: 600;
    font-size: 0.85rem;
    color: #495057;
    padding: 12px 8px;
    text-align: left;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 2px solid #dee2e6;
}

.narrative-token-table tbody tr {
    border-bottom: 1px solid #f1f3f4;
    transition: all 0.2s ease;
    background: white;
}

.narrative-token-table tbody tr:hover {
    background: linear-gradient(135deg, #f8f9ff 0%, #e3f2fd 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 82, 204, 0.08);
}

/* Enhanced hover for clickable rows */
.narrative-token-table tbody tr[onclick]:hover {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 82, 204, 0.15);
}

.narrative-token-table tbody tr:last-child {
    border-bottom: none;
}

.narrative-token-table tbody td {
    padding: 12px;
    vertical-align: middle;
    border: none;
    white-space: nowrap;
}

.narrative-token-table tbody td.token-info-mobile {
    white-space: normal;
    min-width: 200px;
}

/* Token Info Section */
.narrative-token-info {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.narrative-token-logo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid #e9ecef;
    transition: all 0.3s ease;
    background: white;
    object-fit: cover;
}

.narrative-token-logo:hover {
    transform: scale(1.1) rotate(360deg);
    border-color: #007bff;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.2);
}

.narrative-token-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.narrative-token-symbol {
    font-weight: 700;
    font-size: 1rem;
    color: #212529;
    text-decoration: none;
    transition: color 0.2s ease;
}

.narrative-token-symbol:hover {
    color: #007bff;
}

.narrative-token-market-cap {
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 2px;
}

/* Mobile layout adjustments */
@media (max-width: 768px) {
    .narrative-token-info {
        gap: 8px;
        align-items: center;
    }

    .narrative-token-details {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
        flex: 1;
        min-width: 0;
    }

    .narrative-token-symbol-row {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
    }

    .narrative-token-symbol {
        font-size: 0.85rem;
        line-height: 1.2;
        flex-shrink: 0;
    }

    .narrative-token-market-cap {
        font-size: 0.7rem;
        white-space: nowrap;
        color: #6c757d;
        margin-left: auto;
    }

    .narrative-alt-rank-indicator {
        margin-top: 2px;
        align-self: flex-start;
    }
}

/* Alt Rank Performance Indicators */
.narrative-alt-rank-indicator {
    margin-left: 8px;
    font-size: 1.2em;
    cursor: help;
    transition: transform 0.2s ease;
}

.narrative-alt-rank-indicator:hover {
    transform: scale(1.2);
}

/* Volume Battery Indicators */
.narrative-volume-battery {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.narrative-battery-icon {
    font-size: 1.3rem;
    transition: all 0.3s ease;
    cursor: help;
}

.narrative-battery-icon:hover {
    transform: scale(1.15);
}

.narrative-battery-icon.exceptional {
    color: #6f42c1;
    text-shadow: 0 0 8px rgba(111, 66, 193, 0.3);
}

.narrative-battery-icon.strong {
    color: #007bff;
    text-shadow: 0 0 6px rgba(0, 123, 255, 0.3);
}

.narrative-battery-icon.moderate {
    color: #28a745;
    text-shadow: 0 0 4px rgba(40, 167, 69, 0.3);
}

.narrative-battery-icon.weak {
    color: #ffc107;
}

.narrative-battery-icon.poor {
    color: #dc3545;
}

.narrative-volume-text {
    font-size: 0.7rem;
    font-weight: 600;
    color: #6c757d;
    text-align: center;
    white-space: nowrap;
}

/* Mobile volume layout */
@media (max-width: 768px) {
    .narrative-volume-battery {
        flex-direction: row;
        align-items: center;
        gap: 4px;
        justify-content: flex-start;
    }

    .narrative-battery-icon {
        font-size: 1.0rem;
    }

    .narrative-volume-text {
        font-size: 0.65rem;
        margin: 0;
    }
}

/* Price Display */
.narrative-token-price {
    font-weight: 700;
    font-size: 1rem;
    color: #212529;
    text-align: right;
}

.narrative-price-notation {
    font-size: 0.7em;
    color: #6c757d;
    font-weight: normal;
}

/* Mini Charts */
.narrative-mini-charts {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0px;
}

.narrative-mini-chart {
    position: relative;
    transition: transform 0.2s ease;
}

.narrative-mini-chart:hover {
    transform: scale(1.1);
}

.narrative-mini-chart svg {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.narrative-chart-text {
    font-size: 7px;
    font-weight: 600;
    text-anchor: middle;
}

.narrative-chart-label {
    font-size: 6px;
    font-weight: 500;
    text-anchor: middle;
}

.narrative-chart-dot {
    transition: r 0.2s ease;
}

.narrative-mini-chart:hover .narrative-chart-dot {
    r: 3;
}

/* Sentiment & Social Volume */
.narrative-sentiment-social {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.narrative-sentiment-emoji {
    font-size: 1.4em;
    transition: transform 0.3s ease;
    cursor: help;
}

.narrative-sentiment-emoji:hover {
    transform: scale(1.2) rotate(10deg);
}

.narrative-social-volume {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6c757d;
    text-align: center;
}

/* Performance Change Colors */
.narrative-change-positive {
    color: #28a745 !important;
}

.narrative-change-negative {
    color: #dc3545 !important;
}

.narrative-change-neutral {
    color: #6c757d !important;
}

/* Token logo spin animation */
.token-logo {
    transition: transform 0.3s ease;
    transform-style: preserve-3d;
}

.token-row:hover .token-logo {
    animation: coinFlip3D 2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

@keyframes coinFlip3D {
    0% {
        transform: perspective(200px) rotateY(0deg) rotateX(0deg);
        filter: brightness(1);
    }
    5% {
        transform: perspective(200px) rotateY(90deg) rotateX(5deg);
        filter: brightness(1.1);
    }
    10% {
        transform: perspective(200px) rotateY(180deg) rotateX(10deg);
        filter: brightness(0.9);
    }
    15% {
        transform: perspective(200px) rotateY(270deg) rotateX(15deg);
        filter: brightness(1.1);
    }
    20% {
        transform: perspective(200px) rotateY(360deg) rotateX(20deg);
        filter: brightness(1);
    }
    25% {
        transform: perspective(200px) rotateY(450deg) rotateX(15deg);
        filter: brightness(1.1);
    }
    30% {
        transform: perspective(200px) rotateY(540deg) rotateX(10deg);
        filter: brightness(0.9);
    }
    35% {
        transform: perspective(200px) rotateY(630deg) rotateX(5deg);
        filter: brightness(1.1);
    }
    40% {
        transform: perspective(200px) rotateY(720deg) rotateX(0deg);
        filter: brightness(1);
    }
    50% {
        transform: perspective(200px) rotateY(900deg) rotateX(-5deg);
        filter: brightness(0.95);
    }
    60% {
        transform: perspective(200px) rotateY(1080deg) rotateX(-3deg);
        filter: brightness(1.05);
    }
    70% {
        transform: perspective(200px) rotateY(1260deg) rotateX(-2deg);
        filter: brightness(0.98);
    }
    80% {
        transform: perspective(200px) rotateY(1440deg) rotateX(-1deg);
        filter: brightness(1.02);
    }
    90% {
        transform: perspective(200px) rotateY(1620deg) rotateX(-0.5deg);
        filter: brightness(0.99);
    }
    95% {
        transform: perspective(200px) rotateY(1710deg) rotateX(0deg);
        filter: brightness(1.01);
    }
    100% {
        transform: perspective(200px) rotateY(1800deg) rotateX(0deg);
        filter: brightness(1);
    }
}

/* Mobile Responsive Adjustments */
@media (max-width: 768px) {
    /* Remove card margin on mobile */
    .card.mb-4 {
        margin-bottom: 0 !important;
        padding: 0 !important;
    }

    /* Token info cell styling to match top tokens widget */
    .narrative-token-table .token-info-mobile {
        width: 35% !important;
        padding: 4px 2px !important;
        vertical-align: middle !important;
    }

    .narrative-token-table .token-volume-mobile {
        width: 17% !important;
        padding: 0 !important;
        vertical-align: bottom !important;
        text-align: left !important;
    }

    .narrative-token-table .token-price-mobile {
        width: 10% !important;
        padding: 4px 2px !important;
        vertical-align: bottom !important;
        text-align: left !important;
    }

    .narrative-token-table .token-charts-mobile {
        width: 18% !important;
        padding: 4px 2px !important;
        vertical-align: middle !important;
    }

    .narrative-token-table .token-sentiment-social-mobile {
        width: 6% !important;
        padding: 4px 2px !important;
        vertical-align: middle !important;
    }

    .narrative-token-table thead th {
        padding: 12px 8px;
        font-size: 0.75rem;
    }

    .narrative-token-table tbody td {
        padding: 8px 6px;
    }

    .narrative-token-info {
        gap: 8px;
    }

    .narrative-token-logo {
        width: 28px;
        height: 28px;
    }

    .narrative-token-symbol {
        font-size: 0.85rem;
    }

    .narrative-token-market-cap {
        font-size: 0.7rem;
    }



    .narrative-alt-rank-indicator {
        font-size: 0.9em !important;
        margin-left: 4px;
    }

    .narrative-battery-icon {
        font-size: 1.1rem;
    }

    .narrative-volume-text {
        font-size: 0.65rem;
    }

    .narrative-token-price {
        font-size: 0.65rem !important;
    }

    /* Match top tokens widget chart sizing exactly */
    .narrative-mini-chart svg {
        width: 90px !important;
        height: 25px !important;
    }

    .narrative-sentiment-emoji {
        font-size: 1.2em;
    }

    .narrative-social-volume {
        font-size: 0.65rem;
    }

    .narrative-mini-charts {
        gap: 0px;
    }

    .narrative-chart-text {
        font-size: 9px;
    }
}

@media (max-width: 576px) {
    .narrative-token-table thead th {
        padding: 8px 4px;
        font-size: 0.7rem;
    }

    .narrative-token-table tbody td {
        padding: 6px 4px;
    }

    .narrative-token-symbol {
        font-size: 0.8rem;
    }

    .narrative-token-price {
        font-size: 0.6rem !important;
    }

    /* Match top tokens widget chart sizing on smaller mobile */
    .narrative-mini-chart svg {
        width: 90px !important;
        height: 25px !important;
    }

    .narrative-alt-rank-indicator {
        font-size: 0.8em !important;
        margin-left: 2px;
    }

    .narrative-chart-text {
        font-size: 9px;
    }
}

/* Hover Effects for Interactive Elements */
.narrative-token-table tbody tr:hover .narrative-token-logo {
    border-color: #007bff;
}

.narrative-token-table tbody tr:hover .narrative-token-symbol {
    color: #007bff;
}

.narrative-token-table tbody tr:hover .narrative-battery-icon {
    transform: scale(1.1);
}

.narrative-token-table tbody tr:hover .narrative-sentiment-emoji {
    transform: scale(1.1);
}

/* Loading States */
.narrative-token-table.loading {
    opacity: 0.7;
    pointer-events: none;
}

.narrative-token-table.loading tbody tr {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Custom Tooltip Styling for Narrative Table */
.narrative-tooltip {
    font-size: 0.8rem;
    max-width: 250px;
    text-align: left;
}

.narrative-tooltip .tooltip-inner {
    background: rgba(0, 0, 0, 0.9) !important;
    color: white !important;
    border-radius: 6px !important;
    padding: 8px 12px !important;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    .token-rank-cell.text-center {
        display: none !important;
    }

    /* Allow volume text on mobile for compact display */
    .text-muted.ms-1 {
        font-size: 0.55rem !important;
    }

    /* Hide badges on mobile */
    .badge.text-decoration-none.me-1 {
        display: none !important;
    }

    /* Make token info cell more compact on mobile - match top tokens widget */
    .token-info-cell .fw-bold {
        font-size: 0.65rem !important;
    }

    .token-info-cell .text-muted {
        font-size: 0.6rem !important;
    }

    /* Reduce token logo size on mobile - match top tokens widget */
    #tokensContainer .token-logo {
        width: 28px !important;
        height: 28px !important;
    }

    /* Make symbol text more compact - match top tokens widget exactly */
    #tokensContainer .fw-bold {
        font-size: 17px !important;
        line-height: 1.1 !important;
    }

    /* Specific styling for chart percentage text below SVGs on mobile - match top tokens */
    #tokensContainer .token-charts-mobile .fw-bold {
        font-size: 10px !important;
    }

    /* Reduce market cap font size - match top tokens widget exactly */
    #tokensContainer .text-muted {
        font-size: 10px !important;
        line-height: 1.1 !important;
    }

    /* Force small font size for mobile token prices - match top tokens widget */
    .token-price-cell,
    .token-price-cell .fw-bold,
    .token-price-cell span {
        font-size: 0.75rem !important;
    }

    /* Shrink emoji size to match market cap text - match top tokens widget */
    .token-row span[title*="performance"],
    .flex-grow-1 span[title*="performance"],
    td .flex-grow-1 span {
        font-size: 0.7rem !important;
    }

    /* Force table layout fixed for mobile token tables with custom widths */
    #tokensContainer table,
    .token-table {
        table-layout: fixed !important;
        width: 100% !important;
    }

    /* Force full width on mobile for table container and responsive wrapper */
    #tokensContainer {
        width: 100% !important;
        max-width: 100% !important;
    }

    #tokensContainer .table-responsive {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }

    /* Mobile-specific column widths for narrative token table to match top tokens */
    #tokensContainer .token-info-mobile {
        width: 35% !important;
    }

    #tokensContainer .token-volume-mobile {
        width: 17% !important;
    }

    #tokensContainer .token-price-mobile {
        width: 10% !important;
    }

    #tokensContainer .token-charts-mobile {
        width: 18% !important;
    }

    #tokensContainer .token-sentiment-mobile {
        width: 6% !important;
    }

    /* Mobile cell styling - consistent padding and alignment */
    #tokensContainer .token-info-mobile,
    #tokensContainer .token-charts-mobile,
    #tokensContainer .token-sentiment-mobile {
        padding: 4px 2px !important;
        vertical-align: middle !important;
    }

    /* Volume display formatting - left aligned */
    #tokensContainer .token-volume-mobile {
        padding: 0 !important;
        vertical-align: bottom !important;
        text-align: left !important;
    }

    /* Price mobile - align price to bottom and left */
    #tokensContainer .token-price-mobile {
        padding: 4px 2px !important;
        vertical-align: bottom !important;
        text-align: left !important;
    }

    /* Ensure full height utilization in mobile cells */
    #tokensContainer .token-info-mobile .d-flex,
    #tokensContainer .token-volume-mobile .d-flex,
    #tokensContainer .token-price-mobile .d-flex,
    #tokensContainer .token-charts-mobile .d-flex,
    #tokensContainer .token-sentiment-mobile .d-flex {
        height: 100% !important;
        min-height: 18px !important;
    }
}