/* MapRates Pro - Professional Styles */

:root {
    /* Primary Brand Colors - Professional Blue Palette */
    --primary-blue: #1a73e8;
    --primary-blue-light: #4285f4;
    --primary-blue-dark: #1557b0;
    
    /* Neutral Colors - Clean & Professional */
    --white: #ffffff;
    --gray-50: #f8f9fa;
    --gray-100: #f1f3f4;
    --gray-200: #e8eaed;
    --gray-300: #dadce0;
    --gray-400: #bdc1c6;
    --gray-500: #9aa0a6;
    --gray-600: #80868b;
    --gray-700: #5f6368;
    --gray-800: #3c4043;
    --gray-900: #202124;
    
    /* Accent Colors */
    --success-green: #137333;
    --success-green-light: #34a853;
    --warning-orange: #f29900;
    --error-red: #d93025;
    
    /* Semantic Colors */
    --text-primary: var(--gray-900);
    --text-secondary: var(--gray-700);
    --text-tertiary: var(--gray-500);
    --border-light: var(--gray-200);
    --border-medium: var(--gray-300);
    --surface-primary: var(--white);
    --surface-secondary: var(--gray-50);
    
    /* Shadows & Effects */
    --shadow-sm: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
    --shadow-md: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 2px 6px 2px rgba(60, 64, 67, 0.15);
    --shadow-lg: 0 2px 4px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15);
    --shadow-xl: 0 4px 8px 0 rgba(60, 64, 67, 0.3), 0 6px 20px 4px rgba(60, 64, 67, 0.15);
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    /* Typography */
    --font-heading: 'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
}

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

body {
    font-family: var(--font-body);
    background: #f7f9fc;
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

/* Header Section */
.header {
    text-align: center;
    margin-bottom: 32px;
    padding: 48px 0 32px 0;
}
/* Push header content to avoid overlap */
.header h1, 
.app-title,
h1:has(+ .layer-switcher-container) {
    margin-top: 60px !important; /* Push down below layer switcher */
}

/* Or move the layer switcher to the right of the title */
.layer-switcher-container.standalone {
    position: absolute !important;
    top: 20px !important;
    right: 20px !important;
    left: auto !important;
}
.header h1 {
    font-family: var(--font-heading);
    font-size: 2.75rem;
    font-weight: 400;
    color: var(--text-primary);
    margin-bottom: 12px;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.header h1 img {
    width: 48px;
    height: 48px;
}

.header p {
    font-size: 1.125rem;
    color: var(--text-secondary);
    font-weight: 400;
    max-width: 600px;
    margin: 0 auto;
}

/* Main App Container */
.app-container {
    background: var(--surface-primary);
    border-radius: var(--radius-xl);
    box-shadow: 0 8px 32px rgba(60, 64, 67, 0.2);
    overflow: hidden;
    border: 2px solid var(--border-medium);
}

/* Compact Header */
.compact-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    background: linear-gradient(135deg, var(--surface-primary), var(--surface-secondary));
    border-bottom: 3px solid var(--primary-blue);
    box-shadow: 0 2px 8px rgba(26, 115, 232, 0.1);
    flex-wrap: nowrap;
    gap: 24px;
    min-height: 70px;
}

.currency-flow {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-width: 340px;
}

.currency-flow select {
    padding: 8px 12px;
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    background: var(--surface-primary);
    font-size: 0.875rem;
    font-weight: 500;
    min-width: 120px;
}

.flow-arrow {
    font-size: 1.2rem;
    color: var(--text-secondary);
    font-weight: bold;
}

.live-rate-display {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--success-green);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-family: var(--font-mono);
    font-size: 1rem;
    box-shadow: var(--shadow-sm);
}

.live-rate-display input {
    width: 100px;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    padding: 4px 8px;
    color: white;
    font-weight: bold;
    text-align: center;
    font-size: 0.9rem;
}

.quick-actions {
    display: flex;
    gap: 12px;
}

