/* reset & core styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

a {
    color: inherit;
    text-decoration: none;
}

input, select, button {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    background: none;
    border: none;
    outline: none;
}

.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
}

/* app grid structure */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    padding-top: 32px;
    padding-bottom: 64px;
}

/* sticky top navigation header */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-height);
    background-color: rgba(19, 23, 34, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

:root[data-theme="light"] .app-header {
    background-color: rgba(255, 255, 255, 0.85);
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

/* logo styling */
.brand-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.brand-logo .logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--border-radius-sm);
    background: var(--primary-gradient);
    color: #0b0e14;
    font-size: 18px;
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.25);
}

.brand-logo .logo-text span {
    color: var(--primary-color);
}

/* desktop navbar */
.nav-menu {
    display: flex;
    height: 100%;
}

.nav-list {
    display: flex;
    list-style: none;
    height: 100%;
    align-items: center;
    gap: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: color var(--transition-fast), background-color var(--transition-fast);
}

.nav-link:hover, .nav-link.active {
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
}

/* header utilities & user controls */
.header-utilities {
    display: flex;
    align-items: center;
    gap: 16px;
}

.utility-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: color var(--transition-fast), transform var(--transition-fast);
}

.utility-btn:hover {
    color: var(--text-primary);
    transform: scale(1.05);
}

.utility-btn .light-icon {
    display: none;
}

:root[data-theme="light"] .utility-btn .dark-icon {
    display: none;
}

:root[data-theme="light"] .utility-btn .light-icon {
    display: block;
}

.auth-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* user session dropdown dropdown menu */
.user-menu-wrapper {
    position: relative;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px 6px 8px;
    border-radius: 20px;
    background-color: var(--bg-tertiary);
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.user-menu-btn:hover {
    background-color: var(--border-color);
}

.user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: #0b0e14;
    font-size: 14px;
}

.user-name {
    font-weight: 500;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu-btn .caret {
    font-size: 10px;
    color: var(--text-secondary);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 180px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-md);
    padding: 6px;
    list-style: none;
    display: none;
}

.user-dropdown.show {
    display: block;
    animation: fadeInSlide 0.15s ease-out;
}

.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    transition: color var(--transition-fast), background-color var(--transition-fast);
}

.user-dropdown a:hover {
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
}

.user-dropdown .divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 6px 0;
}

/* mobile hamburger menu toggle */
.mobile-menu-toggle {
    display: none;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius-sm);
}

.mobile-menu-toggle:hover {
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
}

/* footer styling */
.app-footer-section {
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 64px 0 32px 0;
    transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.footer-top {
    display: flex;
    justify-content: space-between;
    gap: 48px;
    margin-bottom: 40px;
}

.footer-brand {
    max-width: 420px;
}

.footer-description {
    color: var(--text-secondary);
    margin-top: 16px;
    font-size: 14px;
}

.footer-links {
    display: flex;
    gap: 64px;
}

.links-column h4 {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.links-column ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.links-column a {
    color: var(--text-secondary);
    font-size: 14px;
    transition: color var(--transition-fast);
}

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

.footer-divider {
    border: none;
    height: 1px;
    background-color: var(--border-color);
    margin-bottom: 24px;
}

.footer-bottom {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.footer-bottom .disclaimer {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.6;
}

.footer-bottom .copyright {
    font-size: 13px;
    color: var(--text-muted);
}

/* animations */
@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Coin Detail Page Layout */
.coin-detail-page {
    margin-top: 16px;
}

.coin-detail-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.coin-detail-navigation .back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-weight: 500;
    transition: color var(--transition-fast);
}

.coin-detail-navigation .back-link:hover {
    color: var(--primary-color);
}

.coin-detail-header-block {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 24px;
}

.coin-identity {
    display: flex;
    align-items: center;
    gap: 16px;
}

.detail-coin-logo {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    background-color: var(--bg-tertiary);
}

.coin-title h1 {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.coin-title .badge {
    font-size: 16px;
    padding: 2px 8px;
    vertical-align: middle;
}

.rank-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    background-color: var(--bg-tertiary);
    color: var(--text-muted);
}

.coin-valuation {
    text-align: right;
}

.detail-price {
    font-family: var(--font-display);
    font-size: 36px;
    font-weight: 800;
    color: var(--text-primary);
}

.detail-change {
    font-size: 16px;
    font-weight: 600;
    margin-top: 4px;
}

.coin-detail-grid {
    display: grid;
    grid-template-columns: 2.2fr 1fr;
    gap: 32px;
    align-items: start;
}

.coin-detail-main {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.chart-card-container {
    padding: 24px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.chart-header h3 {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
}

.chart-timeframes {
    display: flex;
    gap: 6px;
    background-color: var(--bg-tertiary);
    padding: 4px;
    border-radius: 8px;
}

.timeframe-btn {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.timeframe-btn:hover {
    color: var(--text-primary);
}

.timeframe-btn.active {
    background-color: var(--bg-secondary);
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.chart-wrapper {
    position: relative;
    height: 400px;
    width: 100%;
}

#coin-detail-chart {
    width: 100% !important;
    height: 100% !important;
}

.chart-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(19, 23, 34, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 5;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.chart-loading-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.chart-loading-overlay i {
    font-size: 32px;
    color: var(--primary-color);
}

.source-breakdown-card {
    padding: 24px;
}

.source-breakdown-card .card-header {
    margin-bottom: 20px;
}

.source-breakdown-card h3 {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
}

.card-footer-tip {
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.description-card {
    padding: 24px;
}

.description-card h3 {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
}

.description-card p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 16px;
}

.description-card p:last-child {
    margin-bottom: 0;
}

.stats-sidebar-card {
    padding: 24px;
}

.stats-sidebar-card h3 {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.stats-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.stats-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.stats-list li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 14px;
}

.stat-value {
    color: var(--text-primary);
    font-size: 15px;
}

.stat-value-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.stat-subtext {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Header Search Bar & Autocomplete Dropdown */
.header-search {
    position: relative;
    width: 240px;
    margin: 0 16px;
}

@media (min-width: 1200px) {
    .header-search {
        width: 280px;
    }
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.search-input-wrapper .search-icon {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    font-size: 14px;
    pointer-events: none;
}

#navbar-search {
    width: 100%;
    padding: 8px 36px 8px 36px;
    font-size: 14px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

#navbar-search:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-input-wrapper .search-loader {
    position: absolute;
    right: 12px;
    color: var(--text-muted);
    font-size: 14px;
    display: none;
}

.search-input-wrapper .search-loader.show {
    display: block;
}

.search-results-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
    display: none;
}

.search-results-dropdown.show {
    display: block;
    animation: fadeInSlide 0.15s ease-out;
}

.search-results-list {
    list-style: none;
    padding: 6px;
    margin: 0;
}

.search-result-item {
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    margin-bottom: 2px;
}

.search-result-item:last-child {
    margin-bottom: 0;
}

.search-coin-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    transition: background-color var(--transition-fast);
}

.search-coin-link:hover {
    background-color: var(--bg-tertiary);
}

.search-coin-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.search-coin-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
    text-align: right;
}

.search-coin-logo {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    background-color: var(--bg-tertiary);
    flex-shrink: 0;
}

.search-coin-logo-placeholder {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    flex-shrink: 0;
}

.search-coin-names {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.search-coin-symbol {
    font-weight: 700;
    font-family: var(--font-display);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.2;
}

.search-coin-name {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    margin-top: 2px;
}

.search-coin-price {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.2;
}

.search-coin-change {
    font-size: 12px;
    font-weight: 600;
    margin-top: 2px;
    line-height: 1.2;
}

.search-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

