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

/* Replace existing color variables or add these at the top */
:root {
    --primary-color: #2c5282; /* Deep blue */
    --secondary-color: #3182ce; /* Medium blue */
    --accent-color: #63b3ed; /* Light blue */
    --neutral-dark: #2d3748; /* Dark slate */
    --neutral-medium: #4a5568; /* Medium slate */
    --neutral-light: #e2e8f0; /* Light gray */
    --background-color: #f7fafc; /* Off-white */
    --success-color: #38a169; /* Green */
    --warning-color: #d69e2e; /* Amber */
    --danger-color: #e53e3e; /* Red */
    --text-dark: #1a202c; /* Near black */
    --text-medium: #4a5568; /* Dark gray */
    --text-light: #718096; /* Medium gray */
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--background-color);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    margin-bottom: 10px;
    color: var(--primary-color);
    font-size: 2rem;
}

header p {
    font-size: 1rem;
    color: var(--text-medium);
}

/* Enhanced Header */
.header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.logo h1 {
    margin-bottom: 5px;
}

.tagline {
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
}

.header-controls {
    display: flex;
    gap: 20px;
    align-items: center;
}

.global-search {
    position: relative;
    display: flex;
    align-items: center;
}

.global-search input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    width: 250px;
    font-size: 14px;
}

.global-search button {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.action-button {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 16px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.action-button:hover {
    background-color: var(--secondary-color);
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 300px;
    overflow-y: auto;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    z-index: 1000;
    padding: 10px;
}

.search-dropdown.visible {
    display: block;
}

.search-dropdown.hidden {
    display: none;
}

.search-result-item {
    padding: 8px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.search-result-item:hover {
    background-color: #f5f5f5;
}

.search-no-results {
    padding: 15px;
    text-align: center;
    color: #666;
}

.search-error {
    padding: 15px;
    text-align: center;
    color: #e74c3c;
}

/* Map container styles */
#map-container {
    position: relative;
    width: 100%;
    height: 60vh;
    min-height: 300px;
    margin: 0 auto;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
}

/* Country styles */
.country {
    stroke: #fff;
    stroke-width: 0.5px;
    transition: fill 0.3s ease;
}

.country:hover {
    stroke-width: 1px;
    stroke: #000;
    cursor: pointer;
    opacity: 0.9;
}

/* Tooltip styles */
#tooltip {
    position: absolute;
    display: none;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.95);
    border: 1px solid #ddd;
    border-radius: 4px;
    pointer-events: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
    max-width: 300px;
    z-index: 1000;
    font-size: 0.9rem;
}

#tooltip h3 {
    margin-bottom: 5px;
    color: #2c3e50;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
    font-size: 1.1rem;
}

#tariff-info {
    font-size: 0.9rem;
}

.tariff-item {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px dashed #eee;
}

.tariff-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.tariff-rate {
    font-weight: bold;
    color: black;
}

.tariff-date {
    color: #7f8c8d;
    font-size: 0.8rem;
}

/* Data table styles */
#table-container {
    margin-top: 30px;
    width: 100%;
    overflow-x: auto;
    border-radius: 5px;
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    display: flexbox;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th {
    background-color: var(--primary-color);
    color: white;
    padding: 12px 15px;
    text-align: left;
    position: sticky;
    top: 0;
}

.data-table td {
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
}

.data-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.data-table tr:hover {
    background-color: #f1f1f1;
}

.data-table .rate-cell {
    font-weight: bold;
    color: black;
}

/* Search and filter controls */
.table-controls {
    margin-bottom: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.search-box {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    flex-grow: 1;
    min-width: 200px;
}

.sort-select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
}

/* Tabs for switching between map and table */
.tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 1px solid #ddd;
}

.tab {
    padding: 10px 20px;
    cursor: pointer;
    background-color: var(--neutral-light);
    border: 1px solid #ddd;
    border-bottom: none;
    border-radius: 5px 5px 0 0;
    margin-right: 5px;
    color: var(--text-medium);
}

.tab.active {
    background-color: white;
    border-bottom: 1px solid white;
    margin-bottom: -1px;
    font-weight: bold;
    color: var(--primary-color);
}

.tab-content {
    display: none;
    padding: 15px 0;
    min-height: 200px;
}

.tab-content.active {
    display: block !important;
}

