/* CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* CSS Variables - Design System */
:root {
    --bg-primary: #0F172A;
    --surface-dark: #111827;
    --card-bg: #1F2937;
    --text-primary: #FFFFFF;
    --accent-cyan: #22D3EE;
    --success-green: #22C55E;
    --warning-orange: #F59E0B;
    --danger-red: #EF4444;
    --muted: #9CA3AF;
    --border-color: #374151;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: var(--surface-dark);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.brand {
    font-size: 0.875rem;
    color: var(--muted);
    font-weight: 400;
}

.last-updated {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--muted);
}

.update-label {
    color: var(--muted);
}

#lastUpdateTime {
    color: var(--accent-cyan);
    font-weight: 500;
}

/* Main Content */
.main {
    padding: 40px 0;
}

/* Hero Section */
.hero {
    text-align: center;
    margin-bottom: 40px;
    padding: 40px 0;
}

.hero-title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--success-green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--muted);
    margin-bottom: 8px;
}

.hero-support {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* Input Section */
.input-section {
    margin-bottom: 40px;
}

.input-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr auto 1fr;
    gap: 20px;
    align-items: end;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--muted);
}

.currency-select,
.amount-input,
.purpose-select {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s ease;
}

.currency-select:focus,
.amount-input:focus,
.purpose-select:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgb(34 211 238 / 0.1);
}

.amount-input {
    width: 100%;
}

.preset-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.preset-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--surface-dark);
    color: var(--muted);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-btn:hover {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

.preset-btn.active {
    background: var(--accent-cyan);
    color: var(--bg-primary);
    border-color: var(--accent-cyan);
}

/* Swap Button */
.swap-button {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--muted);
}

.swap-button:hover {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    transform: rotate(180deg);
}

/* Rate Snapshot */
.rate-snapshot {
    margin-bottom: 40px;
}

.rate-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
}

.rate-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.rate-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.rate-change {
    font-size: 0.875rem;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 6px;
}

.rate-change.positive {
    background: rgb(34 197 94 / 0.1);
    color: var(--success-green);
}

.rate-change.negative {
    background: rgb(239 68 68 / 0.1);
    color: var(--danger-red);
}

.rate-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.rate-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-cyan);
    font-variant-numeric: tabular-nums;
}

.rate-source {
    font-size: 0.875rem;
    color: var(--muted);
}

/* Conversion Result */
.conversion-result {
    margin-bottom: 40px;
}

.result-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
}

.result-card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
}

.result-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
}

.amount-sent,
.amount-received {
    text-align: center;
}

.label {
    display: block;
    font-size: 0.875rem;
    color: var(--muted);
    margin-bottom: 4px;
}

.value {
    display: block;
    font-size: 2rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.amount-sent .value {
    color: var(--warning-orange);
}

.amount-received .value {
    color: var(--success-green);
}

.arrow {
    font-size: 2rem;
    color: var(--accent-cyan);
    font-weight: bold;
}

/* Comparison Table */
.comparison-section {
    margin-bottom: 40px;
}

.comparison-section h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
}

.comparison-table-container {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

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

.comparison-table th,
.comparison-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.comparison-table th {
    background: var(--surface-dark);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.comparison-table td {
    font-size: 1rem;
    color: var(--text-primary);
}

.provider-type {
    font-weight: 600;
}

.rate-used {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 0.875rem;
}

.fees {
    color: var(--warning-orange);
    font-weight: 500;
}

.received-amount {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.savings {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.savings.positive {
    color: var(--success-green);
}

.savings.negative {
    color: var(--danger-red);
}

.best-option {
    background: rgb(34 197 94 / 0.1);
    border-left: 4px solid var(--success-green);
}

.worst-option {
    background: rgb(239 68 68 / 0.1);
    border-left: 4px solid var(--danger-red);
}

/* Historical Section */
.historical-section {
    margin-bottom: 40px;
}

.historical-section h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
}

.historical-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
}

.period-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface-dark);
    color: var(--muted);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.period-btn:hover {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

.period-btn.active {
    background: var(--accent-cyan);
    color: var(--bg-primary);
    border-color: var(--accent-cyan);
}

.chart-container {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
}

.historical-insight {
    text-align: center;
    color: var(--muted);
    font-size: 0.875rem;
    font-style: italic;
}

/* Smart Insights */
.insights-section {
    margin-bottom: 40px;
}

.insights-section h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
}

.insight-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.insight-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.insight-text {
    font-size: 1rem;
    line-height: 1.6;
}

/* Rate Alerts */
.alerts-section {
    margin-bottom: 40px;
}

.alerts-section h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
}

.alert-setup {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: end;
    gap: 16px;
    flex-wrap: wrap;
}