.action-btn {
    background: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.action-btn:hover {
    background: var(--primary-blue-dark);
    transform: translateY(-1px);
}

.action-btn.secondary {
    background: var(--surface-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-medium);
}

/* Map Container */
.map-container-primary {
    padding: 0;
    background: var(--surface-primary);
    min-height: 500px;
}

.map-container-primary h2 {
    text-align: center;
    padding: 20px 0 10px 0;
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-secondary);
}

#worldMap {
    background: var(--white);
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 16px rgba(60, 64, 67, 0.15);
    display: block;
    margin: 0 auto;
    max-width: 100%;
    width: 100%;
    height: auto;
}

.country {
    fill: #e8f0fe;
    stroke: var(--primary-blue);
    stroke-width: 0.5;
    cursor: pointer;
    transition: all 0.2s ease;
}

.country:hover {
    fill: #fff9c4;
    stroke: #f9a825;
    stroke-width: 1.5;
    transition: all 0.2s ease;
}

.country.selected-home,
.country.selected-home:hover {
    fill: var(--success-green) !important;
    stroke: var(--success-green) !important;
    stroke-width: 1.5 !important;
}

.country.selected-destination,
.country.selected-destination:hover {
    fill: var(--primary-blue) !important;
    stroke: var(--primary-blue-dark) !important;
    stroke-width: 1.5 !important;
}

/* Map Status */
.map-status {
    background: var(--surface-secondary);
    border: 1px solid var(--primary-blue);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 24px;
    text-align: center;
    font-weight: 500;
    color: var(--primary-blue);
    font-size: 0.875rem;
}

.map-status.locked {
    background: #fef7f0;
    border-color: var(--warning-orange);
    color: #b06000;
}

/* Buttons */
.add-destination-btn {
    background: var(--primary-blue);
    color: var(--white);
    border: none;
    border-radius: var(--radius-md);
    padding: 12px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-body);
    box-shadow: var(--shadow-sm);
}

