/**
 * Shared Dashboard Styles
 * Common styles for BESTSELLER sales dashboards
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: #f5f7fa;
    background-image: none;
    min-height: 100vh;
    color: #1f2937;
    overflow-x: hidden;
    position: relative;
}

/* Removed distracting background animations */

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Auth Indicator Styles */
.auth-indicator {
    position: absolute;
    top: 15px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 8px 16px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.08);
    font-size: 0.875rem;
    z-index: 10;
}

.auth-user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #374151;
}

.auth-user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.auth-user-email {
    font-weight: 500;
    color: #4b5563;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auth-logout-btn {
    background: #ef4444;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.auth-logout-btn:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.auth-logout-btn:active {
    transform: translateY(0);
}

/* Mobile responsive auth indicator */
@media (max-width: 768px) {
    .auth-indicator {
        position: relative;
        top: auto;
        right: auto;
        margin: 0 auto 16px auto;
        width: fit-content;
        justify-content: center;
    }

    .auth-user-email {
        max-width: 120px;
    }
}

@media (max-width: 480px) {
    .auth-indicator {
        flex-direction: column;
        gap: 8px;
        padding: 12px;
        text-align: center;
    }

    .auth-user-info {
        justify-content: center;
    }

    .auth-user-email {
        max-width: none;
    }
}

/* Header Styles */
.header {
    background: #ffffff;
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.05),
        0 2px 4px -1px rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(229, 231, 235, 0.5);
    position: relative;
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    text-align: center;
}

.header:hover {
    transform: translateY(-2px);
    box-shadow:
        0 15px 35px rgba(0, 0, 0, 0.12),
        0 0 0 1px rgba(102, 126, 234, 0.1);
}

.header-logo {
    height: 80px;
    width: auto;
    margin-bottom: 20px;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.1));
}

.header h1 {
    font-size: 2.25rem;
    font-weight: 700;
    color: #111827;
    background: none;
    -webkit-text-fill-color: initial;
    margin-bottom: 8px;
    letter-spacing: -0.025em;
}

.header p {
    color: #666;
    font-size: 1.1rem;
    margin: 0;
}

/* Removed floating keyframe animations for better performance */

/* Mobile responsive styles */
@media (max-width: 768px) {
    .container {
        padding: 15px !important;
        max-width: 100% !important;
    }

    .header {
        padding: 25px 20px;
    }

    .header-logo {
        height: 60px;
        margin-bottom: 15px;
    }

    .header h1 {
        font-size: 2rem;
    }

    .header p {
        font-size: 1rem;
    }

    /* Removed floating card animations for better performance */

    /* Mobile responsive chart containers */
    .chart-container,
    .trend-chart-container {
        margin: 15px 0 !important;
        padding: 15px !important;
        border-radius: 16px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .trend-header {
        margin-bottom: 15px !important;
        flex-direction: column !important;
        align-items: flex-start !important;
    }

    .trend-header h3.chart-title {
        font-size: 1.1rem !important;
        margin-bottom: 8px !important;
        margin-right: 0 !important;
    }

    .trend-header #trendChartSummary {
        font-size: 0.8em !important;
        text-align: left !important;
        margin-left: 0 !important;
    }

    #trendAvgDaily {
        margin-bottom: 1px !important;
    }

    /* Mobile table scrolling */
    .chart-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .chart-container table {
        min-width: 600px;
        /* Ensure tables don't compress too much */
        font-size: 0.9em;
    }

    .chart-container th,
    .chart-container td {
        padding: 12px 10px !important;
        white-space: nowrap;
        min-width: 80px;
    }

    .chart-container th {
        font-size: 0.8em !important;
    }

    /* Mobile list items */
    .list-item {
        font-size: 0.9em !important;
        padding: 10px 0 !important;
    }

    .item-name {
        font-size: 0.9em !important;
        font-weight: 600 !important;
    }

    .item-details {
        font-size: 0.75em !important;
        margin-top: 2px !important;
    }

    .item-value {
        font-size: 0.9em !important;
        font-weight: 600 !important;
    }
}

/* Date Controls */
.date-controls {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 20px;
}