.alert-input-group {
    flex: 1;
    min-width: 200px;
}

.alert-input-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 8px;
}

.target-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface-dark);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
}

.alert-btn,
.notification-btn {
    padding: 12px 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--accent-cyan);
    color: var(--bg-primary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.notification-btn {
    background: var(--surface-dark);
    color: var(--text-primary);
}

.alert-btn:hover,
.notification-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.alert-status {
    margin-top: 16px;
    padding: 12px 16px;
    background: rgb(34 197 94 / 0.1);
    border: 1px solid var(--success-green);
    border-radius: 8px;
    color: var(--success-green);
    font-size: 0.875rem;
}

/* FAQ Section */
.faq-section {
    margin-bottom: 40px;
}

.faq-section h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
}

.faq-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}

.faq-question {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.faq-question:hover {
    background: var(--surface-dark);
}

.faq-question h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.faq-toggle {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-cyan);
    transition: transform 0.2s ease;
}

.faq-item.active .faq-toggle {
    transform: rotate(45deg);
}

.faq-answer {
    padding: 0 20px;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.faq-item.active .faq-answer {
    padding: 0 20px 20px;
    max-height: 200px;
}

.faq-answer p {
    color: var(--muted);
    line-height: 1.6;
}

/* Footer */
.footer {
    background: var(--surface-dark);
    border-top: 1px solid var(--border-color);
    padding: 40px 0 20px;
    margin-top: 60px;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 32px;
    margin-bottom: 32px;
}

.footer-content h4 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.footer-content p {
    color: var(--muted);
    line-height: 1.6;
    font-size: 0.875rem;
}

.footer-bottom {
    text-align: center;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.footer-bottom p {
    color: var(--muted);
    font-size: 0.875rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1.125rem;
    }
    
    .input-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .swap-button {
        order: 3;
        align-self: center;
    }
    
    .result-content {
        flex-direction: column;
        text-align: center;
    }
    
    .arrow {
        transform: rotate(90deg);
    }
    
    .comparison-table-container {
        overflow-x: auto;
    }
    
    .comparison-table {
        min-width: 600px;
    }
    
    .alert-setup {
        flex-direction: column;
        align-items: stretch;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}

@media (max-width: 480px) {
    .hero {
        padding: 20px 0;
    }
    
    .hero-title {
        font-size: 1.75rem;
    }
    
    .rate-value {
        font-size: 1.75rem;
    }
    
    .value {
        font-size: 1.25rem;
        word-break: break-all;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .preset-buttons {
        flex-wrap: wrap;
    }
    
    /* Improve touch targets for mobile */
    .preset-btn,
    .period-btn,
    .alert-btn,
    .notification-btn {
        min-height: 44px;
        touch-action: manipulation;
    }
    
    /* Better spacing for mobile */
    .comparison-table th,
    .comparison-table td {
        padding: 12px 8px;
        font-size: 0.875rem;
    }
    
    .provider-type {
        min-width: 120px;
    }
    
    .received-amount {
        font-size: 0.875rem;
        font-variant-numeric: tabular-nums;
    }
}

/* Enhanced responsive handling for large numbers */
@media (max-width: 768px) {
    .rate-value {
        font-size: 2rem;
        word-break: break-all;
        line-height: 1.2;
    }
    
    .value {
        word-break: break-all;
        font-variant-numeric: tabular-nums;
    }
    
    /* Prevent overflow in comparison table */
    .comparison-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .comparison-table {
        min-width: 700px;
    }
    
    /* Better handling for large Indian numbers */
    .amount-received .value,
    .amount-sent .value {
        font-size: 1.75rem;
        line-height: 1.3;
    }
}

/* Large number display improvements */
.value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.amount-received .value,
.amount-sent .value {
    overflow: visible;
    white-space: normal;
    word-break: break-word;
}

/* Improve table cell spacing for large numbers */
.comparison-table td {
    vertical-align: middle;
    min-width: 100px;
}

.received-amount,
.savings {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Better scaling for extremely large numbers */
@media (max-width: 320px) {
    .rate-value {
        font-size: 1.5rem;
    }
    
    .value {
        font-size: 1rem;
    }
    
    .hero-title {
        font-size: 1.5rem;
    }
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.skeleton {
    background: linear-gradient(90deg, var(--card-bg) 25%, var(--surface-dark) 50%, var(--card-bg) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Micro-interactions */
.hover-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Count-up animation */
.count-up {
    animation: countUp 0.8s ease-out;
}

@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.hidden { display: none; }
.visible { display: block; }

/* Print Styles */
@media print {
    .header,
    .alerts-section,
    .faq-section {
        display: none;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .rate-card,
    .result-card,
    .comparison-table-container,
    .insight-card {
        border: 1px solid #ccc;
    }
}