.add-destination-btn:hover {
    background: var(--primary-blue-dark);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.add-destination-btn:disabled {
    background: var(--gray-300);
    color: var(--gray-500);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.reset-destinations-btn {
    background: var(--surface-primary);
    color: var(--error-red);
    border: 1px solid var(--error-red);
    border-radius: var(--radius-md);
    padding: 12px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-body);
}

.reset-destinations-btn:hover {
    background: var(--error-red);
    color: var(--white);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.swap-btn {
    background: var(--surface-primary);
    border: 2px solid var(--primary-blue);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 16px;
    color: var(--primary-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-weight: 600;
}

.swap-btn:hover {
    background: var(--primary-blue);
    color: var(--white);
    transform: rotate(180deg);
    box-shadow: var(--shadow-md);
}

.swap-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Destination Cards */
.destination-card {
    background: var(--surface-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin: 12px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.destination-card:hover {
    border-color: var(--primary-blue);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.destination-info {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.destination-flag {
    font-size: 1.5rem;
}

.destination-details h4 {
    margin: 0 0 4px 0;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    font-family: var(--font-heading);
}

.destination-details p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.remove-destination-btn {
    background: var(--surface-primary);
    border: 1px solid var(--error-red);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    color: var(--error-red);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.remove-destination-btn:hover {
    background: var(--error-red);
    color: var(--white);
    transform: scale(1.05);
}

/* Exchange Results */
.exchange-result {
    background: var(--surface-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-top: 24px;
    box-shadow: var(--shadow-md);
}

.currency-calculator {
    margin-bottom: 20px;
}

.calculator-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    font-size: 1.125rem;
    font-weight: 500;
    flex-wrap: wrap;
}

#fromAmount {
    width: 120px;
    padding: 12px 16px;
    background: var(--surface-primary);
    border: 2px solid var(--border-medium);
    border-radius: var(--radius-md);
    font-size: 1.125rem;
    font-weight: 500;
    text-align: center;
    color: var(--text-primary);
    font-family: var(--font-mono);
    transition: all 0.2s ease;
}

#fromAmount:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

#fromCurrency, #toCurrency {
    font-weight: 500;
    background: var(--surface-secondary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    font-family: var(--font-mono);
}

#toAmount {
    font-size: 1.375rem;
    font-weight: 600;
    color: var(--success-green);
    font-family: var(--font-mono);
}

.exchange-rate {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 12px;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.exchange-details {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Multiple Results */
.multiple-results {
    background: var(--surface-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-top: 24px;
    box-shadow: var(--shadow-md);
}

.results-header {
    text-align: center;
    margin-bottom: 24px;
}

.results-header h3 {
    color: var(--text-primary);
    font-size: 1.375rem;
    font-weight: 500;
    margin: 0 0 8px 0;
    font-family: var(--font-heading);
}

.results-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.conversion-card {
   background: var(--surface-secondary);
   border: 1px solid var(--border-light);
   border-radius: var(--radius-lg);
   padding: 24px;
   text-align: center;
   transition: all 0.2s ease;
   box-shadow: var(--shadow-sm);
}

.conversion-card:hover {
   border-color: var(--primary-blue);
   box-shadow: var(--shadow-md);
   transform: translateY(-2px);
}

.conversion-amount {
   font-size: 1.75rem;
   font-weight: 600;
   color: var(--success-green);
   margin-bottom: 8px;
   font-family: var(--font-mono);
}

.conversion-rate {
   font-size: 0.875rem;
   color: var(--text-secondary);
   margin-bottom: 8px;
   font-family: var(--font-mono);
}

.conversion-country {
   font-size: 0.875rem;
   color: var(--text-primary);
   font-weight: 500;
}

/* Chart Container */
.chart-container {
   background: var(--surface-primary);
   border: 1px solid var(--border-light);
   border-radius: var(--radius-lg);
   margin-top: 24px;
   box-shadow: var(--shadow-md);
   overflow: hidden;
}

.chart-header {
   display: flex;
   justify-content: space-between;
   align-items: center;
   padding: 20px 24px;
   background: var(--surface-secondary);
   border-bottom: 1px solid var(--border-light);
}

.chart-header h3 {
   color: var(--text-primary);
   font-size: 1.125rem;
   font-weight: 500;
   margin: 0;
}

.chart-controls {
   display: flex;
   align-items: center;
   gap: 16px;
}

.timeframe-buttons {
   display: flex;
   gap: 8px;
}

.timeframe-btn {
   background: var(--surface-primary);
   border: 1px solid var(--border-medium);
   border-radius: 4px;
   padding: 6px 12px;
   font-size: 0.875rem;
   font-weight: 500;
   color: var(--text-secondary);
   cursor: pointer;
   transition: all 0.2s ease;
}

.timeframe-btn:hover {
   border-color: var(--primary-blue);
   color: var(--primary-blue);
}

.timeframe-btn.active {
   background: var(--primary-blue);
   border-color: var(--primary-blue);
   color: white;
}

.indicator-btn {
   background: var(--surface-primary);
   border: 1px solid var(--border-medium);
   border-radius: 4px;
   padding: 6px 12px;
   font-size: 0.75rem;
   font-weight: 500;
   color: var(--text-secondary);
   cursor: pointer;
   transition: all 0.2s ease;
}

.indicator-btn:hover {
   border-color: var(--primary-blue);
   color: var(--primary-blue);
}

.indicator-btn.active {
   background: var(--success-green);
   border-color: var(--success-green);
   color: white;
}
.map-reset-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.2s ease;
}

.map-reset-btn:hover {
    background: rgba(255, 255, 255, 1) !important;
    border-color: #0052cc !important;
    transform: scale(1.05) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
}

.map-reset-btn:active {
    transform: scale(0.95) !important;
}

.close-chart-btn {
   background: var(--surface-primary);
   border: 1px solid var(--border-medium);
   border-radius: 50%;
   width: 32px;
   height: 32px;
   display: flex;
   align-items: center;
   justify-content: center;
   cursor: pointer;
   color: var(--text-secondary);
   transition: all 0.2s ease;
   font-size: 14px;
   font-weight: bold;
}

.close-chart-btn:hover {
   background: #d93025;
   border-color: #d93025;
   color: white;
}

#addDestinationBtn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(26, 115, 232, 0.4) !important;
}

#resetAllBtn:hover {
    background: #ea4335 !important;
    color: white !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(234, 67, 53, 0.3) !important;
}

/* Ensure map container allows absolute positioning */
.map-container-primary {
    position: relative !important;
}

.chart-wrapper {
   padding: 24px;
   height: 400px;
   position: relative;
}

.chart-info {
   padding: 16px 24px;
   background: var(--surface-secondary);
   border-top: 1px solid var(--border-light);
}

.chart-stats {
   display: flex;
   gap: 32px;
   justify-content: center;
}

.stat-item {
   display: flex;
   flex-direction: column;
   align-items: center;
   gap: 4px;
}

.stat-label {
   font-size: 0.75rem;
   color: var(--text-tertiary);
   text-transform: uppercase;
   letter-spacing: 0.5px;
   font-weight: 500;
}

.stat-value {
   font-size: 0.875rem;
   font-weight: 600;
   color: var(--text-primary);
}

.show-chart-btn {
   background: var(--surface-primary);
   border: 2px solid var(--primary-blue);
   border-radius: 8px;
   padding: 12px 20px;
   font-size: 0.875rem;
   font-weight: 500;
   color: var(--primary-blue);
   cursor: pointer;
   transition: all 0.2s ease;
   display: inline-flex;
   align-items: center;
   gap: 8px;
   margin-top: 16px;
}

.show-chart-btn:hover {
   background: var(--primary-blue);
   color: white;
   transform: translateY(-1px);
}

.chart-actions {
   text-align: center;
   margin-top: 16px;
}

.chart-loading {
   display: flex;
   align-items: center;
   justify-content: center;
   height: 200px;
   color: var(--text-secondary);
   font-size: 0.875rem;
}

/* Tooltip */
.tooltip {
   position: absolute;
   background: var(--gray-800);
   color: var(--white);
   padding: 8px 12px;
   border-radius: var(--radius-sm);
   font-size: 0.875rem;
   font-weight: 500;
   pointer-events: none;
   z-index: 1000;
   transform: translate(-50%, -100%);
   margin-top: -8px;
   box-shadow: var(--shadow-lg);
   max-width: 200px;
   text-align: center;
}

/* Loading & Error States */
.loading {
   text-align: center;
   padding: 48px;
   color: var(--text-secondary);
   font-size: 1rem;
}

.error {
   background: #fce8e6;
   color: var(--error-red);
   padding: 16px;
   border-radius: var(--radius-md);
   margin-top: 16px;
   border-left: 4px solid var(--error-red);
   font-size: 0.875rem;
}

/* Map locked state */
.map-locked .country {
   cursor: not-allowed !important;
   opacity: 0.6 !important;
}

.map-locked .country:hover {
   fill: #e8f0fe !important;
   stroke-width: 0.5 !important;
}

.map-locked .country.selected-home:hover {
   fill: var(--success-green) !important;
   stroke: var(--success-green) !important;
   stroke-width: 1.5 !important;
   opacity: 1 !important;
}

.map-locked .country.selected-destination:hover {
   fill: var(--primary-blue) !important;
   stroke: var(--primary-blue-dark) !important;
   stroke-width: 1.5 !important;
   opacity: 1 !important;
}

/* Fix horizontal scrolling */
.container, .main-content {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

/* Fix the currency list container */
.currency-list-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100vw;
}

/* Fix the chart container */
.chart-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Ensure the whole page is scrollable */
body {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* new */
/* Mobile responsiveness */
@media (max-width: 768px) {
    /* Make tables scrollable */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Fix currency list */
    .currency-list {
        font-size: 14px;
        min-width: 300px; /* Ensures content doesn't get squished */
    }
    
    /* Fix chart buttons */
    .chart-controls {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .chart-controls button {
        flex: 1;
        min-width: 60px;
        font-size: 12px;
    }
    
    /* Make the map container scrollable */
    #map-container {
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* end new */

/* Custom chart hover effects */
/* #historicalChart {
    position: relative;
} */
#historicalChart {
    max-width: 100%;
    height: 400px !important;
    min-height: 350px !important;
    display: block !important;
    position: relative !important;
}

/* iOS-specific fixes */
@supports (-webkit-touch-callout: none) {
    #historicalChart {
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }
    
    .chart-wrapper {
        -webkit-overflow-scrolling: touch;
        position: relative;
        min-height: 350px;
    }
}

/* Hide cursor when hovering data points */
.chart-wrapper canvas:hover {
    cursor: crosshair;
}

/* Smooth animation for chart updates */
.chart-wrapper {
    transition: all 0.3s ease;
}

/* Responsive Design */
@media (max-width: 768px) {
   .container {
       padding: 16px;
   }
   
   .header h1 {
       font-size: 2rem;
       flex-direction: column;
       gap: 12px;
   }
   
   .compact-header {
       flex-direction: column;
       gap: 16px;
       padding: 16px;
   }
   
   .currency-flow {
       min-width: auto;
       width: 100%;
   }
   
   .live-rate-display {
       width: 100%;
       justify-content: center;
   }
   
   .quick-actions {
       width: 100%;
       justify-content: center;
   }
   
   .calculator-row {
       gap: 12px;
   }
   
   #fromAmount {
       width: 100px;
   }
   
   .chart-header {
       flex-direction: column;
       gap: 16px;
       align-items: flex-start;
   }
   
   .chart-controls {
       width: 100%;
       justify-content: space-between;
   }
   
   .chart-stats {
       flex-direction: column;
       gap: 16px;
   }
}

/* Intelligence Layer Switcher */
.layer-switcher {
    margin-bottom: 20px;
    background: rgba(26, 26, 46, 0.95);
    border-radius: 12px;
    padding: 12px;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.layer-tabs {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.layer-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 8px;
    color: #cbd5e1;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    position: relative;
}

.layer-btn:hover:not([disabled]) {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.5);
    transform: translateY(-2px);
}

.layer-btn.active {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border-color: #3b82f6;
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.layer-btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.layer-btn .layer-icon {
    font-size: 18px;
}

.layer-btn .coming-soon {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #f59e0b;
    color: #1a1a2e;
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
    text-transform: uppercase;
}

@media (max-width: 768px) {
    .layer-tabs {
        flex-direction: column;
    }
    
    .layer-btn {
        width: 100%;
        justify-content: center;
    }
}
/* Fix the currency selector dropdowns */
.currency-selector-container {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 0;
}

/* On mobile, stack them vertically instead */
@media (max-width: 768px) {
    .currency-selector-container {
        flex-direction: column;
        overflow-x: visible;
    }
    
    .currency-selector {
        width: 100%;
        min-width: unset;
    }
}

/* Make map bigger on mobile */
@media (max-width: 768px) {
    #worldMap, .map-container {
        height: 60vh !important; /* Takes 60% of screen height */
        min-height: 400px;
        width: 100%;
    }
    
    /* Make the destination button smaller/repositioned */
    .add-destination-btn {
        padding: 10px 15px;
        font-size: 14px;
        margin-top: 10px;
    }
    
    /* Better spacing */
    .map-section {
        padding: 10px;
    }
}

/* Focus indicators for accessibility */
.add-destination-btn:focus,
.reset-destinations-btn:focus,
.swap-btn:focus,
.remove-destination-btn:focus {
   outline: 2px solid var(--primary-blue);
   outline-offset: 2px;
}

/* Fix the currency list cards */
.currency-list-item {
    min-width: 0; /* Prevent overflow */
    overflow: hidden;
}

.currency-value {
    white-space: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Better mobile layout for cards */
@media (max-width: 768px) {
    .currency-card {
        display: grid;
        grid-template-columns: 60px 1fr auto;
        gap: 10px;
        align-items: center;
        padding: 15px;
    }
    
    .currency-name {
        font-size: 14px;
    }
    
    .currency-value {
        font-size: 18px;
        text-align: right;
    }
    
    .currency-amount {
        font-size: 12px;
        color: #666;
    }
}

/* Mobile chart container fix */
@media (max-width: 768px) {
    .chart-container, #chartContainer {
        min-height: 400px !important;
        height: auto !important;
        padding: 10px;
        margin-bottom: 20px;
    }
    
    /* The actual chart canvas */
    #exchangeChart, canvas {
        height: 300px !important;
        width: 100% !important;
    }
}

@media (max-width: 768px) {
    /* Time period buttons (7D, 1M, 3M, 1Y) */
    .chart-controls, .time-controls {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr);
        gap: 5px;
        margin-bottom: 10px;
    }
    
    /*Button Layout */
    /* Indicator buttons (SMA, Bollinger, RSI, etc) */
    .indicator-controls {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr);
        gap: 5px;
        margin-bottom: 10px;
    }
    
    /* All chart buttons */
    .chart-controls button,
    .time-controls button,
    .indicator-controls button {
        padding: 8px 5px !important;
        font-size: 12px !important;
        min-width: unset !important;
        width: 100% !important;
    }
    
    /* Currency tags (USD, LYD, AUD) */
    .currency-tags {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
        margin-bottom: 10px;
    }
    
    .currency-tag {
        padding: 5px 10px;
        font-size: 12px;
        flex: 1;
        min-width: 60px;
        text-align: center;
    }
    
    /* Manage Overlay button */
    .manage-overlay-btn {
        width: 100%;
        margin-top: 10px;
        padding: 10px;
    }
}

/* Chart Section Layout */
@media (max-width: 768px) {
    /* Main chart section */
    .chart-section {
        padding: 10px;
        background: white;
        border-radius: 10px;
        margin: 10px;
    }
    
    /* Chart wrapper */
    .chart-wrapper {
        position: relative;
        width: 100%;
        padding-bottom: 75%; /* 4:3 Aspect Ratio */
        height: 0;
        overflow: hidden;
    }
    
    .chart-wrapper canvas {
        position: absolute;
        top: 0;
        left: 0;
        width: 100% !important;
        height: 100% !important;
    }
    
    /* Legend below chart */
    .chart-legend {
        margin-top: 10px;
        padding: 10px;
        background: #f5f5f5;
        border-radius: 5px;
        font-size: 12px;
    }
    
    /* Fix cut-off "Trend Analysis" button */
    .analysis-buttons {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
        margin-top: 10px;
    }
}

/* Portrait Mode Optimization */
@media (max-width: 768px) and (orientation: portrait) {
    /* Make chart taller in portrait */
    .chart-container, #chartContainer {
        min-height: 350px !important;
        max-height: 400px !important;
    }
    
    /* Stack buttons in 2 columns for portrait */
    .chart-controls, .time-controls {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px;
    }
    
    .indicator-controls {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px;
    }
    
    /* Bigger buttons in portrait */
    .chart-controls button,
    .indicator-controls button {
        padding: 12px 8px !important;
        font-size: 13px !important;
        height: 44px !important; /* Apple's recommended touch target */
    }
    
    /* Currency tags in a row */
    .currency-tags {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        gap: 8px;
        padding-bottom: 8px;
    }
    
    .currency-tag {
        flex-shrink: 0;
        min-width: 70px;
    }
}

/* Landscape Mode - Keep it as is since it works */
@media (max-width: 768px) and (orientation: landscape) {
    /* Your existing styles are good for landscape */
    .chart-container {
        min-height: 300px !important;
    }
    
    /* 4 columns for buttons in landscape */
    .chart-controls, .time-controls {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

/* Landscape Mode - Make map use full space */
@media (max-width: 900px) and (orientation: landscape) {
    /* Map takes most of the screen */
    #worldMap, .map-container, svg#worldMap {
        width: 100% !important;
        height: 70vh !important;  /* 70% of viewport height */
        max-height: none !important;
        min-height: 400px !important;
    }
    
    /* Remove unnecessary padding/margins */
    .map-wrapper, .map-section {
        padding: 5px !important;
        margin: 0 !important;
    }
    
    /* Hide or minimize other elements in landscape */
    .header-section {
        display: none;  /* Hide header to save space */
    }
    
    /* Make the SVG scale properly */
    svg#worldMap {
        width: 100% !important;
        height: 100% !important;
        display: block !important;
    }
}


/* High contrast for better readability */
@media (prefers-contrast: high) {
   :root {
       --border-medium: var(--gray-400);
       --text-secondary: var(--gray-800);
   }
}

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

/* Mini Calculator Widget - Professional Design */
.mini-calculator-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 320px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

.mini-calculator-widget.minimized {
    height: 45px;
    width: 200px;
}

.calculator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    color: white;
    font-weight: 600;
    cursor: move;
}

.calculator-title {
    font-size: 14px;
    letter-spacing: 0.5px;
}

.calculator-minimize {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: background 0.2s;
}

.calculator-minimize:hover {
    background: rgba(255, 255, 255, 0.3);
}

.calculator-body {
    padding: 20px;
    background: white;
    border-radius: 0 0 16px 16px;
}

.minimized .calculator-body {
    display: none;
}

.calc-input-group {
    position: relative;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    background: #f8f9fa;
    border-radius: 12px;
    padding: 4px;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.calc-input-group:focus-within {
    border-color: #667eea;
}

.calc-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 24px;
    font-weight: 300;
    padding: 12px;
    outline: none;
    color: #2d3748;
}

.calc-input::placeholder {
    color: #cbd5e0;
}

.calc-currency {
    padding: 0 16px;
    font-weight: 600;
    color: #667eea;
    font-size: 18px;
}

.calc-arrow {
    text-align: center;
    font-size: 20px;
    color: #cbd5e0;
    margin: 8px 0;
}

.calc-rate-display {
    background: #f7fafc;
    border-radius: 8px;
    padding: 12px;
    margin: 16px 0;
    text-align: center;
}

#calcRateInfo {
    display: block;
    font-size: 14px;
    color: #4a5568;
    font-weight: 500;
}

