/* ════════════════════════════════════════════
   NEXUS — style.css
   Updated with:
     ① localStorage save indicator styles
     ② Scenario Engine banner + flash styles
     ③ Toast notification system
     ④ Ledger status badge
     ⑤ General polish & fixes
════════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
    --bg-dark: #0f1113;
    --card-bg: #1a1d21;
    --card-deep: #24292e;
    --accent-emerald: #10b981;
    --accent-blue: #3b82f6;
    --accent-red: #f43f5e;
    --accent-amber: #f59e0b;
    --text-main: #e2e8f0;
    --text-dim: #94a3b8;
    --border-color: #2d333b;
    --sidebar-w: 240px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

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

/* ── Base ── */
body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    min-height: 100vh;
}

.text-dim {
    color: var(--text-dim);
}

/* ── App Layout ── */
.app-container {
    display: flex;
    width: 100vw;
    min-height: 100vh;
}

/* ────────────────────────────────
   SIDEBAR
──────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: #16191d;
    border-right: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.logo {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--accent-emerald);
    margin-bottom: 2.5rem;
    letter-spacing: 3px;
}

.nav-links {
    list-style: none;
    flex-grow: 1;
}

.nav-links li {
    padding: 0.75rem 1rem;
    margin-bottom: 4px;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.25s ease;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    font-weight: 500;
}

.nav-links li:hover {
    background: rgba(16, 185, 129, 0.05);
    color: var(--accent-emerald);
}

.nav-links li.active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-emerald);
    font-weight: 600;
}

/* ─── User Profile block ─── */
.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 1rem 0 0;
    border-top: 1px solid var(--border-color);
    margin-top: 1rem;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-dim);
}

.avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent-emerald), var(--accent-blue));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.78rem;
    color: white;
    flex-shrink: 0;
}

/* ─── Save indicator (injected by JS) ─── */
.save-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-dim);
    font-size: 0.72rem;
    padding-top: 0.75rem;
}

.save-dot {
    width: 7px;
    height: 7px;
    background: var(--accent-emerald);
    border-radius: 50%;
    animation: savePulse 2.5s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes savePulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.3;
        transform: scale(0.8);
    }
}

/* ─── Reset button (injected by JS) ─── */
.btn-reset {
    background: transparent;
    border: 1px solid var(--border-color);
    color: #64748b;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: all 0.2s;
    margin-top: 8px;
    font-family: 'Inter', sans-serif;
}

.btn-reset:hover {
    border-color: var(--accent-red);
    color: var(--accent-red);
}

/* ────────────────────────────────
   MAIN CONTENT
──────────────────────────────── */
.main-content {
    flex-grow: 1;
    padding: 2rem 2.5rem;
    overflow-y: auto;
    max-width: calc(100vw - var(--sidebar-w));
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

/* ─── Balance Card ─── */
.balance-card {
    background: var(--card-bg);
    padding: 0.9rem 2rem;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--accent-emerald);
    min-width: 220px;
}

.balance-card .label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.balance-card .amount {
    display: block;
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--accent-emerald);
    letter-spacing: -0.5px;
}

/* ─── Tab Buttons ─── */
.tabs {
    display: flex;
    gap: 0.5rem;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.25s;
    font-family: 'Inter', sans-serif;
}

.tab-btn.active,
.tab-btn:hover {
    color: var(--accent-emerald);
    border-bottom-color: var(--accent-emerald);
}

/* ────────────────────────────────
   CARD
──────────────────────────────── */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

/* ────────────────────────────────
   MARKET VIEW LAYOUT
──────────────────────────────── */
.market-ticker {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 12px 16px;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-color: var(--accent-emerald);
    flex-wrap: wrap;
    gap: 8px;
}

.ticker-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.market-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
    gap: 8px;
}

.badge {
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent-emerald);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ────────────────────────────────
   TALENT LIST
──────────────────────────────── */
.scroll-list {
    margin-top: 0.5rem;
    max-height: 260px;
    overflow-y: auto;
}

.scroll-list::-webkit-scrollbar {
    width: 5px;
}

.scroll-list::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

.scroll-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.scroll-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

.talent-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
    gap: 8px;
}

.talent-item:last-child {
    border-bottom: none;
}

