/* ==================== Apple Design System ==================== */
/* Reset & Base */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Apple Color Palette */
    --color-blue: #007AFF;
    --color-blue-dark: #0051D5;
    --color-blue-light: #5AC8FA;
    --color-indigo: #5856D6;
    --color-green: #34C759;
    --color-red: #FF3B30;
    --color-orange: #FF9500;
    --color-yellow: #FFCC00;
    
    /* Neutral Colors */
    --color-gray-1: #F5F5F7;
    --color-gray-2: #E8E8ED;
    --color-gray-3: #D1D1D6;
    --color-gray-4: #C7C7CC;
    --color-gray-5: #AEAEB2;
    --color-gray-6: #8E8E93;
    --color-gray-7: #636366;
    --color-gray-8: #48484A;
    --color-gray-9: #3A3A3C;
    --color-gray-10: #2C2C2E;
    --color-gray-11: #1C1C1E;
    
    /* Semantic Colors */
    --color-text-primary: #1D1D1F;
    --color-text-secondary: #86868B;
    --color-text-tertiary: #AEAEB2;
    --color-background: #FFFFFF;
    --color-background-secondary: #F5F5F7;
    --color-background-elevated: #FFFFFF;
    
    /* Borders & Dividers */
    --color-border: rgba(0, 0, 0, 0.06);
    --color-divider: rgba(0, 0, 0, 0.08);
    
    /* Shadows */
    --shadow-small: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-medium: 0 4px 6px rgba(0, 0, 0, 0.04), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-large: 0 10px 15px rgba(0, 0, 0, 0.05), 0 4px 6px rgba(0, 0, 0, 0.08);
    --shadow-xlarge: 0 20px 25px rgba(0, 0, 0, 0.06), 0 8px 10px rgba(0, 0, 0, 0.08);
    
    /* Blur Effects */
    --blur-small: blur(10px);
    --blur-medium: blur(20px);
    --blur-large: blur(40px);
    
    /* Border Radius */
    --radius-small: 8px;
    --radius-medium: 12px;
    --radius-large: 16px;
    --radius-xlarge: 20px;
    
    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 24px;
    --space-2xl: 32px;
    --space-3xl: 48px;
    --space-4xl: 64px;
    
    /* Typography */
    --font-weight-regular: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #F5F5F7 0%, #E8E8ED 100%);
    background-attachment: fixed;
    min-height: 100vh;
    color: var(--color-text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
    padding: var(--space-xl);
}

/* ==================== Container ==================== */
.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ==================== Header ==================== */
header {
    text-align: center;
    margin-bottom: var(--space-4xl);
    padding: var(--space-3xl) 0;
}

.header-content {
    margin-bottom: var(--space-2xl);
}

header h1 {
    font-size: 3.5rem;
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
    letter-spacing: -0.02em;
    margin-bottom: var(--space-md);
}

.header-subtitle {
    font-size: 1.125rem;
    font-weight: var(--font-weight-regular);
    color: var(--color-text-secondary);
    letter-spacing: -0.01em;
}

.header-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xl);
    flex-wrap: wrap;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
}

.info-label {
    font-size: 0.75rem;
    font-weight: var(--font-weight-medium);
    color: var(--color-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-value {
    font-size: 0.9375rem;
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
}

.info-divider {
    width: 1px;
    height: 24px;
    background: var(--color-divider);
}

/* ==================== Toolbar ==================== */
.toolbar {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
    flex-wrap: wrap;
}

/* Search Box */
.search-box {
    flex: 1;
    min-width: 280px;
    position: relative;
}

.search-icon {
    position: absolute;
    left: var(--space-lg);
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--color-text-tertiary);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 14px 20px 14px 48px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-large);
    font-size: 0.9375rem;
    font-weight: var(--font-weight-regular);
    background: var(--color-background-elevated);
    backdrop-filter: var(--blur-medium);
    -webkit-backdrop-filter: var(--blur-medium);
    box-shadow: var(--shadow-small);
    transition: all var(--transition-base);
    color: var(--color-text-primary);
}

.search-box input::placeholder {
    color: var(--color-text-tertiary);
}

.search-box input:focus {
    outline: none;
    border-color: var(--color-blue);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1), var(--shadow-medium);
    background: var(--color-background);
}

/* Filter Buttons */
.filter-buttons {
    display: flex;
    gap: var(--space-sm);
}