.calc-timestamp {
    display: block;
    font-size: 11px;
    color: #a0aec0;
    margin-top: 4px;
}

.calc-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.calc-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.calc-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

/* Comparison List */
.calc-comparisons {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}

.comparison-header {
    font-size: 12px;
    font-weight: 600;
    color: #718096;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.comparison-item {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    background: #f7fafc;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 14px;
}

.comparison-remove {
    color: #e53e3e;
    cursor: pointer;
    font-weight: bold;
}

/* Make it draggable on desktop */
@media (min-width: 768px) {
    .mini-calculator-widget {
        cursor: move;
    }
}

/* Mobile responsive */
@media (max-width: 767px) {
    .mini-calculator-widget {
        width: calc(100% - 20px);
        left: 10px;
        right: 10px;
        bottom: 10px;
    }
}

/* ============================================
   CHART VISIBILITY CONTROL - FIXED OVERFLOW
   ============================================ */

/* Hide chart container by default */
#chartContainer {
    display: none;
}

/* Show only when chart-active class is added */
#chartContainer.chart-active {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-height: 400px !important;
    background: white !important;
    border-radius: 12px !important;
    margin: 20px auto !important;
    max-width: 100% !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1) !important;
    position: relative !important;
    z-index: 1 !important;
    overflow: hidden !important; /* KEY FIX: Prevent chart overflow */
}

