/* ════════════════════════════════════════
   EARNER — USER APP SYSTEM STYLES
   Common mobile-first layout styles
   ════════════════════════════════════════ */

:root {
    --blue:      #1535a0;
    --blue-mid:  #1e4fc7;
    --blue-lite: #2563eb;
    --green:     #00c48c;
    --red:       #e84040;
    --gold:      #f59e0b;
    --bg:        #f4f6fb;
    --card:      #ffffff;
    --border:    #e8eaf0;
    --text:      #1a1f36;
    --muted:     #8a94a6;
    --font:      'Inter', system-ui, sans-serif;
    --nav-h:     68px;
    --header-h:  62px;
    --radius:    16px;
    --radius-sm: 10px;
}

*, *::before, *::after { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}

html { 
    font-size: 15px; 
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    /* Mobile-app max-width centered */
    max-width: 480px;
    margin: 0 auto;
    position: relative;
    box-shadow: 0 0 32px rgba(0,0,0,0.05);
}

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

/* ── Sticky App Header ── */
.app-header {
    position: sticky;
    top: 0;
    z-index: 200;
    background: #fff;
    height: var(--header-h);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    box-shadow: 0 1px 0 var(--border);
}

.app-header .logo img {
    height: 26px;
    width: auto;
    display: block;
}

.profile-btn {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--blue-mid), var(--blue));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.95rem;
    flex-shrink: 0;
    cursor: pointer;
    text-decoration: none;
}

/* ── Common Sections ── */
.section { 
    padding: 0 14px; 
    margin-top: 18px; 
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.section-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--blue-mid);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.view-all {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--blue-lite);
}

/* ── Bottom Navigation Bar ── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: var(--nav-h);
    background: #fff;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    z-index: 300;
    box-shadow: 0 -4px 20px rgba(0,0,0,.07);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    padding: 6px 0;
    text-decoration: none;
    position: relative;
}

.nav-icon {
    font-size: 1.2rem;
    color: var(--muted);
    transition: color .2s, transform .2s;
    line-height: 1;
}

.nav-label {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--muted);
    transition: color .2s;
}

.nav-item.active .nav-icon { 
    color: var(--blue-mid); 
    transform: translateY(-1px); 
}

.nav-item.active .nav-label { 
    color: var(--blue-mid); 
}

.nav-item.active::after {
    content: '';
    position: absolute;
    top: 0;
    width: 24px;
    height: 3px;
    border-radius: 0 0 4px 4px;
    background: var(--blue-mid);
}

.nav-item:hover .nav-icon { 
    color: var(--blue-mid); 
}

.nav-item:hover .nav-label { 
    color: var(--blue-mid); 
}

/* Trade center button (middle) */
.nav-item.trade {
    flex: 0 0 72px;
}

.trade-btn {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--blue-mid), var(--blue));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.3rem;
    box-shadow: 0 6px 20px rgba(30,79,199,.38);
    margin-bottom: 2px;
    transition: transform .2s, box-shadow .2s;
}

.nav-item.trade:hover .trade-btn {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 10px 28px rgba(30,79,199,.48);
}

.nav-item.trade .nav-label { 
    color: var(--blue-mid); 
    font-weight: 700; 
}

/* ── Modal Dialog Styles ── */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    justify-content: flex-end;
    flex-direction: column;
}

.modal-content {
    background-color: #fff;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    padding: 20px 16px 30px;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.15);
    animation: slideUp 0.3s ease-out forwards;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

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

.modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    color: var(--muted);
    cursor: pointer;
    padding: 4px;
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.form-input-icon {
    position: absolute;
    left: 14px;
    color: var(--muted);
    font-size: 0.95rem;
}

.form-input {
    width: 100%;
    padding: 12px 14px 12px 36px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: var(--blue-lite);
}

.btn-submit {
    width: 100%;
    background: linear-gradient(135deg, var(--blue-mid), var(--blue));
    color: #fff;
    border: none;
    padding: 14px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(30,79,199,0.25);
    transition: opacity 0.2s;
}

.btn-submit:hover {
    opacity: 0.95;
}

/* ════════════════════════════════════════
   POSITIONS & PORTFOLIO PAGES
   ════════════════════════════════════════ */

.positions-scroll {
    overflow-y: auto;
    padding-bottom: calc(var(--nav-h) + 24px);
    -webkit-overflow-scrolling: touch;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f1f5f9;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: var(--muted);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.header-action-btn:hover {
    background: var(--blue-mid);
    color: #fff;
}

/* ── P&L Card ── */
.pl-summary-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.02);
}

