/* CSS Custom Properties for Theming */
:root {
    --primary-color: #4594A2;
    --secondary-color: #8AC6CC;
    --accent-light: #D4EEE5;
    --warm-neutral: #E9BDA0;
    --warm-accent: #DF986C;
    --light-accent: #FEE892;
    --bg-color: #ffffff;
    --text-color: #333;
    --text-secondary: #2c3e50;
    --text-muted: #6c757d;
    --border-color: #e9ecef;
    --bg-light: #f8f9fa;
}

.dark-mode {
    --primary-color: #4594A2;
    --secondary-color: #6B9CA3;
    --bg-color: #1a1a1a;
    --text-color: #ffffff;
    --text-secondary: #e9ecef;
    --text-muted: #adb5bd;
    --bg-light: #2a2a2a;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-color);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    text-align: center;
    padding: 30px 40px;
    border-radius: 20px 20px 0 0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
}

.title-section {
    flex: 1;
    text-align: center;
}

.language-switcher {
    position: relative;
}

.language-switcher select {
    background: var(--warm-neutral);
    border: none;
    color: var(--text-color);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.language-switcher select option {
    background: var(--primary-color);
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Main converter */
.converter {
    padding: 40px;
}

.input-section {
    margin-bottom: 40px;
}

.input-row {
    display: grid;
    grid-template-columns: 1.5fr 2fr 2fr;
    gap: 20px;
    margin-bottom: 25px;
    align-items: end;
}

.amount-group {
    min-width: 0;
}

.currency-group {
    min-width: 0;
}

.input-group {
    margin-bottom: 25px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.2;
    word-wrap: break-word;
}

input, select {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid var(--accent-light);
    border-radius: 12px;
    font-size: 16px;
    background-color: var(--bg-color);
    transition: all 0.3s ease;
    box-sizing: border-box;
    min-height: 54px;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(69, 148, 162, 0.3);
}

.convert-btn {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.convert-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(69, 148, 162, 0.3);
}

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

/* Results section */
.results-section {
    margin-top: 40px;
}

.conversion-flow {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    padding: 15px 25px;
    border-radius: 12px;
    margin-bottom: 25px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(79, 172, 254, 0.3);
}

.flow-indicator {
    color: white;
    font-weight: 600;
}

.flow-text {
    font-size: 0.9rem;
    opacity: 0.9;
}

#flowPath {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 1px;
    margin-left: 8px;
}

/* Route Comparison Section */
.route-comparison {
    background: linear-gradient(135deg, var(--accent-light) 0%, var(--warm-neutral) 100%);
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 25px;
    border: 2px solid var(--accent-light);
}

.route-comparison h4 {
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.2rem;
}

.routes-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.route-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
    position: relative;
}

.route-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.route-card.best-route-highlight {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, var(--accent-light) 0%, var(--secondary-color) 100%);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(69, 148, 162, 0.3);
}

.route-card.best-route-highlight::before {
    content: "👑";
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--primary-color);
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

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

.route-header h5 {
    color: var(--text-secondary);
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.route-path {
    background: var(--primary-color);
    color: white;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}

.route-amount {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 15px;
}

.route-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.step {
    background: var(--bg-light);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    border-left: 3px solid var(--primary-color);
    white-space: pre-line;
}

.best-route {
    background: linear-gradient(135deg, var(--warm-accent) 0%, var(--light-accent) 100%);
    color: white;
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    font-size: 1.1rem;
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.3);
}

/* Direct Conversion Section (USD pairs, no route comparison needed) */
.direct-conversion {
    background: linear-gradient(135deg, var(--accent-light) 0%, var(--warm-neutral) 100%);
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 25px;
    border: 2px solid var(--accent-light);
    text-align: center;
}