/* Chart wrapper - contain the chart properly */
.chart-wrapper {
    display: block !important;
    min-height: 350px !important;
    max-height: 400px !important; /* KEY FIX: Limit chart height */
    padding: 20px !important;
    position: relative !important;
    width: 100% !important;
    overflow: hidden !important; /* KEY FIX: Contain chart */
}

/* Canvas - strict size controls */
#chartContainer.chart-active canvas,
#chartContainer.chart-active #historicalChart {
    display: block !important;
    visibility: visible !important;
    width: 100% !important;
    height: 350px !important; /* Fixed height */
    max-width: 100% !important;
    max-height: 350px !important; /* KEY FIX: Prevent overflow */
    background: white !important;
    position: relative !important;
    z-index: 1 !important;
}

/* Chart info section - ensure proper spacing */
#chartContainer.chart-active .chart-info {
    display: block !important;
    visibility: visible !important;
    padding: 16px 24px !important;
    background: #f8f9fa !important;
    border-top: 1px solid #e8eaed !important;
    position: relative !important;
    z-index: 2 !important;
    clear: both !important;
    margin-top: 0 !important; /* No gap */
}

/* Educational info - ensure it appears below chart */
#indicatorEducationalInfo {
    position: relative !important;
    z-index: 3 !important;
    margin-top: 20px !important; /* Space from chart */
    clear: both !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Mobile responsive */