.pl-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.pl-card-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.pl-card-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.pl-value-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pl-total-amount {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--green);
    letter-spacing: -0.02em;
    line-height: 1;
}

.pl-total-amount.loss {
    color: var(--red);
}

.pl-change-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 30px;
    font-size: 0.65rem;
    font-weight: 700;
    background: rgba(0, 196, 140, 0.12);
    color: var(--green);
    width: fit-content;
}

.pl-change-pill.loss {
    background: rgba(232, 64, 64, 0.12);
    color: var(--red);
}

.pl-sparkline-wrap {
    flex: 1;
    height: 48px;
    max-width: 120px;
}

.pl-sparkline {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.pl-sub-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-top: 14px;
}

.pl-sub-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pl-sub-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
}

.pl-sub-val {
    font-size: 0.95rem;
    font-weight: 700;
}

.pl-sub-val.profit { 
    color: var(--green); 
}

.pl-sub-val.loss { 
    color: var(--red); 
}

/* ── Filter Tabs ── */
.tab-bar-container {
    border-bottom: 1.5px solid var(--border);
    margin: 18px -14px 0;
    padding: 0 14px;
}

.tab-bar {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scrollbar-width: none;
}

.tab-bar::-webkit-scrollbar { 
    display: none; 
}

.tab-item {
    padding: 8px 4px 10px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--muted);
    cursor: pointer;
    position: relative;
    white-space: nowrap;
    transition: color 0.2s;
}

.tab-item:hover {
    color: var(--blue-mid);
}

.tab-item.active {
    color: var(--blue-mid);
}

.tab-item.active::after {
    content: '';
    position: absolute;
    bottom: -1.5px;
    left: 0;
    right: 0;
    height: 2.5px;
    background: var(--blue-mid);
    border-radius: 4px;
}

/* ── Positions List ── */
.positions-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 14px;
}

.position-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.position-card:hover {
    border-color: var(--blue-lite);
    box-shadow: 0 4px 14px rgba(30,79,199,0.04);
}

.pos-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.pos-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.pos-symbol-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pos-badge {
    font-size: 0.55rem;
    font-weight: 800;
    padding: 1px 4px;
    border-radius: 3px;
    letter-spacing: 0.02em;
}

.pos-badge.nse {
    background: #e0f2fe;
    color: #0369a1;
}

.pos-badge.nfo {
    background: #fae8ff;
    color: #a21caf;
}

.pos-symbol {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
}

.pos-change-badge {
    font-size: 0.65rem;
    font-weight: 700;
    margin-left: 2px;
}

.pos-change-badge.up { 
    color: var(--green); 
}

.pos-change-badge.down { 
    color: var(--red); 
}

.pos-sub {
    font-size: 0.62rem;
    color: var(--muted);
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.pos-pl-wrap {
    text-align: right;
    display: flex;
    align-items: center;
    gap: 6px;
}

.pos-total-pl {
    font-size: 0.95rem;
    font-weight: 800;
}

.pos-total-pl.profit { 
    color: var(--green); 
}

.pos-total-pl.loss { 
    color: var(--red); 
}

.pos-total-pct {
    font-size: 0.62rem;
    font-weight: 600;
    display: block;
}

.pos-total-pct.profit { 
    color: var(--green); 
}

.pos-total-pct.loss { 
    color: var(--red); 
}

.pos-menu-btn {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 0.82rem;
    padding: 2px;
}

.pos-menu-btn:hover {
    color: var(--text);
}

.pos-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    background: #f8fafc;
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    border: 1px solid var(--border);
}

.pos-grid-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pos-grid-item.right-align {
    text-align: right;
}

.pos-grid-label {
    font-size: 0.55rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
}

.pos-grid-val {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text);
}

.pos-grid-val.profit { 
    color: var(--green); 
}

.pos-grid-val.loss { 
    color: var(--red); 
}

.pos-ltp-change {
    font-size: 0.52rem;
    font-weight: 600;
    display: block;
    margin-top: 1px;
}

.pos-ltp-change.up { 
    color: var(--green); 
}

.pos-ltp-change.down { 
    color: var(--red); 
}

/* ── Placeholders ── */
.empty-placeholder {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 14px;
}

.placeholder-icon {
    font-size: 2.2rem;
    color: var(--muted);
    margin-bottom: 12px;
    opacity: 0.6;
}

.placeholder-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.placeholder-desc {
    font-size: 0.72rem;
    color: var(--muted);
    max-width: 280px;
    line-height: 1.45;
}