.date-control {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.date-control label {
    font-weight: 600;
    color: #555;
}

.date-control input,
.date-control button {
    padding: 12px 20px;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.3s ease;
}

.date-control input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn {
    background-color: #6b7280;
    /* Grey 500 */
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 8px;
    padding: 10px 20px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn:hover {
    background-color: #f97316;
    /* Orange 500 */
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(249, 115, 22, 0.3), 0 2px 4px -1px rgba(249, 115, 22, 0.1);
}

.btn:active {
    transform: translateY(0);
    background-color: #ea580c;
    /* Orange 600 */
}

/* Grid Layouts */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
    min-height: 200px;
    /* Prevent layout shift */
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
    min-height: 350px;
    /* Prevent layout shift */
}

.top-lists {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
    min-height: 400px;
    /* Prevent layout shift */
}

/* Enhanced Card Components with Glassmorphism */
/* Enhanced Card Components with Clean Design */
.stat-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.05),
        0 2px 4px -1px rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(229, 231, 235, 0.5);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    cursor: pointer;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow:
        0 10px 15px -3px rgba(0, 0, 0, 0.08),
        0 4px 6px -2px rgba(0, 0, 0, 0.04);
    border-color: rgba(229, 231, 235, 0.8);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Removed .stat-card:hover animations for better performance */

.stat-card:active {
    transform: translateY(-6px) scale(1.01);
    transition: all 0.1s ease;
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 700;
    color: #111827;
    background: none;
    -webkit-text-fill-color: initial;
    margin-bottom: 8px;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.025em;
}

/* Dynamically sized font for large values - keeps on single line */
.stat-value.large-value {
    font-size: 1.8rem;
    line-height: 1.2;
}

.stat-value.extra-large-value {
    font-size: 1.4rem;
    line-height: 1.2;
}

.stat-value.huge-value {
    font-size: 1.1rem;
    line-height: 1.2;
}

.stat-label {
    color: #6b7280;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.percentage-change {
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 8px;
    padding: 4px 10px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.positive-change {
    background-color: #dcfce7;
    /* Green 100 */
    color: #166534;
    /* Green 800 */
}

.negative-change {
    background-color: #fee2e2;
    /* Red 100 */
    color: #991b1b;
    /* Red 800 */
}

/* Enhanced Chart Containers */
/* Enhanced Chart Containers */
.chart-container {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.05),
        0 2px 4px -1px rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(229, 231, 235, 0.5);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    min-height: 400px;
    /* Prevent layout shift */
    contain: layout;
    /* Contain layout changes */
}

.chart-container:hover {
    box-shadow:
        0 10px 15px -3px rgba(0, 0, 0, 0.08),
        0 4px 6px -2px rgba(0, 0, 0, 0.04);
}

/* Removed .chart-container:hover animations for better performance */

/* Tables inside chart containers */
.chart-container table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.chart-container th,
.chart-container td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.chart-container th {
    background: #f3f4f6;
    color: #374151;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
}

.chart-container tr:hover {
    background-color: rgba(102, 126, 234, 0.05);
}

.chart-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: #333;
}

/* Container spacing */
#salesByQarkContainer,
#assignedUserTableContainer,
#salesTableContainer {
    margin-bottom: 30px;
    min-height: 300px;
    /* Prevent layout shift */
}

/* Full-width mode for sales table */
#salesTableContainer.full-width {
    max-width: none;
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    padding-left: 20px;
    padding-right: 20px;
}

#salesTableContainer.full-width .data-table {
    max-width: none;
    width: 100%;
    overflow-x: visible;
}

#salesTableContainer.full-width table {
    font-size: 0.9rem;
    table-layout: fixed;
    width: 100%;
}

#salesTableContainer.full-width th,
#salesTableContainer.full-width td {
    padding: 12px 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* First column (category name) wider in full-width mode */
#salesTableContainer.full-width th:first-child,
#salesTableContainer.full-width td:first-child {
    width: 15%;
    min-width: 120px;
}

/* Allow text to wrap in percentage change columns */
#salesTableContainer.full-width td:nth-child(4),
#salesTableContainer.full-width td:nth-child(7) {
    white-space: normal;
    word-wrap: break-word;
}

/* Toggle button for full-width mode */
.table-width-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: 16px;
    padding: 8px 16px;
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    color: #667eea;
    font-weight: 500;
}

.table-width-toggle:hover {
    background: rgba(102, 126, 234, 0.2);
    border-color: rgba(102, 126, 234, 0.5);
    transform: translateY(-1px);
}

.table-width-toggle:active {
    transform: translateY(0);
}

