@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap');

:root {
    --primary: #FF7F50; /* Coral */
    --secondary: #4ECDC4; /* Medium Turquoise */
    --accent: #FFD166; /* Mango Tango */
    --background: #F9F7F3; /* Soft Ivory */
    --card-bg: #FFFFFF;
    --dark: #2D3142;
    --success: #7AC74F; /* Bright green */
    --danger: #FF5C5C; /* Soft red */
    --text: #333333;
    --border-radius: 16px;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Nunito', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
}

body {
    background-color: var(--background);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 16px;
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

header {
    background-color: var(--card-bg);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 10;
    width: 100%;
    position: relative;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
}

.logo h1 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 0.5px;
}

.nav-links {
    display: flex;
    gap: 1rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--dark);
    font-weight: 700;
    font-size: 0.9rem;
    padding: 0.5rem 0.8rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.nav-links a:hover {
    color: var(--primary);
    background-color: rgba(255, 127, 80, 0.1);
}

.container {
    max-width: 100%;
    width: 100%;
    margin: 1.5rem auto;
    padding: 0 1rem;
    flex: 1;
}

.swap-container {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    max-width: 550px;
    margin: 0 auto;
    position: relative;
    border: 3px solid var(--primary);
    width: 100%;
}

.swap-header {
    padding: 1.5rem 1rem;
    background: linear-gradient(135deg, var(--primary) 0%, #FF9F7D 100%);
    color: white;
    text-align: center;
    position: relative;
    border-bottom-left-radius: 30px;
}

.swap-header h2 {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

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

.swap-header .gerbil-mascot {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(-50%); }
    50% { transform: translateY(-60%); }
}

.swap-body {
    padding: 1.5rem 1rem;
}

.swap-stages {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
    position: relative;
}

.swap-stages:before {
    content: '';
    position: absolute;
    top: 25px;
    left: 15%;
    right: 15%;
    height: 3px;
    background-color: #e2e8f0;
    z-index: 0;
}

.stage {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 1;
}

.stage-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.8rem;
    position: relative;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text);
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.stage.active .stage-icon {
    background-color: var(--primary);
    color: white;
    transform: scale(1.15);
    box-shadow: 0 6px 15px rgba(255, 127, 80, 0.3);
}

.stage.completed .stage-icon {
    background-color: var(--success);
    color: white;
}

.stage-icon:hover {
    transform: scale(1.1);
}

.stage p {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
}

.stage.active p {
    color: var(--primary);
}

.swap-step {
    margin-bottom: 2rem;
    position: relative;
}

.swap-step h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary);
    font-weight: 800;
}

.step-number {
    background-color: var(--primary);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    box-shadow: 0 4px 8px rgba(255, 127, 80, 0.3);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--dark);
}

.form-control {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    font-weight: 600;
    color: var(--dark);
    -webkit-appearance: none;
    appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(255, 127, 80, 0.2);
}

.form-control::placeholder {
    color: #a0aec0;
}

.currency-input {
    display: flex;
    align-items: center;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.currency-input:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(255, 127, 80, 0.2);
}

.currency-input input {
    flex: 1;
    border: none;
    padding: 0.8rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--dark);
    -webkit-appearance: none;
    appearance: none;
}

.currency-input input:focus {
    outline: none;
}

.currency-select {
    padding: 0.8rem 1rem;
    background-color: #f8fafc;
    border-left: 2px solid #e2e8f0;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--dark);
    font-size: 0.9rem;
}

.currency-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: #f1f5f9;
}

.swap-direction {
    text-align: center;
    margin: 1.2rem 0;
    position: relative;
}

.swap-direction button {
    background-color: var(--secondary);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(78, 205, 196, 0.3);
    transition: all 0.3s ease;
    color: white;
    margin: 0 auto;
}

.swap-direction button:hover,
.swap-direction button:active {
    transform: rotate(180deg);
}

.swap-info {
    background-color: #f8fafc;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.swap-info p {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.7rem;
    font-size: 0.9rem;
    flex-wrap: wrap;
}

.swap-info p span:first-child {
    color: #64748b;
    font-weight: 600;
}

.swap-info p span:last-child {
    font-weight: 700;
    color: var(--dark);
}

.price-display {
    font-weight: 700;
    letter-spacing: 0.3px;
    transition: all 0.3s ease;
    font-family: 'Nunito', sans-serif;
}

.price-crypto {
    font-size: 0.85rem;
    display: inline-block;
    margin-right: 10px;
    font-weight: 700;
}

#exchangeRate {
    font-weight: 700;
    color: var(--primary);
}

.btn {
    display: inline-block;
    padding: 0.9rem 1.2rem;
    border-radius: 12px;
    font-weight: 800;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    font-size: 1rem;
    letter-spacing: 0.5px;
    -webkit-appearance: none;
    appearance: none;
    max-width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #FF9F7D 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 127, 80, 0.4);
}

