/* Apple-inspired design system */
:root {
    --bg-primary: #F8F9FB;
    --bg-secondary: rgba(255, 255, 255, 0.8);
    --text-primary: #1D1D1F;
    --text-secondary: #86868B;
    --accent-blue: #007AFF;
    --accent-hover: #0056CC;
    --border-light: rgba(0, 0, 0, 0.1);
    --shadow-light: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-medium: 0 8px 40px rgba(0, 0, 0, 0.12);
    --blur-bg: blur(20px);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
    background: var(--bg-primary);
    background-image: radial-gradient(circle at 50% 50%, rgba(0, 122, 255, 0.03) 0%, transparent 50%);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    font-weight: 400;
    letter-spacing: -0.01em;
}

/* Top Navigation */
.nav-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: var(--blur-bg);
    background: rgba(248, 249, 251, 0.8);
    border-bottom: 1px solid var(--border-light);
}

.nav-brand {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.search-container {
    position: relative;
    flex: 0 0 400px;
    max-width: 400px;
}

.search-input {
    width: 100%;
    padding: 12px 20px 12px 44px;
    border: 1px solid var(--border-light);
    border-radius: 20px;
    background: var(--bg-secondary);
    backdrop-filter: var(--blur-bg);
    font-size: 16px;
    font-weight: 400;
    color: var(--text-primary);
    outline: none;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.search-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
    background: rgba(255, 255, 255, 0.95);
}

.search-input::placeholder {
    color: var(--text-secondary);
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    opacity: 0.6;
}

.nav-avatar {
    width: 36px;
    height: 36px;
    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: 14px;
}

/* 3D Canvas Container */
.canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Company Info Card */
.analytics-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 48px;
    height: 48px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    z-index: 1000;
    color: #374151;
}

.analytics-button:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.analytics-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.25);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
}

.analytics-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.analytics-card {
    position: relative;
    width: calc(100% - 32px);
    max-width: 1200px;
    height: calc(100vh - 64px);
    max-height: 90vh;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
    overflow: hidden;
    display: grid;
    grid-template-rows: auto 1fr;
}

.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.analytics-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: #1f2937;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
}

.analytics-body {
    padding-block: 4px;
    overflow: hidden;
}

.analytics-content {
    overflow-y: auto;
    padding: 24px 32px 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: 100%;
}

.analytics-close {
    height: 32px;
    width: 32px;
    border-radius: 999px;
    /*background: rgba(255, 255, 255, 0.96);*/
    /*box-shadow: 0 4px 10px rgba(15, 23, 42, 0.16);*/
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    color: #666;
    z-index: 1001;
    border: none;
}

.analytics-close:hover {
    background: rgba(255, 255, 255, 1);
    color: #333;
    transform: scale(1.05);
}

.analytics-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Row 1: KPI Cards */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.analytics-card-inner {
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.06);
    padding: 16px 18px 18px;
}

.kpi-tile {
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.06);
    padding: 20px;
    text-align: start;
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 6px;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
}

.kpi-label {
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
}

/* Row 2: Charts */
.charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 16px;
    align-items: stretch;
    grid-auto-rows: 450px;
}

.chart-container {
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.06);
    padding: 16px 18px 18px;
    display: flex;
    flex-direction: column;
    min-height: 320px;
}

.chart-title {
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 12px;
    text-align: start;
}

.chart-canvas {
    flex: 1;
    min-height: 0;
}

/* Row 3: World Map */
.bottom-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    align-items: stretch;
}

.bottom-row-fill {
    display: grid;
    grid-template-columns: 1fr;
    grid-auto-rows: 350px;
}

.world-map-container {
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.06);
    padding: 16px 18px 18px;
    display: flex;
    flex-direction: column;
    min-height: 400px;
}

.world-map {
    flex: 1;
    min-height: 0;
    background: #f8fafc;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    font-size: 14px;
    position: relative;
    overflow: hidden;
}

.country-dot {
    position: absolute;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    transition: all 0.2s ease;
}

.country-dot:hover {
    transform: scale(1.2);
    background: #1d4ed8;
}