.direct-conversion h4 {
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.direct-result {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.direct-arrow {
    color: var(--text-secondary);
    font-size: 1.4rem;
}

.direct-rate {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.conversion-result {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 40px;
}

.result-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 25px;
    border-radius: 15px;
    text-align: center;
    border: 2px solid #e9ecef;
    transition: all 0.3s ease;
}

.result-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
}

.result-card h3 {
    color: var(--text-secondary);
    font-size: 1.3rem;
    margin-bottom: 15px;
    font-weight: 700;
}

.result-amount {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.exchange-rate {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Rates info */
.rates-info {
    background: var(--accent-light);
    padding: 25px;
    border-radius: 15px;
    border: 2px solid #e9ecef;
}

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

.rates-info h4 {
    color: var(--text-secondary);
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
}

.refresh-btn {
    background: linear-gradient(135deg, var(--warm-accent) 0%, var(--light-accent) 100%);
    color: var(--text-color);
    padding: 10px 20px;
    font-size: 0.9rem;
    border-radius: 8px;
}

.refresh-btn:hover {
    transform: translateY(-2px) rotate(90deg);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

.refresh-btn:active {
    transform: translateY(0) rotate(180deg);
}

.rates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.rate-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    font-weight: 500;
    transition: all 0.3s ease;
}

.rate-item:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

/* Footer */
footer {
    background: var(--bg-light);
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    border-top: 1px solid #e9ecef;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

footer a:hover {
    color: var(--warm-accent);
    text-decoration: underline;
}

/* PWA Install Button */
#install-pwa {
    position: fixed;
    top: 10px;
    right: 10px;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    display: none;
}

#install-pwa:hover {
    background: var(--secondary-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* iOS Install Modal Styles */
.ios-install-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.ios-install-content {
    background: var(--bg-color);
    color: var(--text-color);
    padding: 20px;
    border-radius: 10px;
    max-width: 300px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

.ios-install-content h3 {
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.ios-install-content p {
    color: var(--text-muted);
    margin-bottom: 15px;
    line-height: 1.5;
}

.ios-install-close {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

/* PWA Update and Install Notifications */
.update-notification {
    background: var(--light-accent);
    border: 1px solid var(--warm-accent);
    padding: 10px;
    margin: 10px;
    border-radius: 5px;
    font-size: 14px;
}

.update-notification button {
    background: var(--warm-accent);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    margin-left: 10px;
    cursor: pointer;
}

.install-notification {
    background: var(--accent-light);
    border: 1px solid var(--primary-color);
    padding: 10px;
    margin: 10px;
    border-radius: 5px;
    font-size: 14px;
}

.install-notification button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    margin-left: 10px;
    cursor: pointer;
}

.app-version {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 5px;
}

.force-refresh-link {
    color: var(--primary-color);
    cursor: pointer;
    text-decoration: underline;
}

/* PWA Mode - Hide install elements when running as PWA */
.pwa-mode #install-pwa,
.pwa-mode #install-banner,
.pwa-mode .install-notification {
    display: none !important;
}

/* Large Screen Optimizations */
@media (min-width: 1200px) {
    .input-row {
        grid-template-columns: 2fr 2fr 2fr;
        gap: 30px;
        max-width: 1000px;
        margin: 0 auto 25px auto;
    }
    
    .input-group {
        margin-bottom: 25px;
    }
    
    input, select {
        padding: 18px 24px;
        font-size: 18px;
        min-height: 58px;
    }
    
    .input-group label {
        font-size: 1.1rem;
        margin-bottom: 10px;
    }
}

@media (min-width: 769px) and (max-width: 1199px) {
    .input-row {
        grid-template-columns: 1.5fr 2fr 2fr;
        gap: 25px;
        max-width: 900px;
        margin: 0 auto 25px auto;
    }
    
    input, select {
        padding: 16px 22px;
        font-size: 17px;
        min-height: 56px;
    }
}

/* Responsive design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        border-radius: 15px;
    }
    
    header {
        padding: 20px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .converter {
        padding: 20px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 15px;
    }
    
    .language-switcher {
        order: -1;
        align-self: flex-end;
    }
    
    .input-row {
        gap: 10px;
        grid-template-columns: 1fr 1.2fr 1.2fr;
        align-items: end;
    }
    
    .amount-group {
        min-width: 0;
    }
    
    .currency-group {
        min-width: 0;
    }
    
    .routes-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .route-amount {
        font-size: 1.5rem;
    }
    
    .conversion-flow {
        padding: 12px 20px;
        margin-bottom: 20px;
    }
    
    #flowPath {
        font-size: 1rem;
    }
    
    .conversion-result {
        grid-template-columns: 1fr;
    }
    
    .rates-grid {
        grid-template-columns: 1fr;
    }
    
    .result-amount {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.8rem;
    }
    
    .input-row {
        gap: 8px;
        grid-template-columns: 1fr 1fr 1fr;
        align-items: end;
    }
    
    .input-group label {
        font-size: 0.85rem;
        margin-bottom: 6px;
    }
    
    .input-group input,
    .input-group select {
        font-size: 16px;
        padding: 10px 12px;
        min-height: 44px;
    }
    
    .result-card {
        padding: 15px;
    }
    
    .rates-info {
        padding: 15px;
    }
}

/* Prevent zoom on mobile devices by ensuring minimum 16px font size */
input[type="number"], 
input[type="text"], 
input[type="email"], 
input[type="tel"], 
select {
    font-size: 16px !important;
}