/**
 * Mercado na Prática — Layout
 * 
 * Header, Footer, Ticker, Mega-Menu, Busca
 */

/* ============================================
   HEADER
   ============================================ */
.site-header {
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-base), box-shadow var(--transition-base);
}

.site-header.scrolled {
    box-shadow: var(--shadow-md);
}

/* Top bar */
.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) 0;
    gap: var(--space-6);
}

/* Logo */
.header-logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-decoration: none;
    flex-shrink: 0;
}

.header-logo img {
    height: 36px;
    width: auto;
}

.header-logo-text {
    font-size: var(--text-lg);
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.header-logo-text span {
    color: var(--color-secondary);
}

/* Search */
.header-search {
    flex: 1;
    max-width: 480px;
    position: relative;
}

.header-search-input {
    width: 100%;
    padding: var(--space-2) var(--space-4);
    padding-left: 40px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-full);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: var(--text-sm);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.header-search-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(15, 52, 96, 0.1);
}

html.dark-mode .header-search-input:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.header-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: var(--text-sm);
    pointer-events: none;
}

/* Search dropdown */
.search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-height: 400px;
    overflow-y: auto;
    display: none;
    z-index: var(--z-dropdown);
    animation: slideDown 0.2s ease;
}

.search-dropdown.active {
    display: block;
}

.search-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    transition: background var(--transition-fast);
    cursor: pointer;
    text-decoration: none;
    color: var(--text-primary);
}

.search-item:hover,
.search-item.highlighted {
    background: var(--bg-card-hover);
}

.search-item-logo {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--border-color-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--text-secondary);
    overflow: hidden;
    flex-shrink: 0;
}

.search-item-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.search-item-info {
    flex: 1;
    min-width: 0;
}

.search-item-ticker {
    font-weight: 700;
    font-size: var(--text-sm);
}

.search-item-name {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-item-type {
    font-size: var(--text-xs);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: var(--color-info-bg);
    color: var(--color-info);
    font-weight: 600;
}

/* Header actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-shrink: 0;
}

/* Dark mode toggle */
.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    cursor: pointer;
    font-size: var(--text-lg);
    background: transparent;
    border: none;
}

.theme-toggle:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

/* ============================================
   NAVIGATION (Main Nav)
   ============================================ */
.main-nav {
    border-top: 1px solid var(--border-color);
}