/* Timeline View Styles */
.timeline-controls {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.date-range-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.date-range-selector input[type="date"] {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.timeline-container {
    width: 100%;
    height: 300px;
    border: 1px solid #ddd;
    border-radius: 5px;
    position: relative;
    background-color: white;
    margin-bottom: 20px;
    overflow-x: auto;
}

.timeline-scale {
    height: 40px;
    border-bottom: 1px solid #ddd;
    position: relative;
}

.timeline-markers {
    display: flex;
    height: 100%;
}

.timeline-events {
    padding: 20px;
    position: relative;
    min-height: 240px;
}

.timeline-event {
    position: absolute;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timeline-event:hover {
    z-index: 10;
    transform: scale(1.05);
}

.timeline-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
}

.legend-color {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 3px;
}

/* Analytics View Styles */
#charts-view {
    padding: 20px 0;
}

/* Analytics filter controls */
.filters-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.analytics-select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    min-width: 150px;
    font-size: 14px;
}

.filter-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Stats display */
.stats-row {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.stat-box {
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    flex: 1;
    min-width: 120px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.stat-title {
    font-size: 0.9rem;
    color: #718096;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

/* Country comparison styles */
.comparison-controls {
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 20px;
}

.country-selector label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    color: var(--text-medium);
}

.country-search {
    position: relative;
    margin-bottom: 15px;
}

#country-search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.country-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    background-color: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    z-index: 100;
}

.search-result-item {
    padding: 8px 12px;
    cursor: pointer;
}

.search-result-item:hover {
    background-color: #f1f1f1;
}

.no-results {
    padding: 8px 12px;
    color: #888;
    font-style: italic;
}

.selected-countries {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.country-tag {
    background-color: #e2e8f0;
    border-radius: 16px;
    padding: 4px 12px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.remove-country {
    cursor: pointer;
    display: inline-block;
    width: 16px;
    height: 16px;
    text-align: center;
    line-height: 16px;
    border-radius: 50%;
    background-color: rgba(0,0,0,0.1);
    font-weight: bold;
}

.remove-country:hover {
    background-color: rgba(0,0,0,0.2);
}

.no-data-message {
    text-align: center;
    padding: 40px;
    color: #666;
    font-style: italic;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .filters-row {
        flex-direction: column;
    }
    
    .filter-options {
        flex-direction: column;
    }
    
    .analytics-select, 
    #download-chart {
        width: 100%;
    }
    
    .stat-box {
        padding: 10px;
        min-width: 100px;
    }
    
    .stat-title {
        font-size: 0.8rem;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
    
    .filters-row {
        flex-direction: column;
    }
    
    .filter-options {
        flex-direction: column;
    }
    
    .analytics-select, 
    #download-chart {
        width: 100%;
    }
    
    .stat-box {
        padding: 10px;
        min-width: 100px;
    }
    
    .stat-title {
        font-size: 0.8rem;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
    
    .country-active {
        stroke: #000;
        stroke-width: 2px;
        opacity: 0.8;
    }
    
    /* Make tooltip more visible on mobile */
    .mobile-tooltip {
        background-color: #fff;
        padding: 16px;
        animation: slideUp 0.3s ease-out;
    }
    
    @keyframes slideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }
    
    .header-main {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .header-controls {
        width: 100%;
        flex-direction: column;
        margin-top: 15px;
    }
    
    .global-search {
        width: 100%;
    }
    
    .global-search input {
        width: 100%;
    }
    
    .header-actions {
        width: 100%;
        justify-content: space-between;
        margin-top: 10px;
    }
    
    .timeline-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .date-range-selector {
        flex-wrap: wrap;
    }
    
    #chart-container {
        height: 300px;
    }
}

/* Loading indicator */
.loading-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0,0,0,0.1);
    border-radius: 50%;
    border-top: 4px solid var(--primary-color);
    animation: spin 1s linear infinite;
}

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

/* Footer styles */
footer {
    margin-top: 30px;
    text-align: center;
    font-size: 0.9rem;
    color: #7f8c8d;
    padding: 20px 0;
    border-top: 1px solid #eee;
}

/* Ad container styles */
.ad-container {
    width: 100%;
    margin: 20px 0;
    text-align: center;
    overflow: hidden;
    clear: both;
}