/* ────────────────────────────────
   SERVICE CARDS
──────────────────────────────── */
.post-service-form {
    margin-top: 0.5rem;
}

.input-row {
    display: flex;
    gap: 8px;
    margin-top: 0.5rem;
}

.input-row input {
    margin: 0;
    flex: 1;
}

.input-row .btn-primary {
    width: auto;
    margin: 0;
    white-space: nowrap;
}

input,
select {
    width: 100%;
    padding: 0.75rem 1rem;
    margin: 0.4rem 0;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    transition: border-color 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent-emerald);
}

input::placeholder {
    color: var(--text-dim);
}

.service-card {
    background: var(--card-deep);
    padding: 0.9rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.6rem;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    transition: border-color 0.2s;
}

.service-card:hover {
    border-color: rgba(16, 185, 129, 0.3);
}

/* ────────────────────────────────
   EQUITY EXCHANGE
──────────────────────────────── */
.stock-market-container {
    margin-bottom: 1.5rem;
}

.stock-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.2rem;
    margin-top: 1.2rem;
}

.stock-card {
    background: var(--card-deep);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.2rem;
    transition: transform 0.2s, border-color 0.2s;
    cursor: default;
}

.stock-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-emerald);
}

.stock-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.stock-symbol {
    font-weight: 800;
    color: var(--accent-emerald);
    background: rgba(16, 185, 129, 0.1);
    padding: 3px 9px;
    border-radius: 5px;
    font-size: 0.88rem;
    letter-spacing: 1px;
}

.stock-price {
    font-size: 1.15rem;
    font-weight: 700;
}

.stock-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
    color: var(--text-dim);
    margin-bottom: 1rem;
}

.trend-up {
    color: var(--accent-emerald);
    font-weight: 600;
}

.trend-down {
    color: var(--accent-red);
    font-weight: 600;
}

.btn-buy {
    width: 100%;
    background: #30363d;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-buy:hover {
    background: var(--accent-emerald);
    border-color: var(--accent-emerald);
    color: white;
}

/* ── Stock card flash animations (also in injected styles, kept for clarity) ── */
@keyframes flashGreen {
    0% {
        box-shadow: 0 0 0 2px #10b981;
        background: rgba(16, 185, 129, 0.15);
    }

    100% {
        box-shadow: none;
        background: var(--card-deep);
    }
}

@keyframes flashRed {
    0% {
        box-shadow: 0 0 0 2px #f43f5e;
        background: rgba(244, 63, 94, 0.15);
    }

    100% {
        box-shadow: none;
        background: var(--card-deep);
    }
}

.flash-green {
    animation: flashGreen 1.2s ease-out forwards;
}

.flash-red {
    animation: flashRed 1.2s ease-out forwards;
}

/* ────────────────────────────────
   SCENARIO ENGINE — NEWS BANNER
──────────────────────────────── */
#scenarioBanner {
    background: linear-gradient(135deg, #16191d 0%, #1e2429 100%);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    padding: 14px 24px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    transform: translateY(-100%);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.scenario-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.scenario-left {
    flex: 1;
    min-width: 200px;
}

.scenario-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.scenario-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.scenario-headline {
    color: var(--text-main);
    font-size: 0.92rem;
    font-weight: 600;
    margin: 0 0 4px;
}

.scenario-detail {
    color: var(--text-dim);
    font-size: 0.78rem;
    margin: 0;
}

.scenario-tickers {
    color: var(--text-main);
    font-size: 0.82rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.scenario-close {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-dim);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.scenario-close:hover {
    background: var(--border-color);
    color: var(--text-main);
}

/* ── Recent events log ── */
.scenario-log {
    min-height: 60px;
}

.scenario-log h4 {
    color: var(--text-dim);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-bottom: 0.6rem;
}

.scenario-log-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.83rem;
    color: var(--text-dim);
}

.scenario-log-item:last-child {
    border-bottom: none;
}

.log-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ────────────────────────────────
   PORTFOLIO VIEW
──────────────────────────────── */
.portfolio-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.p-stat h4 {
    color: var(--text-dim);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.6rem;
}

.p-stat p {
    font-size: 1.9rem;
    font-weight: 800;
    color: var(--accent-emerald);
    letter-spacing: -0.5px;
}

.owned-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
    gap: 8px;
}