.nav-list {
    display: flex;
    align-items: center;
    gap: 0;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-item {
    position: relative;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

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

.nav-link .arrow {
    font-size: 10px;
    transition: transform var(--transition-fast);
}

.nav-item:hover .nav-link .arrow {
    transform: rotate(180deg);
}

/* ============================================
   MEGA MENU (Dropdown)
   ============================================ */
.mega-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 280px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: var(--space-4);
    display: none;
    z-index: var(--z-dropdown);
    animation: slideDown 0.2s ease;
}

.nav-item:hover .mega-menu {
    display: block;
}

.mega-menu-section {
    margin-bottom: var(--space-4);
}

.mega-menu-section:last-child {
    margin-bottom: 0;
}

.mega-menu-label {
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: var(--space-1) var(--space-3);
    margin-bottom: var(--space-1);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.mega-menu-link {
    display: block;
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    text-decoration: none;
}

.mega-menu-link:hover {
    background: var(--bg-card-hover);
    color: var(--color-primary);
}

.mega-menu-link.disabled {
    color: var(--text-tertiary);
    cursor: not-allowed;
}

.mega-menu-link.disabled::after {
    content: 'Em breve';
    font-size: var(--text-xs);
    margin-left: var(--space-2);
    padding: 1px 6px;
    border-radius: var(--radius-full);
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

/* ============================================
   TICKER (Barra de Cotações)
   ============================================ */
.ticker-bar {
    background: var(--bg-ticker);
    color: #FFFFFF;
    overflow: hidden;
    position: relative;
    height: 36px;
    display: flex;
    align-items: center;
}

.ticker-track {
    display: flex;
    animation: scroll 40s linear infinite;
    white-space: nowrap;
}

.ticker-track:hover {
    animation-play-state: paused;
}

.ticker-item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0 var(--space-6);
    font-size: var(--text-xs);
    font-family: var(--font-mono);
    font-weight: 500;
    text-decoration: none;
    color: #FFFFFF;
    transition: opacity var(--transition-fast);
    flex-shrink: 0;
}

.ticker-item:hover {
    opacity: 0.7;
    color: #FFFFFF;
}

.ticker-name {
    font-weight: 700;
    color: rgba(255, 255, 255, 0.7);
}

.ticker-price {
    font-weight: 500;
}

.ticker-change {
    font-weight: 600;
}

.ticker-change.positive {
    color: #34D399;
}

.ticker-change.negative {
    color: #F87171;
}

.ticker-separator {
    width: 1px;
    height: 16px;
    background: rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

/* ============================================
   FOOTER
   ============================================ */
.site-footer {
    background: var(--bg-footer);
    color: #9CA3AF;
    padding: var(--space-16) 0 var(--space-8);
    margin-top: var(--space-16);
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
    gap: var(--space-8);
}

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

.footer-brand-name {
    font-size: var(--text-xl);
    font-weight: 800;
    color: #FFFFFF;
    margin-bottom: var(--space-3);
}

.footer-brand-name span {
    color: var(--color-secondary);
}

.footer-brand-desc {
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
    color: #6B7280;
}

.footer-column-title {
    font-size: var(--text-sm);
    font-weight: 700;
    color: #FFFFFF;
    margin-bottom: var(--space-4);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.footer-links {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.footer-link {
    font-size: var(--text-sm);
    color: #6B7280;
    text-decoration: none;
    transition: color var(--transition-fast);
}

.footer-link:hover {
    color: var(--color-secondary);
}

.footer-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: var(--space-12);
    padding-top: var(--space-8);
    border-top: 1px solid #1F2937;
    font-size: var(--text-xs);
    color: #6B7280;
}

.footer-social {
    display: flex;
    gap: var(--space-4);
}

.footer-social a {
    color: #6B7280;
    font-size: var(--text-lg);
    transition: color var(--transition-fast);
}

.footer-social a:hover {
    color: var(--color-secondary);
}

/* ============================================
   MOBILE MENU
   ============================================ */
.mobile-toggle {
    display: none;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xl);
    color: var(--text-primary);
    cursor: pointer;
    background: transparent;
    border: none;
}

.mobile-drawer {
    display: none;
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
}

.mobile-drawer.active {
    display: block;
}

.mobile-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s ease;
}

.mobile-panel {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 300px;
    max-width: 85%;
    background: var(--bg-card);
    padding: var(--space-6);
    overflow-y: auto;
    animation: slideRight 0.3s ease;
}

@keyframes slideRight {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

.mobile-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xl);
    color: var(--text-secondary);
    cursor: pointer;
    margin-bottom: var(--space-6);
    background: transparent;
    border: none;
}

.mobile-nav-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.mobile-nav-link {
    display: block;
    padding: var(--space-3) var(--space-3);
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--text-primary);
    border-radius: var(--radius-md);
    text-decoration: none;
}

.mobile-nav-link:hover {
    background: var(--bg-card-hover);
}

.mobile-subnav {
    padding-left: var(--space-6);
    display: none;
}

.mobile-subnav.active {
    display: block;
}

.mobile-subnav-link {
    display: block;
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    text-decoration: none;
}

/* ============================================
   PAGE CONTENT
   ============================================ */
.page-content {
    min-height: calc(100vh - 200px);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1199px) {
    .footer-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-6);
    }

    .footer-brand {
        grid-column: span 3;
        max-width: 100%;
    }
}

@media (max-width: 767px) {
    .header-search {
        display: none;
    }

    .mobile-toggle {
        display: flex;
    }

    .main-nav {
        display: none;
    }

    .header-top {
        padding: var(--space-2) 0;
    }

    .header-logo-text {
        font-size: var(--text-base);
    }

    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-4);
    }

    .footer-brand {
        grid-column: span 2;
    }

    .footer-bottom {
        flex-direction: column;
        gap: var(--space-4);
        text-align: center;
    }

    .section {
        padding: var(--space-8) 0;
    }

    .section-title {
        font-size: var(--text-xl);
    }

    .container {
        padding: 0 var(--space-4);
    }
}

@media (max-width: 480px) {
    .footer-grid {
        grid-template-columns: 1fr;
    }

    .footer-brand {
        grid-column: span 1;
    }
}