@media only screen and (max-width: 768px) {
    #chartContainer.chart-active {
        min-height: 350px !important;
        margin: 15px 10px !important;
        padding: 10px !important;
    }
    
    .chart-wrapper {
        min-height: 250px !important;
        max-height: 300px !important; /* Smaller on mobile */
        padding: 15px !important;
    }
    
    #chartContainer.chart-active canvas,
    #chartContainer.chart-active #historicalChart {
        height: 250px !important;
        max-height: 250px !important;
    }
}

/* ============================================
   HIDE MINI CALCULATOR
   ============================================ */

/* Hide all calculator elements */
#miniCalculator,
.mini-calculator,
.mini-calculator-widget,
.calculator-widget,
#mobileCalcToggle,
#mobileCalcSheet,
.mobile-calc-toggle,
.mobile-calc-sheet {
    display: none !important;
    visibility: hidden !important;
}

/* Also hide any calculator buttons/triggers */
.calculator-toggle,
.calc-toggle-btn,
[data-calculator],
[onclick*="calculator"] {
    display: none !important;
}

/* ============================================
   EDUCATIONAL INDICATOR INFO - FIXED LAYOUT
   ============================================ */

/* Educational Indicator Info - Fixed Layout */
.indicator-educational-info,
#indicatorEducationalInfo {
    background: linear-gradient(135deg, #f0f4f8, #e2e8f0);
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
    font-size: 0.875rem;
}

