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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #1f2937;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 1rem;
}

/* Container */
.container {
    max-width: 480px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    animation: slideUp 0.6s ease-out;
}

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

/* Header */
.header {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    padding: 2rem 1.5rem;
    text-align: center;
}

.title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
}

.subtitle {
    font-size: 0.875rem;
    opacity: 0.9;
    font-weight: 400;
}

/* Main Converter */
.converter {
    padding: 2rem 1.5rem;
}

/* Conversion Sections */
.conversion-section {
    margin-bottom: 2rem;
}

.input-label {
    display: flex;
    align-items: center;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.currency-flag {
    margin-right: 0.5rem;
    font-size: 1.25rem;
}

/* Input Group */
.input-group {
    position: relative;
    margin-bottom: 1.5rem;
}

.currency-input {
    width: 100%;
    padding: 1rem 4rem 1rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 1.125rem;
    font-weight: 500;
    background: #f9fafb;
    transition: all 0.3s ease;
    -webkit-appearance: none;
    -moz-appearance: textfield;
}

.currency-input::-webkit-outer-spin-button,
.currency-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.currency-input:focus {
    outline: none;
    border-color: #2563eb;
    background: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.currency-input::placeholder {
    color: #9ca3af;
}

.input-group .currency-code {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 600;
    color: #6b7280;
    font-size: 0.875rem;
    background: #e5e7eb;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
}

/* Result Section */
.result-section {
    margin-top: 1rem;
}

.result-label {
    display: flex;
    align-items: center;
    font-weight: 500;
    color: #6b7280;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.result-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f3f4f6;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 1rem;
    transition: all 0.3s ease;
}

.result-display:hover {
    background: #e5e7eb;
}

.result-amount {
    font-size: 1.5rem;
    font-weight: 700;
    color: #059669;
    flex-grow: 1;
}

.result-display .currency-code {
    font-weight: 600;
    color: #6b7280;
    margin-right: 0.75rem;
}

/* Copy Button */
.copy-btn {
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.copy-btn:hover {
    background: #1d4ed8;
    transform: scale(1.05);
}

.copy-btn:active {
    transform: scale(0.95);
}

/* Divider */
.divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2rem 0;
    position: relative;
}

.divider::before {
    content: '';
    flex: 1;
    height: 1px;
    background: #e5e7eb;
}

.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e5e7eb;
}

.divider-text {
    background: white;
    color: #9ca3af;
    padding: 0 1rem;
    font-weight: 500;
    font-size: 0.875rem;
}

/* Footer */
.footer {
    background: #f9fafb;
    padding: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.disclaimer {
    font-size: 0.75rem;
    color: #6b7280;
    text-align: center;
    line-height: 1.5;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #059669;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    font-weight: 500;
    font-size: 0.875rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Responsive Design */
@media (max-width: 480px) {
    body {
        padding: 0.5rem;
    }
    
    .container {
        border-radius: 16px;
    }
    
    .header {
        padding: 1.5rem 1rem;
    }
    
    .title {
        font-size: 1.5rem;
    }
    
    .converter {
        padding: 1.5rem 1rem;
    }
    
    .currency-input {
        font-size: 1rem;
        padding: 0.875rem 3.5rem 0.875rem 0.875rem;
    }
    
    .result-amount {
        font-size: 1.25rem;
    }
}

@media (max-width: 360px) {
    .currency-input {
        padding: 0.75rem 3rem 0.75rem 0.75rem;
    }
    
    .input-group .currency-code {
        right: 0.75rem;
        font-size: 0.75rem;
        padding: 0.2rem 0.4rem;
    }
    
    .copy-btn {
        min-width: 36px;
        height: 36px;
        font-size: 0.875rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
.currency-input:focus,
.copy-btn:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .container {
        border: 2px solid #000;
    }
    
    .currency-input {
        border-color: #000;
    }
    
    .result-display {
        border-color: #000;
    }
}

/* --- Adapted Utility Buttons Styling for Consistency --- */
.utility-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 24px 0;
    flex-wrap: wrap;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.07);
    padding: 18px 12px;
    border: 1px solid #e5e7eb;
}

.utility-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 25px;
    color: #2563eb;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(37,99,235,0.04);
    position: relative;
}

.utility-btn:hover {
    background: #e0e7ff;
    border-color: #2563eb;
    color: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37,99,235,0.10);
}