.map-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.top-companies {
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.06);
    padding: 16px 18px 18px;
    display: flex;
    flex-direction: column;
}

.top-companies-body {
    margin-top: 8px;
    max-height: 260px;
    overflow-y: auto;
}

.top-company-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    cursor: pointer;
    border-radius: 6px;
    margin-bottom: 2px;
}

.top-company-item:hover {
    background: rgba(59, 130, 246, 0.1);
}

.top-company-name {
    font-weight: 500;
    color: #1f2937;
    font-size: 13px;
}

.top-company-score {
    font-weight: 700;
    color: #3b82f6;
    font-size: 13px;
}

/* Row 4: Company Table */
.company-table {
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.06);
    padding: 16px 18px 18px;
    display: flex;
    flex-direction: column;
    /*min-height: 300px;*/
    max-height: 500px;
    height: 100%;
}

.table-container {
    flex: 1;
    overflow-y: auto;
    /*min-height: 0;*/
    margin-top: 8px;
}

.company-table table {
    width: 100%;
    border-collapse: collapse;
}

.company-table th,
.company-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    font-size: 13px;
}

.company-table th {
    background: rgba(0, 0, 0, 0.04);
    font-weight: 600;
    color: #374151;
    position: sticky;
    top: 0;
    white-space: nowrap;
}

.company-table tr:hover {
    background: rgba(59, 130, 246, 0.08);
    cursor: pointer;
}

.tag-pill {
    display: inline-block;
    background: #e5e7eb;
    color: #374151;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    margin-right: 3px;
    margin-bottom: 1px;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .kpi-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .charts-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .map-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .kpi-row {
        grid-template-columns: 1fr;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }
}

.chart-container h3 {
    margin: 0 0 20px 0;
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}

.table-container {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    /*padding: 24px;*/
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.table-container h3 {
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
}

.table-wrapper {
    overflow-x: auto;
    max-height: 700px;
    overflow-y: auto;
}

#companyTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

#companyTable th {
    background: #f9fafb;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    white-space: nowrap;
}

#companyTable td {
    padding: 12px;
    border-bottom: 1px solid #f3f4f6;
    color: #1f2937;
}

#companyTable tr:hover {
    background: rgba(59, 130, 246, 0.05);
    cursor: pointer;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tag {
    background: #e5e7eb;
    color: #374151;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

#topCompanies {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.top-company {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.top-company:hover {
    background: rgba(59, 130, 246, 0.1);
}

.top-company-name {
    font-weight: 600;
    color: #1f2937;
}

.top-company-score {
    font-weight: 700;
    color: #3b82f6;
}

.hidden {
    display: none !important;
}

.info-card {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    width: 480px;
    max-width: calc(100vw - 80px);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: var(--blur-bg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 32px;
    box-shadow: var(--shadow-medium);
    z-index: 100;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: none;
}

.info-card.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    display: block;
}

.info-card-header {
    position: relative;
    margin-bottom: 20px;
}

.close-button {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
    color: var(--text-secondary);
}

.close-button:hover {
    background: rgba(0, 0, 0, 0.15);
    color: var(--text-primary);
    transform: scale(1.1);
}

.company-name {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.company-score {
    display: inline-flex;
    align-items: center;
    background: var(--accent-blue);
    color: white;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 20px;
}

.company-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.detail-item {
    display: flex;
    flex-direction: column;
}

.detail-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.detail-value {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
}

.company-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.tag {
    background: rgba(0, 122, 255, 0.1);
    color: var(--accent-blue);
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
}

.company-note {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Loading State */
.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2000;
    text-align: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-light);
    border-top: 3px solid var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.loading-text {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 500;
}


/* Responsive Design */
@media (max-width: 768px) {
    .nav-container {
        padding: 16px 20px;
        flex-direction: column;
        gap: 16px;
    }

    .search-container {
        flex: 1;
        max-width: none;
    }

    .info-card {
        width: calc(100vw - 40px);
        padding: 24px;
        bottom: 20px;
    }

    .company-details {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

/* Smooth transitions for all interactive elements */
* {
    transition: opacity 0.2s ease, transform 0.2s ease;
}
