/* Smart Header - Always visible, row 2 collapses smoothly */
.smart-header {
    position: sticky;
    top: 0;
    z-index: 1020;
}

/* Smooth collapse for controls & stats section (Row 2) */
.header-details {
    max-height: 300px;
    opacity: 1;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.2s ease-out;
    will-change: max-height, opacity;
}

.smart-header.collapsed .header-details {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
}

/* Stats mini bar - hidden by default, shown when collapsed */
.stats-mini {
    display: none;
    font-size: 0.7rem;
    opacity: 0;
    transition: opacity 0.2s ease-in;
}

.smart-header.collapsed .stats-mini {
    display: flex;
    opacity: 1;
}

/* Mini stat items */
.mini-stat-item {
    display: flex;
    align-items: center;
    gap: 3px;
    background: rgba(255,255,255,0.15);
    border-radius: 20px;
    padding: 2px 8px;
    font-weight: 600;
}

.mini-stat-item i {
    font-size: 0.65rem;
}

.mini-stat-open {
    background: rgba(255,193,7,0.2);
}

.mini-open-pnl {
    font-size: 0.65rem;
    padding: 1px 4px;
    border-radius: 8px;
    margin-left: 2px;
}

.mini-open-pnl.positive {
    background: rgba(25,135,84,0.4);
    color: #75e6a0;
}

.mini-open-pnl.negative {
    background: rgba(220,53,69,0.4);
    color: #ff8a8a;
}

/* Full width tabs */
.nav-tabs-fullwidth {
    display: flex;
    width: 100%;
}

.nav-tabs-fullwidth .nav-item {
    flex: 1;
    text-align: center;
}

.nav-tabs-fullwidth .nav-link {
    width: 100%;
    border-radius: 0;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 0.75rem 0.5rem;
}

.nav-tabs-fullwidth .nav-link.active {
    border-bottom-color: var(--bs-primary);
    background: rgba(var(--bs-primary-rgb), 0.1);
}

/* Compact stats */
.stat-compact {
    padding: 0.5rem;
}

.stat-compact i {
    font-size: 1.25rem;
}

.stat-compact h5 {
    font-size: 1rem;
    margin: 0;
}

.stat-compact small {
    font-size: 0.65rem;
}

/* Remove internal scrollbars - single page scroll */
.tab-pane .card-body {
    max-height: none !important;
    overflow: visible !important;
}

/* Exit reason - wrap text nicely */
.exit-reason-wrap {
    max-width: 220px;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.4;
    text-align: right;
}

/* On mobile, adjust width */
@media (max-width: 576px) {
    .exit-reason-wrap {
        max-width: 150px;
        font-size: 0.75rem;
    }
}

/* ========== MOBILE BOTTOM NAVBAR ========== */
.bottom-navbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bs-body-bg);
    border-top: 1px solid var(--bs-border-color);
    z-index: 1030;
    padding: 0.5rem 0;
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
}

.bottom-navbar .nav {
    display: flex;
    justify-content: space-around;
}

.bottom-navbar .nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.25rem 0.5rem;
    color: var(--bs-secondary);
    font-size: 0.65rem;
    text-decoration: none;
    transition: color 0.2s;
}

.bottom-navbar .nav-link i {
    font-size: 1.25rem;
    margin-bottom: 2px;
}

.bottom-navbar .nav-link.active {
    color: var(--bs-primary);
}

.bottom-navbar .nav-link:hover {
    color: var(--bs-primary);
}

/* Page container with bottom padding for navbar */
.page-container {
    padding-bottom: 100px;
    margin-bottom: env(safe-area-inset-bottom, 0);
}

/* Page sections */
.page-section {
    display: none;
    padding-bottom: 80px;
}

.page-section.active {
    display: block;
}

/* Markets page - full height flex layout */
#page-markets.active {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 130px);
}

/* Sub-tabs for pages */
.sub-tabs {
    display: flex;
    background: var(--bs-body-tertiary);
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 1rem;
}