.filter-btn {
    padding: 12px 24px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-large);
    background: var(--color-background-elevated);
    backdrop-filter: var(--blur-medium);
    -webkit-backdrop-filter: var(--blur-medium);
    color: var(--color-text-primary);
    font-size: 0.9375rem;
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    box-shadow: var(--shadow-small);
    transition: all var(--transition-base);
    white-space: nowrap;
}

.filter-btn:hover {
    background: var(--color-background);
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

.filter-btn.active {
    background: var(--color-blue);
    color: white;
    border-color: var(--color-blue);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.15), var(--shadow-medium);
}

.filter-btn.active:hover {
    background: var(--color-blue-dark);
    border-color: var(--color-blue-dark);
    transform: translateY(-1px);
}

/* ==================== Info Banner ==================== */
.info-banner {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    background: rgba(0, 122, 255, 0.05);
    backdrop-filter: var(--blur-medium);
    -webkit-backdrop-filter: var(--blur-medium);
    padding: var(--space-lg) var(--space-xl);
    border-radius: var(--radius-large);
    margin-bottom: var(--space-xl);
    border: 1.5px solid rgba(0, 122, 255, 0.12);
}

.info-icon {
    width: 20px;
    height: 20px;
    color: var(--color-blue);
    flex-shrink: 0;
}

.info-banner span {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    font-weight: var(--font-weight-regular);
    line-height: 1.5;
}

/* ==================== Loading State ==================== */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-4xl) var(--space-xl);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(0, 122, 255, 0.15);
    border-top-color: var(--color-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: var(--space-xl);
}

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

.loading-text {
    font-size: 1.0625rem;
    color: var(--color-text-secondary);
    font-weight: var(--font-weight-medium);
}

.loading-state.hidden {
    display: none;
}

/* ==================== Error State ==================== */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-lg);
    background: rgba(255, 59, 48, 0.05);
    border: 1.5px solid rgba(255, 59, 48, 0.15);
    padding: var(--space-3xl) var(--space-xl);
    border-radius: var(--radius-xlarge);
    margin-bottom: var(--space-xl);
    text-align: center;
}

.error-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 59, 48, 0.1);
    border-radius: 50%;
}

.error-icon svg {
    width: 28px;
    height: 28px;
    color: var(--color-red);
}

.error-text {
    font-size: 1.0625rem;
    color: var(--color-red);
    font-weight: var(--font-weight-medium);
}

.retry-button {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 12px 24px;
    background: var(--color-red);
    color: white;
    border: none;
    border-radius: var(--radius-medium);
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: var(--font-weight-semibold);
    transition: all var(--transition-base);
    box-shadow: var(--shadow-medium);
}

.retry-button svg {
    width: 16px;
    height: 16px;
}

.retry-button:hover {
    background: #d70015;
    transform: translateY(-1px);
    box-shadow: var(--shadow-large);
}

.retry-button:active {
    transform: translateY(0);
}

/* ==================== Currency Grid ==================== */
.currency-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-lg);
    animation: fadeIn 0.4s ease-out;
}

/* ==================== Currency Card ==================== */
.currency-card {
    background: var(--color-background-elevated);
    backdrop-filter: var(--blur-medium);
    -webkit-backdrop-filter: var(--blur-medium);
    border-radius: var(--radius-large);
    padding: var(--space-lg);
    box-shadow: var(--shadow-small);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    transition: all var(--transition-base);
    border: 1.5px solid var(--color-border);
    position: relative;
    overflow: hidden;
}

.currency-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: transparent;
    transition: all var(--transition-base);
}

.currency-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-large);
    border-color: var(--color-gray-3);
}

.currency-card.priority::before {
    background: var(--color-blue);
}

.currency-card.active {
    border-color: var(--color-blue);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1), var(--shadow-large);
}

.currency-card.hidden {
    display: none;
}

/* Currency Icon */
.currency-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.08), rgba(88, 86, 214, 0.08));
    border-radius: var(--radius-medium);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    flex-shrink: 0;
    border: 1.5px solid rgba(0, 122, 255, 0.12);
    transition: all var(--transition-base);
}

.currency-card:hover .currency-icon {
    transform: scale(1.05);
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.12), rgba(88, 86, 214, 0.12));
}

/* Currency Info */
.currency-info {
    flex: 0 0 100px;
}

.currency-code {
    font-size: 1.125rem;
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
    letter-spacing: -0.01em;
    margin-bottom: var(--space-xs);
}

.currency-name {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    font-weight: var(--font-weight-regular);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 110px;
}