/* Responsive styles */
@media (max-width: 992px) {
    .container {
        padding: 15px;
    }
    
    #map-container {
        height: 50vh;
    }
    
    .data-table {
        font-size: 0.85rem;
    }
    
    .data-table th, .data-table td {
        padding: 10px;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }
    
    #map-container {
        height: 45vh;
    }
    
    .tab {
        padding: 12px 20px;
        min-width: 100px; /* Ensure tabs have sufficient width */
        font-size: 0.9rem;
    }
    
    .data-table {
        font-size: 0.8rem;
    }
    
    .data-table th, .data-table td {
        padding: 12px 8px;
    }
    
    .table-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box, .sort-select {
        width: 100%;
        padding: 12px 15px;
        height: 48px; /* Standard minimum touch target height */
        font-size: 16px; /* Prevent iOS zoom on input */
    }
    
    /* Prevent text from being too small */
    body {
        font-size: 16px;
    }
    
    .country-active {
        stroke: #000;
        stroke-width: 2px;
        opacity: 0.8;
    }
    
    /* Make tooltip more visible on mobile */
    .mobile-tooltip {
        background-color: #fff;
        padding: 16px;
        animation: slideUp 0.3s ease-out;
    }
    
    @keyframes slideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }
    
    .header-main {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .header-controls {
        width: 100%;
        flex-direction: column;
        margin-top: 15px;
    }
    
    .global-search {
        width: 100%;
    }
    
    .global-search input {
        width: 100%;
    }
    
    .header-actions {
        width: 100%;
        justify-content: space-between;
        margin-top: 10px;
    }
    
    .timeline-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .date-range-selector {
        flex-wrap: wrap;
    }
    
    #chart-container {
        height: 300px;
    }
}

@media (max-width: 576px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    header p {
        font-size: 0.9rem;
    }
    
    #map-container {
        height: 40vh;
        min-height: 250px;
    }
    
    #tooltip {
        max-width: 250px;
        font-size: 0.8rem;
    }
    
    #tooltip h3 {
        font-size: 1rem;
    }
    
    .tab {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
    
    .data-table {
        font-size: 0.75rem;
    }
    
    .data-table th, .data-table td {
        padding: 6px;
    }
}

/* Touch-friendly adjustments for mobile */
@media (hover: none) {
    .country:hover {
        opacity: 1; /* Disable hover effect on touch devices */
    }
    
    .data-table tr:hover {
        background-color: inherit; /* Disable hover effect on touch devices */
    }
    
    .tab {
        padding: 12px 20px; /* Larger touch target */
    }
    
    .search-box, .sort-select {
        padding: 10px 15px; /* Larger touch target */
    }
}

/* Mobile card view for table data */
.mobile-card-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    padding: 10px;
}

.tariff-card {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 15px;
    transition: transform 0.2s;
}

.tariff-card:active {
    transform: scale(0.98);
}

.tariff-card h3 {
    margin: 0 0 10px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
    font-size: 1.2rem;
}

.card-rate {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 10px;
}

.card-details {
    font-size: 0.9rem;
}

.card-details div {
    margin-bottom: 5px;
}

/* Mobile tooltip improvements */
.mobile-tooltip {
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-radius: 12px 12px 0 0 !important;
}

.close-tooltip {
    display: block;
    width: 100%;
    padding: 10px;
    margin-top: 15px;
    border: none;
    background-color: #2c3e50;
    color: white;
    font-weight: bold;
    border-radius: 5px;
    font-size: 16px;
}

/* Desktop-specific tooltip styles */
@media (min-width: 769px) {
    #tooltip {
        max-height: 400px;
        overflow-y: auto;
        pointer-events: auto; /* Allow scrolling */
        background-color: rgba(255, 255, 255, 0.95);
        border: 1px solid #ddd;
        box-shadow: 0 2px 4px rgba(0,0,0,0.2);
        padding: 15px;
        font-size: 0.9rem;
        line-height: 1.4;
        border-radius: 4px;
        z-index: 1000;
        scrollbar-width: thin; /* Firefox */
    }
    
    /* Custom scrollbar for webkit browsers */
    #tooltip::-webkit-scrollbar {
        width: 6px;
    }
    
    #tooltip::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 3px;
    }
    
    #tooltip::-webkit-scrollbar-thumb {
        background: #bbb;
        border-radius: 3px;
    }
    
    #tooltip::-webkit-scrollbar-thumb:hover {
        background: #999;
    }
    
    /* Other tooltip styles remain the same */
    #tooltip h3 {
        font-size: 1rem;
        margin-bottom: 8px;
        padding-bottom: 6px;
    }
    
    .tariff-item {
        margin-bottom: 8px;
        padding-bottom: 8px;
    }
    
    .tariff-date {
        margin-top: 3px;
    }
}