.utility-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(37,99,235,0.08);
}

.utility-btn.active {
    background: #d1fae5;
    border-color: #5c83ee;
    color: #1d4ed8;
}

.utility-btn.active .btn-icon {
    animation: pulse 2s infinite;
}

.utility-btn.loading {
    background: #dbeafe;
    border-color: #3b82f6;
    color: #3b82f6;
    cursor: not-allowed;
}

.utility-btn.loading .btn-icon {
    animation: spin 1s linear infinite;
}

.btn-icon {
    font-size: 16px;
    line-height: 1;
}

.btn-text {
    font-size: 13px;
    font-weight: 500;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .utility-buttons {
        gap: 10px;
        margin: 15px 0;
        padding: 12px 6px;
    }
    .utility-btn {
        min-width: 100px;
        padding: 8px 12px;
        font-size: 13px;
    }
    .btn-text {
        font-size: 12px;
    }
    .btn-icon {
        font-size: 14px;
    }
}

/* Accessibility improvements */
.utility-btn:focus {
    outline: 2px solid rgba(59, 130, 246, 0.5);
    outline-offset: 2px;
}

.utility-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Status indicators */
.utility-btn::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: transparent;
    transition: all 0.3s ease;
}

.utility-btn.active::after {
    background: #1d4ed8;
    box-shadow: 0 0 6px rgba(34, 86, 197, 0.6);
}

/* Animations */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Modal (Help Popup) */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 10000; /* Sit on top, increased z-index */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow-y: auto; /* Enable vertical scroll if needed */
    background-color: rgba(0,0,0,0.7); /* Darker overlay */
    backdrop-filter: blur(8px); /* Stronger blur */
    -webkit-backdrop-filter: blur(8px); /* Safari support */
    padding: 20px; /* Add padding to prevent content touching edges */
    display: flex; /* Use flexbox for centering */
    align-items: center; /* Center vertically */
    justify-content: center; /* Center horizontally */
}

.modal-content {
    background-color: #3b82f6; /* Blue background */
    padding: 30px;
    border: 1px solid #888;
    width: 95%; /* Slightly smaller width for better mobile fit */
    max-width: 600px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); /* Stronger shadow */
    position: relative;
    color: #fff;
    font-family: Arial, sans-serif;
    animation: fadeIn 0.3s ease-out;
    max-height: 90vh; /* Limit height to viewport height */
    overflow-y: auto; /* Enable scrolling for content */
}

.modal-content h2 {
    color: #fff;
    margin-top: 0;
    font-size: 28px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.modal-content h3 {
    color: #e0f2f7;
    margin-top: 20px;
    font-size: 20px;
}

.modal-content p {
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 15px;
}

.modal-content ul {
    list-style-type: disc;
    margin-left: 20px;
    margin-bottom: 15px;
}

.modal-content ul li {
    margin-bottom: 8px;
    font-size: 15px;
}

.modal-content b {
    color: #ffeb3b; /* Yellow for emphasis */
}

.close-button {
    color: #fff;
    font-size: 30px;
    font-weight: bold;
    position: absolute;
    top: 10px;
    right: 20px;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close-button:hover,
.close-button:focus {
    color: #ccc;
    text-decoration: none;
    cursor: pointer;
}

.modal-footer {
    text-align: center;
    margin-top: 30px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
    .help-btn {
        top: 10px;
        right: 10px;
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    .modal-content {
        margin: 10% auto; /* Adjust margin for mobile */
        padding: 20px;
        width: 95%;
    }

    .modal-content h2 {
        font-size: 24px;
    }

    .modal-content h3 {
        font-size: 18px;
    }

    .modal-content p,
    .modal-content ul li {
        font-size: 14px;
    }

    .close-button {
        font-size: 26px;
        top: 5px;
        right: 15px;
    }
}