.indicator-educational-info h4,
#indicatorEducationalInfo h4 {
    color: #2d3748;
    margin-bottom: 16px;
    font-size: 1rem;
    font-weight: 600;
}

/* FIXED: Grid layout to prevent overlap */
.indicator-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

/* Desktop: 2 columns */
@media (min-width: 768px) {
    .indicator-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

/* Large screens: 4 columns */
@media (min-width: 1200px) {
    .indicator-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }
}

.indicator-card {
    background: white;
    padding: 16px;
    border-radius: 8px;
    border-left: 4px solid;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.indicator-card.sma {
    border-left-color: #4285f4;
}

.indicator-card.bollinger {
    border-left-color: #34a853;
}

.indicator-card.rsi {
    border-left-color: #ea4335;
}

.indicator-card.trend {
    border-left-color: #fbbc04;
}

.indicator-card strong {
    margin-bottom: 8px;
    display: block;
    font-size: 0.9rem;
    line-height: 1.3;
}

.indicator-card p {
    margin: 0;
    color: #4a5568;
    font-size: 0.8rem;
    line-height: 1.4;
    flex: 1;
}

.indicator-card em {
    margin-top: 8px;
    font-size: 0.75rem;
    color: #64748b;
    display: block;
    font-style: italic;
}

/* Warning box styling */
.indicator-warning {
    background: #fff5f5;
    border: 1px solid #feb2b2;
    border-radius: 6px;
    padding: 12px;
    margin-top: 12px;
    color: #c53030;
    font-size: 0.8rem;
}

.indicator-warning strong {
    font-weight: 600;
}

/* Mobile optimization for indicator cards */
@media (max-width: 767px) {
    .indicator-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .indicator-card {
        min-height: 100px;
        padding: 12px;
    }
    
    .indicator-card strong {
        font-size: 0.85rem;
    }
    
    .indicator-card p {
        font-size: 0.75rem;
    }
    
    .indicator-card em {
        font-size: 0.7rem;
    }
}

/* Team Pin Styles */
.team-pin {
    transition: transform 0.2s ease;
}

.team-pin:hover {
    transform: scale(1.1);
}

.pin-marker {
    background: rgba(220, 53, 69, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 5px;
}

.pin-dot {
    font-size: 14px;
}

.pin-label {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Enhanced tooltip on hover */
.team-pin::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1001;
}

.team-pin:hover::after {
    opacity: 1;
}

/* Team details panel styling */
#team-details-panel {
    border: 1px solid #ddd;
    animation: slideInRight 0.3s ease;
}

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