.btn-primary:hover,
.btn-primary:active {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(255, 127, 80, 0.5);
}

.btn-full {
    width: 100%;
}

footer {
    background-color: var(--card-bg);
    padding: 1.2rem 1rem;
    text-align: center;
    margin-top: auto;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.05);
}

.footer-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.footer-links a {
    color: var(--dark);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.footer-links a:hover {
    color: var(--primary);
}

.footer-text {
    font-size: 0.8rem;
    color: #64748b;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    overflow-y: auto;
}

.modal-content {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    max-width: 90%;
    width: 550px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.8rem;
    position: relative;
    box-shadow: var(--shadow);
    border: 3px solid var(--primary);
    margin: auto;
}

.modal-content h2 {
    font-size: 1.6rem;
    color: var(--primary);
    margin-bottom: 1.2rem;
    font-weight: 800;
    padding-right: 30px;
}

.close-modal {
    position: absolute;
    right: 1.2rem;
    top: 1.2rem;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--dark);
    transition: all 0.3s ease;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal:hover,
.close-modal:active {
    color: var(--primary);
    transform: rotate(90deg);
}

/* Loader */
.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 1.5rem auto;
}

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

/* Status badges */
.badge {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 700;
}

.badge-warning {
    background-color: rgba(255, 209, 102, 0.2);
    color: #b38600;
}

.badge-success {
    background-color: rgba(122, 199, 79, 0.2);
    color: #3d6327;
}

.badge-danger {
    background-color: rgba(255, 92, 92, 0.2);
    color: #cc2e2e;
}

/* Hamburger menu for mobile */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 21px;
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 1.5rem;
    z-index: 15;
    background: none;
    border: none;
    padding: 0;
}

.menu-toggle span {
    display: block;
    height: 3px;
    width: 100%;
    background-color: var(--dark);
    border-radius: 3px;
    transition: all 0.3s ease;
}

/* Fix iOS inputs */
input[type="text"], 
input[type="number"],
input[type="email"],
textarea {
    -webkit-appearance: none;
    appearance: none;
    border-radius: 12px;
}

input[type="number"]::-webkit-inner-spin-button, 
input[type="number"]::-webkit-outer-spin-button { 
    -webkit-appearance: none;
    appearance: none;
    margin: 0; 
}

/* Responsive styles */
@media (max-width: 768px) {
    html {
        font-size: 14px;
    }

    .menu-toggle {
        display: flex;
    }

    .nav-links {
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        background-color: var(--card-bg);
        flex-direction: column;
        align-items: center;
        padding: 1.5rem;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        transform: translateY(-100%);
        opacity: 0;
        transition: all 0.3s ease;
        z-index: 9;
    }

    .nav-links.active {
        transform: translateY(0);
        opacity: 1;
    }

    .swap-header .gerbil-mascot {
        width: 40px;
        height: 40px;
    }

    .swap-body {
        padding: 1.2rem 1rem;
    }

    .swap-step h3 {
        font-size: 1.1rem;
    }

    .stage p {
        font-size: 0.75rem;
    }

    .stage-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }

    .swap-stages:before {
        top: 20px;
    }

    .footer-links {
        gap: 1rem;
    }

    /* Add fixed positioning for Safari to solve overflow issues */
    .modal {
        position: fixed;
        -webkit-overflow-scrolling: touch;
    }

    /* Fix for iOS position fixed issues */
    .swap-container {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
}

/* Small screen adjustments */
@media (max-width: 480px) {
    html {
        font-size: 13px;
    }

    .logo img {
        width: 35px;
        height: 35px;
    }

    .logo h1 {
        font-size: 1.2rem;
    }

    .stage-icon {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }

    .swap-stages:before {
        top: 18px;
    }

    .step-number {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }

    /* Fixed swap button to maintain circular shape */
    .swap-direction button {
        width: 44px;
        height: 44px;
    }

    .btn {
        padding: 0.8rem 1rem;
    }

    /* Enhance tap targets */
    .nav-links a,
    .btn,
    .close-modal {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* iOS Safari-specific fixes */
@supports (-webkit-touch-callout: none) {
    /* General iOS fixes */
    .modal-content {
        -webkit-overflow-scrolling: touch;
    }
    
    .form-control,
    .currency-input input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* High contrast mode */
@media (prefers-contrast: more) {
    :root {
        --primary: #D85A2E;
        --text: #000000;
        --dark: #000000;
    }
    
    .swap-info p span:first-child {
        color: #333333;
    }
    
    .form-control::placeholder {
        color: #555555;
    }
}

/* Additional animations */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Fix for notched devices */
@supports (padding-top: env(safe-area-inset-top)) {
    header {
        padding-top: max(1rem, env(safe-area-inset-top));
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    footer {
        padding-bottom: max(1.2rem, env(safe-area-inset-bottom));
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
}