.sub-tabs .sub-tab {
    flex: 1;
    padding: 0.5rem;
    text-align: center;
    border: none;
    background: transparent;
    color: var(--bs-secondary);
    border-radius: 6px;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.sub-tabs .sub-tab.active {
    background: var(--bs-primary);
    color: white;
}

.sub-tabs .sub-tab:hover:not(.active) {
    background: var(--bs-body-bg);
}

/* Top header bar */
.top-header {
    position: sticky;
    top: 0;
    z-index: 1020;
    background: var(--bs-primary);
    padding: 0.5rem 1rem;
}

.top-header .status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(0,0,0,0.3);
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
}

/* ========== STAT CARDS ========== */

/* Hero Stat Card */
.stat-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--bs-body-tertiary) 0%, var(--bs-body-bg) 100%);
    border: 1px solid rgba(255,255,255,0.05);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.stat-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.stat-card-success .stat-card-icon {
    background: rgba(25, 135, 84, 0.15);
    color: #198754;
}

.stat-card-primary .stat-card-icon {
    background: rgba(13, 110, 253, 0.15);
    color: #0d6efd;
}

.stat-card-warning .stat-card-icon {
    background: rgba(255, 193, 7, 0.15);
    color: #ffc107;
}

.stat-card-danger .stat-card-icon {
    background: rgba(220, 53, 69, 0.15);
    color: #dc3545;
}

.stat-card-info .stat-card-icon {
    background: rgba(13, 202, 240, 0.15);
    color: #0dcaf0;
}

.stat-card-content {
    flex: 1;
    min-width: 0;
}

.stat-card-value {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-card-label {
    font-size: 0.7rem;
    color: var(--bs-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Mini Stat Card */
.stat-card-mini {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 6px;
    border-radius: 10px;
    background: var(--bs-body-tertiary);
    text-align: center;
    min-height: 70px;
}

.stat-card-mini i {
    font-size: 1rem;
    margin-bottom: 4px;
}

.stat-card-mini .value {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
}

.stat-card-mini .label {
    font-size: 0.6rem;
    color: var(--bs-secondary);
    text-transform: uppercase;
}

/* Responsive */
@media (max-width: 400px) {
    .stat-card {
        padding: 10px;
    }
    .stat-card-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
    .stat-card-value {
        font-size: 1rem;
    }
    .stat-card-mini .value {
        font-size: 0.8rem;
    }
}

/* ========== PERFORMANCE STATS ========== */
.perf-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.perf-value {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1;
}

.perf-label {
    font-size: 0.65rem;
    color: var(--bs-secondary);
    text-transform: uppercase;
    margin-top: 4px;
}

/* ========== PNL CHART ========== */
.pnl-chart {
    height: 100px;
    display: flex;
    align-items: flex-end;
    gap: 4px;
    padding: 10px 0;
}

.pnl-bar {
    flex: 1;
    min-width: 20px;
    border-radius: 3px 3px 0 0;
    transition: height 0.3s ease;
    position: relative;
}

.pnl-bar.positive {
    background: linear-gradient(to top, #198754, #20c997);
}

.pnl-bar.negative {
    background: linear-gradient(to top, #dc3545, #fd7e14);
}

.pnl-bar:hover {
    opacity: 0.8;
}

.pnl-bar::after {
    content: attr(data-value);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s;
}

.pnl-bar:hover::after {
    opacity: 1;
}

/* ========== INFO ITEMS ========== */
.info-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: var(--bs-body-tertiary);
    border-radius: 8px;
}

.info-item i {
    font-size: 1.2rem;
}

/* ========== RECENT TRADE ITEM ========== */
.recent-trade {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--bs-border-color-translucent);
}

.recent-trade:last-child {
    border-bottom: none;
}

.recent-trade-symbol {
    font-weight: 600;
    font-size: 0.85rem;
}

.recent-trade-time {
    font-size: 0.7rem;
    color: var(--bs-secondary);
}

.recent-trade-pnl {
    font-weight: 600;
    font-size: 0.85rem;
}