/* ── Alert Card ── */
.margin-alert {
    background: #fef2f2;
    border: 1px solid #fee2e2;
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.03);
    margin-top: 18px;
    position: relative;
}

.alert-icon-wrap {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: rgba(239, 68, 68, 0.1);
    color: var(--red);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.alert-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.alert-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: #991b1b;
}

.alert-desc {
    font-size: 0.68rem;
    color: #7f1d1d;
    line-height: 1.4;
    font-weight: 500;
    margin-bottom: 8px;
}

.alert-btn {
    background: var(--red);
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.68rem;
    font-weight: 700;
    cursor: pointer;
    width: fit-content;
    transition: opacity 0.2s;
}

.alert-btn:hover {
    opacity: 0.9;
}

.alert-close-btn {
    background: none;
    border: none;
    color: #f87171;
    font-size: 0.85rem;
    cursor: pointer;
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 2px;
}

.alert-close-btn:hover {
    color: var(--red);
}

/* ==========================================================================
   RESPONSIVE LAYOUT FOR WEB / DESKTOP SCREENS (WIDTH >= 768px)
   ========================================================================== */

@media (min-width: 768px) {
    body {
        max-width: 100% !important;
        padding-left: 260px;
        margin: 0 !important;
        box-shadow: none;
    }
    
    .app-header {
        position: fixed;
        left: 260px;
        right: 0;
        top: 0;
        z-index: 200;
        background: #fff;
        box-shadow: 0 1px 0 var(--border);
    }
    
    .dashboard-scroll, 
    .positions-scroll, 
    .watchlist-scroll, 
    .trade-scroll, 
    .profile-scroll,
    .withdraw-scroll,
    .edit-scroll,
    .page-scroll,
    .info-scroll {
        padding-top: 24px;
        padding-bottom: 40px;
        max-width: 1200px;
        margin: 0 auto;
        padding-left: 30px;
        padding-right: 30px;
    }
    
    /* Left sidebar layout for bottom navigation */
    .bottom-nav {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 260px;
        max-width: 260px !important;
        height: 100vh;
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        border-right: 1px solid var(--border);
        border-top: none;
        padding: 24px 16px;
        background: #fff;
        transform: none !important;
        box-shadow: 2px 0 20px rgba(0,0,0,0.03);
        gap: 8px;
    }
    
    .bottom-nav::before {
        content: 'EARNER';
        font-size: 1.35rem;
        font-weight: 800;
        color: var(--blue);
        text-align: center;
        margin-bottom: 24px;
        letter-spacing: 1px;
    }
    
    .nav-item {
        flex: none;
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        gap: 12px;
        padding: 12px 16px;
        border-radius: 10px;
        width: 100%;
    }
    
    .nav-icon {
        font-size: 1.25rem;
        margin-bottom: 0;
    }
    
    .nav-label {
        font-size: 0.9rem;
        font-weight: 600;
    }
    
    .nav-item.active {
        background: #eff4ff;
        color: var(--blue-mid);
    }
    
    .nav-item.active .nav-icon {
        color: var(--blue-mid);
    }
    
    .nav-item.active::after {
        display: none;
    }
    
    .nav-item:hover {
        background: #f8fafc;
        color: var(--blue-mid);
    }
    
    /* Adjust trade button CTA inside sidebar */
    .nav-item.trade {
        flex: none;
        width: 100%;
        order: 0; /* Keep sequential or reposition */
    }
    
    .trade-btn {
        width: 32px;
        height: 32px;
        font-size: 1rem;
        box-shadow: none;
        margin-bottom: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Dialog Modals centering on Desktop */
    .modal {
        left: 50% !important;
        top: 50% !important;
        bottom: auto !important;
        transform: translate(-50%, -50%) !important;
        width: 440px !important;
        height: auto !important;
        border-radius: 16px !important;
        justify-content: center !important;
        box-shadow: 0 12px 40px rgba(0,0,0,0.15) !important;
        padding: 0 !important;
    }
    
    .modal-content {
        border-radius: 16px !important;
        padding: 24px 20px !important;
        animation: none !important;
    }
    
    /* Bottom Sheets centering on Desktop */
    .sheet-overlay {
        align-items: center !important;
        justify-content: center !important;
    }
    
    .sheet-overlay.open .sheet {
        transform: scale(1) translateY(0) !important;
    }
    
    .sheet {
        width: 460px !important;
        border-radius: 16px !important;
        max-height: 85vh !important;
        margin: 0 auto !important;
        box-shadow: 0 12px 40px rgba(0,0,0,0.15) !important;
        padding-bottom: 16px !important;
    }
    
    .sheet-handle {
        display: none;
    }
}