.owned-item:last-child {
    border-bottom: none;
}

/* ─── Savings Goal ─── */
.goal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 8px;
}

.progress-wrapper {
    margin-top: 0.5rem;
}

.progress-bar-bg {
    width: 100%;
    height: 10px;
    background: var(--bg-dark);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-emerald), #34d399);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
    transition: width 0.6s ease-in-out;
    border-radius: 10px;
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 0.8rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dim);
}

/* ─── Transaction Ledger ─── */
table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    color: var(--text-dim);
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.88rem;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.status-badge {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-emerald);
    padding: 3px 9px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

/* ────────────────────────────────
   HIRING VIEW
──────────────────────────────── */
.hiring-dashboard {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.filter-chips {
    display: flex;
    gap: 8px;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.chip {
    padding: 5px 14px;
    background: var(--card-deep);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
    color: var(--text-dim);
}

.chip.active,
.chip:hover {
    border-color: var(--accent-emerald);
    color: var(--accent-emerald);
    background: rgba(16, 185, 129, 0.05);
}

.talent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.pro-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: border-color 0.2s, transform 0.2s;
}

.pro-card:hover {
    border-color: rgba(16, 185, 129, 0.3);
    transform: translateY(-3px);
}

.pro-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 0.5rem;
}

.pro-avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent-emerald), var(--accent-blue));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    font-size: 0.9rem;
}

.pro-info h4 {
    font-size: 1rem;
    margin: 2px 0;
}

.pro-tag {
    font-size: 0.7rem;
    color: var(--accent-emerald);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 700;
}

.pro-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 0.5rem 0;
    padding: 0.75rem 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.stat-item {
    font-size: 0.78rem;
    color: var(--text-dim);
}

.stat-item b {
    display: block;
    color: var(--text-main);
    font-size: 0.95rem;
    margin-top: 2px;
}

/* ────────────────────────────────
   BUTTONS
──────────────────────────────── */
.btn-primary {
    width: 100%;
    background: var(--accent-emerald);
    border: none;
    padding: 0.8rem 1rem;
    color: white;
    font-weight: 700;
    font-size: 0.88rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-top: 0.75rem;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s;
    letter-spacing: 0.2px;
}

.btn-primary:hover {
    background: #0ea572;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-small {
    background: transparent;
    border: 1px solid var(--accent-emerald);
    color: var(--accent-emerald);
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
    white-space: nowrap;
}

.btn-small:hover {
    background: var(--accent-emerald);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
    transform: translateY(-1px);
}

.btn-small:active {
    transform: translateY(0);
}

/* ────────────────────────────────
   TOAST NOTIFICATIONS
   (Container injected by script.js)
──────────────────────────────── */
#toastContainer {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 10000;
    pointer-events: none;
}

/* ────────────────────────────────
   RESPONSIVE — Mobile
──────────────────────────────── */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        min-width: unset;
        height: auto;
        position: static;
        flex-direction: row;
        align-items: center;
        padding: 1rem;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        flex-wrap: wrap;
        gap: 8px;
    }

    .logo {
        margin-bottom: 0;
        font-size: 1.1rem;
    }

    .nav-links {
        display: flex;
        flex-grow: unset;
        gap: 4px;
    }

    .nav-links li {
        padding: 6px 12px;
        font-size: 0.85rem;
        margin-bottom: 0;
    }

    .user-profile,
    .save-indicator,
    .btn-reset {
        display: none;
    }

    .main-content {
        padding: 1.25rem;
        max-width: 100vw;
    }

    .market-grid,
    .portfolio-grid {
        grid-template-columns: 1fr;
    }

    .stock-grid {
        grid-template-columns: 1fr;
    }

    .talent-grid {
        grid-template-columns: 1fr;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
    }

    .balance-card {
        width: 100%;
    }

    .scenario-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .scenario-right {
        width: 100%;
        justify-content: space-between;
    }

    #toastContainer {
        bottom: 12px;
        right: 12px;
        left: 12px;
    }
}

@media (max-width: 480px) {
    .tabs {
        gap: 0;
    }

    .tab-btn {
        font-size: 0.88rem;
        padding: 0.4rem 0.75rem;
    }

    .balance-card .amount {
        font-size: 1.4rem;
    }
}