.table-width-toggle-icon {
    font-size: 1.1rem;
    line-height: 1;
}

/* Trend chart container specific sizing */
.trend-chart-container {
    min-height: 450px;
    /* Prevent layout shift for 7-day trend */
}

/* Table Styles - Now uses chart-container class, keeping this for any remaining data-table usage */
.data-table {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 24px;
    padding: 30px;
    margin-bottom: 0;
    box-shadow:
        0 12px 35px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    position: relative;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

th,
td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background: #f3f4f6;
    color: #374151;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
}

tr:hover {
    background-color: rgba(102, 126, 234, 0.05);
}

/* Top Lists - Now uses chart-container class, keeping this for any remaining top-list usage */
.top-list {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.05),
        0 2px 4px -1px rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(229, 231, 235, 0.5);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.top-list:hover {
    box-shadow:
        0 10px 15px -3px rgba(0, 0, 0, 0.08),
        0 4px 6px -2px rgba(0, 0, 0, 0.04);
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}

.list-item:last-child {
    border-bottom: none;
}

.rank {
    background: #e5e7eb;
    color: #374151;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.8rem;
    margin-right: 15px;
}

.item-info {
    flex: 1;
    margin-left: 10px;
}

.item-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 2px;
}

.item-details {
    font-size: 0.85rem;
    color: #666;
}

.item-value {
    font-weight: 600;
    color: #4b5563;
}

/* Loading and Error States */
.loading {
    display: none;
    text-align: center;
    padding: 40px;
    color: #666;
}

.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 25px;
    position: relative;
}

.spinner::before,
.spinner::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: #f97316;
    /* Orange 500 */
    opacity: 0.6;
    animation: pulse-ripple 2s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}

.spinner::after {
    animation-delay: -1s;
}

@keyframes pulse-ripple {
    0% {
        top: 48%;
        left: 48%;
        width: 4%;
        height: 4%;
        opacity: 1;
    }

    100% {
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        opacity: 0;
    }
}

/* Modern entrance animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Apply entrance animations */
.stat-card {
    animation: fadeInUp 0.6s ease-out;
    animation-fill-mode: both;
}

.stat-card:nth-child(1) {
    animation-delay: 0.1s;
}

.stat-card:nth-child(2) {
    animation-delay: 0.2s;
}

.stat-card:nth-child(3) {
    animation-delay: 0.3s;
}

.stat-card:nth-child(4) {
    animation-delay: 0.4s;
}

.stat-card:nth-child(5) {
    animation-delay: 0.5s;
}

.stat-card:nth-child(6) {
    animation-delay: 0.6s;
}

.stat-card:nth-child(7) {
    animation-delay: 0.7s;
}

.stat-card:nth-child(8) {
    animation-delay: 0.8s;
}

.chart-container {
    animation: fadeInScale 0.8s ease-out;
    animation-fill-mode: both;
    animation-delay: 0.3s;
}

.data-table {
    animation: slideInRight 0.7s ease-out;
    animation-fill-mode: both;
    animation-delay: 0.5s;
}

.header {
    animation: fadeInUp 0.8s ease-out;
    animation-fill-mode: both;
}

.error {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: white;
    padding: 20px;
    border-radius: 12px;
    margin: 20px 0;
    display: none;
}

/* 3D Map Container */
#map3DContainer {
    width: 100%;
    height: 600px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#map3DCanvas {
    display: block;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .charts-grid {
        grid-template-columns: 1fr;
        gap: 20px;
        margin: 0;
        padding: 0;
    }

    .date-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .header h1 {
        font-size: 2rem;
    }

    .chart-container {
        padding: 15px;
        margin: 15px 0;
        border-radius: 16px;
        width: 100%;
        box-sizing: border-box;
    }

    .stats-grid,
    .top-lists {
        grid-template-columns: 1fr;
        gap: 20px;
        margin: 0;
        padding: 0;
    }

    .stat-card,
    .top-list,
    .data-table {
        padding: 20px;
        border-radius: 20px;
    }

    .date-control input,
    .date-control button {
        padding: 10px 15px;
        font-size: 14px;
    }

    table th,
    table td {
        padding: 10px;
        font-size: 0.9rem;
    }
}

@media (min-width: 769px) {
    .charts-grid .chart-container {
        max-width: none;
        margin: 0;
    }
}