:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-light: #f8fafc;
    --text-light: #1e293b;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dark-mode {
    --primary: #818cf8;
    --primary-hover: #6366f1;
    --bg-light: #0f172a;
    --text-light: #f1f5f9;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-light);
    color: var(--text-light);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.5s ease;
}

/* Background Decorations */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    filter: blur(80px);
}

.blob {
    position: absolute;
    border-radius: 50%;
    opacity: 0.5;
    animation: move 20s infinite alternate;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: #6366f1;
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 300px;
    height: 300px;
    background: #ec4899;
    bottom: -50px;
    right: -50px;
    animation-delay: -5s;
}

.blob-3 {
    width: 250px;
    height: 250px;
    background: #06b6d4;
    top: 40%;
    right: 20%;
    animation-delay: -10s;
}

@keyframes move {
    from { transform: translate(0, 0) scale(1); }
    to { transform: translate(100px, 50px) scale(1.1); }
}

/* App Layout */
.app-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 2rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.icon-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    width: 45px;
    height: 45px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    backdrop-filter: blur(10px);
    transition: var(--transition);
}

.icon-btn:hover {
    transform: translateY(-2px);
    background: var(--glass-border);
}

/* Glass Card */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.converter-card {
    padding: 2.5rem;
    margin-bottom: 2rem;
}

.input-group {
    margin-bottom: 2rem;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
    opacity: 0.8;
}

.input-group input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--glass-border);
    border-radius: 16px;
    padding: 1rem 1.25rem;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-light);
    outline: none;
    transition: var(--transition);
}

.input-group input:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.1);
}

/* Selectors Row */
.selectors-row {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.currency-select-box {
    flex: 1;
}

.currency-select-box label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
    opacity: 0.8;
}

.custom-select {
    cursor: pointer;
}

.select-trigger {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--glass-border);
    border-radius: 16px;
    padding: 0.875rem 1.25rem;
    transition: var(--transition);
}

.select-trigger:hover {
    border-color: var(--primary);
}

.flag {
    width: 28px;
    height: 20px;
    object-fit: cover;
    border-radius: 4px;
}

.selected-code {
    font-weight: 600;
    font-size: 1.125rem;
}

.chevron {
    margin-left: auto;
    font-size: 0.75rem;
    opacity: 0.5;
}

.swap-btn {
    width: 54px;
    height: 54px;
    border-radius: 16px;
    background: var(--primary);
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    margin-bottom: 0;
}

.swap-btn:hover {
    transform: rotate(180deg) scale(1.05);
    background: var(--primary-hover);
}

/* Result Area */
.result-area {
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    margin-bottom: 2rem;
}

#converted-amount {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

#exchange-rate-info {
    font-size: 1rem;
    opacity: 0.7;
}

.primary-btn {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 1.25rem;
    border-radius: 16px;
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(99, 102, 241, 0.4);
}

/* Favorites */
.favorites-section {
    margin-bottom: 3rem;
}

.favorites-section h3 {
    font-size: 1rem;
    margin-bottom: 1.25rem;
    opacity: 0.8;
}

.favorites-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.fav-chip {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 0.625rem 1.25rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    backdrop-filter: blur(10px);
}

.fav-chip:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Bottom Grid */
.bottom-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 2rem;
}

.history-card, .trends-card {
    padding: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.text-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    font-size: 0.875rem;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
}

.history-item .codes {
    font-weight: 500;
}

.history-item .val {
    font-weight: 700;
    color: var(--primary);
}

.empty-msg {
    text-align: center;
    opacity: 0.5;
    font-size: 0.875rem;
    padding: 1rem 0;
}

.trend-item {
    display: flex;
    justify-content: space-between;
    padding: 1rem 0;
    border-bottom: 1px solid var(--glass-border);
}

.trend-item:last-child {
    border-bottom: none;
}

.trend-label {
    font-weight: 500;
}

.trend-value {
    font-weight: 700;
    color: #10b981;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(5px);
}

.modal-content {
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.close-modal {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-light);
}

.search-box input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    color: var(--text-light);
    outline: none;
}

.currency-list {
    overflow-y: auto;
    flex: 1;
}

.currency-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
}

.currency-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.currency-info {
    display: flex;
    flex-direction: column;
}

.curr-code {
    font-weight: 700;
}

.curr-name {
    font-size: 0.75rem;
    opacity: 0.6;
}

/* Utils */
.hidden { display: none !important; }

.loader {
    width: 40px;
    height: 40px;
    border: 4px solid var(--glass-border);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-light);
    color: var(--bg-light);
    padding: 1rem 2rem;
    border-radius: 50px;
    font-weight: 600;
    z-index: 2000;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { bottom: 0; opacity: 0; }
    to { bottom: 2rem; opacity: 1; }
}

footer {
    text-align: center;
    margin-top: 4rem;
    opacity: 0.5;
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
    .selectors-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .swap-btn {
        align-self: center;
        margin: -0.5rem 0;
        z-index: 2;
    }

    .bottom-grid {
        grid-template-columns: 1fr;
    }

    .app-container {
        padding: 1rem;
    }

    .converter-card {
        padding: 1.5rem;
    }
}
