/* Base Styles */
:root {
    --primary-color: #00CED1;
    --secondary-color: #40E0D0;
    --accent-color: #00BCD4;
    --background-color: #ffffff;
    --card-color: #ffffff;
    --text-color: #2d3436;
    --light-text: #636e72;
    --success-color: #00b894;
    --error-color: #d63031;
    --shadow: 0 8px 15px rgba(0, 0, 0, 0.08);
    --transition: all 0.3s ease-in-out;
}

/* Make sure the box sizing is consistent */
* {
    box-sizing: border-box;
}

/* Add viewport-based font sizing for better responsiveness */
html {
    font-size: 16px;
}

body {
    margin: 0;
    padding: 0;
    overflow-x: hidden; /* Prevent horizontal scrolling on mobile */
}

/* Container styles */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Styles */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    margin-bottom: 25px;
    background-color: var(--primary-color);
    border-radius: 15px;
    box-shadow: var(--shadow);
    flex-wrap: wrap; /* Allow wrapping on small screens */
    gap: 15px; /* Add space between wrapped elements */
    margin-top: 15px;
}

.logo {
    display: flex;
    align-items: center;
}

.logo i {
    font-size: 1.5rem;
    margin-right: 8px;
    color: #333333;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #00CED1;
    color: white;
}

.logo h1 {
    font-weight: 600;
    color: #333333;
    font-size: 1.4rem;
    margin: 0;
}

.logo span {
    color: var(--accent-color);
}

.search-box {
    display: flex;
    background: var(--card-color);
    border-radius: 50px;
    padding: 8px 15px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
    width: 300px;
    transition: var(--transition);
}

.search-box input {
    border: none;
    outline: none;
    background: transparent;
    width: 100%;
    padding: 5px;
    font-family: inherit;
    font-size: 0.95rem;
}

.search-box button {
    background: transparent;
    border: none;
    cursor: pointer;
    color: #888;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-box button:hover {
    color: var(--accent-color);
}

/* Market Overview */
.market-overview {
    background: var(--card-color);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: var(--shadow);
}

.market-overview h2 {
    margin-bottom: 20px;
    color: var(--text-color);
    font-weight: 600;
    position: relative;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-color);
    font-size: 1.5rem;
}

.market-stats {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
}

.stat-card {
    flex: 1;
    min-width: 200px;
    padding: 15px;
    border-radius: 12px;
    background: linear-gradient(145deg, #f8f9fd, #ffffff);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    transition: var(--transition);
    border-left: 4px solid var(--primary-color);
}

.stat-card p {
    color: var(--light-text);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.stat-card h3 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.change {
    font-size: 0.85rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 20px;
    display: inline-block;
}

.change.up {
    background-color: rgba(0, 184, 148, 0.1);
    color: var(--success-color);
}

.change.down {
    background-color: rgba(214, 48, 49, 0.1);
    color: var(--error-color);
}

/* Crypto List */
.crypto-list-container {
    background: var(--card-color);
    border-radius: 15px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap; /* Allow wrapping on small screens */
    gap: 10px; /* Add space between wrapped elements */
}

.list-header h2 {
    font-weight: 600;
    position: relative;
    padding-bottom: 8px;
    border-bottom: 3px solid var(--primary-color);
    font-size: 1.5rem;
}

.view-options button {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    color: var(--light-text);
    margin-left: 10px;
    cursor: pointer;
    transition: var(--transition);
}

.view-options button:hover,
.view-options button.active {
    color: var(--primary-color);
}

.crypto-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.crypto-list.list-view {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.crypto-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    transition: var(--transition);
    animation: fadeIn 0.5s ease-in-out;
}

.crypto-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
}

.card-header {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.crypto-icon-container {
    margin-right: 10px;
}

.crypto-title {
    flex-grow: 1;
}

.crypto-name {
    font-size: 1.1rem;
    margin-bottom: 2px;
    font-weight: 600;
}

.crypto-symbol {
    font-size: 0.8rem;
    color: var(--light-text);
    font-weight: 500;
}

.card-body {
    display: flex;
    flex-direction: column;
}

.current-price {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.current-price p {
    font-size: 0.85rem;
    color: var(--light-text);
}

.price-value {
    font-size: 1.3rem;
    font-weight: 600;
}

.price-change {
    position: relative;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
}

.sparkline {
    height: 60px;
    margin-bottom: 15px;
    background-color: rgba(250, 250, 250, 0.5);
    border-radius: 8px;
}

.card-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    flex-wrap: wrap; /* Allow stats to wrap on small mobile screens */
    gap: 10px;
}

.stat {
    flex: 1;
    min-width: calc(50% - 10px); /* Ensure stats stack nicely on small screens */
}

.stat p {
    font-size: 0.75rem;
    color: var(--light-text);
    margin-bottom: 2px;
}

.stat span {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Loading Styles */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(253, 200, 87, 0.2);
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 30px;
    padding: 20px;
    color: var(--light-text);
    font-size: 0.9rem;
}

.update-time {
    font-style: italic;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mobile Responsiveness */
@media screen and (max-width: 768px) {
    html {
        font-size: 15px; /* Slightly smaller base font size for mobile */
    }
    
    .container {
        padding: 0 15px;
    }
    
    header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .logo {
        justify-content: center;
        margin-bottom: 10px;
    }
    
    .search-box {
        width: 100%;
        max-width: none;
    }
    
    .market-stats {
        flex-direction: column;
    }
    
    .stat-card {
        width: 100%;
        min-width: 100%;
    }
    
    .crypto-list {
        grid-template-columns: 1fr; /* Single column for mobile */
    }
    
    .list-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .view-options {
        width: 100%;
        display: flex;
        justify-content: flex-end;
        margin-top: 10px;
    }
    
    .crypto-card {
        padding: 15px; /* Smaller padding on mobile */
    }
}

/* Small mobile screens */
@media screen and (max-width: 480px) {
    html {
        font-size: 14px; /* Even smaller base font size for tiny screens */
    }
    
    .market-overview h2,
    .list-header h2 {
        font-size: 1.3rem;
    }
    
    .stat-card h3 {
        font-size: 1.3rem;
    }
    
    .crypto-name {
        font-size: 1rem;
    }
    
    .price-value {
        font-size: 1.1rem;
    }
    
    .card-stats {
        flex-direction: column; /* Stack stats vertically on tiny screens */
    }
    
    .stat {
        margin-bottom: 8px;
    }
    
    /* Touch-friendly improvements */
    .view-options button {
        font-size: 1.4rem; /* Larger touch targets */
        margin-left: 15px;
        padding: 5px;
    }
    
    .crypto-card {
        padding: 12px;
        margin-bottom: 15px;
    }
    
    /* Better tap targets */
    .card-header {
        min-height: 50px;
    }
}

/* Additional accessibility features for touch screens */
@media (hover: none) {
    /* Styles optimized for touch screens */
    .crypto-card:hover {
        transform: none; /* Remove hover effects on touch devices */
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    }
    
    /* Make interactive elements more tappable */
    .view-options button,
    .search-box button {
        min-height: 44px; /* Apple's recommended minimum tap target size */
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Handle device orientation */
@media screen and (orientation: landscape) and (max-height: 500px) {
    /* Adjustments for landscape mode on phones */
    .market-overview,
    .crypto-list-container {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .crypto-list {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
    
    /* Compact the header to save vertical space */
    header {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 10px;
    }
    
    /* Reduce whitespace to fit more content */
    .market-stats {
        gap: 10px;
    }
}