/* Currency Input */
.currency-input {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.currency-input input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-medium);
    font-size: 1.0625rem;
    font-weight: var(--font-weight-medium);
    text-align: right;
    transition: all var(--transition-base);
    color: var(--color-text-primary);
    background: rgba(0, 0, 0, 0.02);
}

.currency-input input:focus {
    outline: none;
    border-color: var(--color-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
    background: var(--color-background);
}

.currency-input input::placeholder {
    color: var(--color-text-tertiary);
    font-weight: var(--font-weight-regular);
}

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

.currency-input input[type=number] {
    -moz-appearance: textfield;
}

.currency-rate {
    font-size: 0.6875rem;
    color: var(--color-text-tertiary);
    text-align: right;
    margin-top: var(--space-sm);
    font-weight: var(--font-weight-regular);
    letter-spacing: 0.01em;
}

/* ==================== Footer ==================== */
footer {
    text-align: center;
    padding: var(--space-4xl) var(--space-xl) var(--space-2xl);
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
}

.footer-text {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    font-weight: var(--font-weight-regular);
}

.footer-text a {
    color: var(--color-blue);
    text-decoration: none;
    font-weight: var(--font-weight-medium);
    transition: opacity var(--transition-fast);
}

.footer-text a:hover {
    opacity: 0.7;
}

.footer-note {
    color: var(--color-text-tertiary);
    font-size: 0.8125rem;
    font-weight: var(--font-weight-regular);
}

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

.currency-card {
    animation: fadeIn 0.4s ease-out backwards;
}

/* Staggered animation for cards */
.currency-card:nth-child(1) { animation-delay: 0.02s; }
.currency-card:nth-child(2) { animation-delay: 0.04s; }
.currency-card:nth-child(3) { animation-delay: 0.06s; }
.currency-card:nth-child(4) { animation-delay: 0.08s; }
.currency-card:nth-child(5) { animation-delay: 0.1s; }
.currency-card:nth-child(6) { animation-delay: 0.12s; }
.currency-card:nth-child(7) { animation-delay: 0.14s; }
.currency-card:nth-child(8) { animation-delay: 0.16s; }
.currency-card:nth-child(9) { animation-delay: 0.18s; }
.currency-card:nth-child(10) { animation-delay: 0.2s; }
.currency-card:nth-child(11) { animation-delay: 0.22s; }
.currency-card:nth-child(12) { animation-delay: 0.24s; }

/* ==================== Scrollbar ==================== */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--color-gray-1);
    border-radius: var(--radius-small);
}

::-webkit-scrollbar-thumb {
    background: var(--color-gray-4);
    border-radius: var(--radius-small);
    transition: background var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-gray-5);
}

/* ==================== Responsive Design ==================== */
@media (max-width: 768px) {
    body {
        padding: var(--space-md);
    }
    
    header {
        padding: var(--space-xl) 0;
        margin-bottom: var(--space-2xl);
    }
    
    header h1 {
        font-size: 2.25rem;
    }
    
    .header-subtitle {
        font-size: 1rem;
    }
    
    .header-info {
        flex-direction: column;
        gap: var(--space-md);
    }
    
    .info-divider {
        width: 40px;
        height: 1px;
    }
    
    .toolbar {
        flex-direction: column;
    }
    
    .search-box {
        min-width: auto;
    }
    
    .filter-buttons {
        justify-content: center;
        width: 100%;
    }
    
    .filter-btn {
        flex: 1;
    }
    
    .currency-grid {
        grid-template-columns: 1fr;
    }
    
    .currency-card {
        padding: var(--space-md);
    }
    
    .currency-icon {
        width: 48px;
        height: 48px;
        font-size: 1.5rem;
    }
    
    .currency-info {
        flex: 0 0 85px;
    }
    
    .currency-code {
        font-size: 1rem;
    }
    
    .currency-name {
        font-size: 0.75rem;
        max-width: 90px;
    }
    
    .currency-input input {
        font-size: 0.9375rem;
    }
    
    footer {
        padding: var(--space-2xl) var(--space-md) var(--space-xl);
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.875rem;
    }
    
    .header-subtitle {
        font-size: 0.9375rem;
    }
    
    .info-label {
        font-size: 0.6875rem;
    }
    
    .info-value {
        font-size: 0.875rem;
    }
}

/* ==================== Print Styles ==================== */
@media print {
    body {
        background: white;
        padding: 0;
    }
    
    .toolbar,
    .info-banner,
    .loading-state,
    .error-state,
    footer {
        display: none;
    }
    
    .currency-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid var(--color-border);
    }
}
