/* ============================================
   Larry Trustee AI — Hub Dashboard Styles
   ============================================ */

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #141620;
    --bg-card: #1a1d28;
    --bg-card-hover: #222633;
    --bg-input: #1e2130;
    --border-color: #2a2e3d;
    --border-focus: #448aff;

    --text-primary: #e8eaed;
    --text-secondary: #9aa0b0;
    --text-muted: #5a6178;

    --regime-bull: #00c853;
    --regime-bull-bg: rgba(0, 200, 83, 0.12);
    --regime-bear: #ff1744;
    --regime-bear-bg: rgba(255, 23, 68, 0.12);
    --regime-sideways: #ffab00;
    --regime-sideways-bg: rgba(255, 171, 0, 0.12);

    --accent: #448aff;
    --accent-hover: #5c9aff;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --sidebar-width: 220px;
    --sidebar-collapsed: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    overflow: hidden;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.25s ease;
    overflow: hidden;
    z-index: 100;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar-header {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    min-height: 64px;
}

.sidebar-logo {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar.collapsed .sidebar-brand {
    opacity: 0;
    width: 0;
}

.brand-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.brand-sub {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ---- Sidebar Nav ---- */
.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-sans);
    transition: all 0.15s;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
    width: 100%;
    text-align: left;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(68, 138, 255, 0.12);
    color: var(--accent);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-label {
    flex: 1;
    overflow: hidden;
}

.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-key {
    opacity: 0;
    width: 0;
}

.nav-key {
    font-size: 10px;
    font-family: var(--font-mono);
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ---- Sidebar Footer ---- */
.sidebar-footer {
    padding: 8px;
    border-top: 1px solid var(--border-color);
}

.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

/* ---- Main Content ---- */
.main-content {
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
}

/* ---- Views ---- */
.view {
    display: none;
    height: 100%;
}

.view.active {
    display: flex;
    flex-direction: column;
}

#view-dashboard.active {
    display: block;
    overflow-y: auto;
    padding: 24px;
}

.view-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: var(--bg-primary);
}

.iframe-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    gap: 12px;
}

.placeholder-icon {
    font-size: 48px;
    opacity: 0.4;
}

.iframe-placeholder h3 {
    color: var(--text-secondary);
    font-size: 18px;
}

.iframe-placeholder p {
    font-size: 13px;
    max-width: 300px;
}

/* ---- Overview Row ---- */
.overview-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.overview-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: border-color 0.2s;
}

.overview-card:hover {
    border-color: rgba(255, 255, 255, 0.08);
}

.overview-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.bull-icon { background: var(--regime-bull-bg); color: var(--regime-bull); }
.bear-icon { background: var(--regime-bear-bg); color: var(--regime-bear); }
.sideways-icon { background: var(--regime-sideways-bg); color: var(--regime-sideways); }

.overview-value {
    font-size: 28px;
    font-weight: 800;
    font-family: var(--font-mono);
    line-height: 1;
}

.overview-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ---- Dashboard Grid ---- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

/* ---- Card Base ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
}

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

.card-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
}

/* ---- Watchlist ---- */
.watchlist-add {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.watchlist-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
}

.watchlist-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(68, 138, 255, 0.12);
}

.watchlist-input::placeholder {
    text-transform: none;
    color: var(--text-muted);
    font-weight: 400;
}

.btn-add {
    background: var(--accent);
    color: #fff;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-add:hover { background: var(--accent-hover); }

.btn-icon {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.btn-icon:hover {
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.watchlist-table-wrap {
    max-height: 340px;
    overflow-y: auto;
}

.watchlist-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.watchlist-table th {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    background: var(--bg-card);
}

.watchlist-table td {
    padding: 10px;
    border-bottom: 1px solid rgba(42, 46, 61, 0.5);
    font-family: var(--font-mono);
    font-size: 12px;
}

.watchlist-table tr {
    cursor: pointer;
    transition: background 0.1s;
}

.watchlist-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.ticker-cell {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 13px;
}

.regime-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.regime-badge.bull {
    background: var(--regime-bull-bg);
    color: var(--regime-bull);
}

.regime-badge.bear {
    background: var(--regime-bear-bg);
    color: var(--regime-bear);
}

.regime-badge.sideways {
    background: var(--regime-sideways-bg);
    color: var(--regime-sideways);
}

.regime-badge.analyzing {
    background: rgba(68, 138, 255, 0.12);
    color: var(--accent);
}

.confidence-cell {
    color: var(--text-secondary);
}

.btn-remove {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.15s;
}

.btn-remove:hover {
    color: var(--regime-bear);
    background: var(--regime-bear-bg);
}

.watchlist-empty,
.alerts-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    line-height: 1.6;
}

.empty-icon {
    font-size: 32px;
    margin-bottom: 8px;
    opacity: 0.4;
}

/* ---- Alerts ---- */
.alerts-list {
    max-height: 380px;
    overflow-y: auto;
}

.alert-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid rgba(42, 46, 61, 0.5);
    animation: alertSlideIn 0.3s ease;
}

@keyframes alertSlideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.alert-arrow {
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 2px;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.alert-title .alert-ticker {
    font-family: var(--font-mono);
    font-weight: 700;
}

.alert-detail {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ---- Portfolio Tracker ---- */
.portfolio-add {
    display: flex;
    gap: 6px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
}

.portfolio-summary {
    display: flex;
    justify-content: space-between;
    padding: 10px 14px;
    font-size: 13px;
    font-family: var(--font-mono);
    border-bottom: 1px solid var(--border-color);
    background: rgba(68,138,255,0.04);
}

.portfolio-table-wrap {
    overflow-x: auto;
}

.ticker-cell {
    font-weight: 700;
    color: var(--accent);
}

.pnl-pos { color: var(--regime-bull); font-weight: 600; }
.pnl-neg { color: var(--regime-bear); font-weight: 600; }

.regime-badge.bull { color: var(--regime-bull); }
.regime-badge.sideways { color: var(--regime-sideways); }
.regime-badge.bear { color: var(--regime-bear); }

.btn-remove {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.15s;
}

.btn-remove:hover {
    color: var(--regime-bear);
    border-color: var(--regime-bear);
}

/* ---- Quick Actions ---- */
.quick-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.15s;
}

.action-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(68, 138, 255, 0.06);
}

/* ---- Portfolio Tracker ---- */
.card-portfolio {
    grid-column: 1 / -1;
}

.portfolio-add {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.portfolio-summary {
    display: flex;
    gap: 24px;
    padding: 10px 16px;
    font-size: 13px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.portfolio-table-wrap {
    max-height: 350px;
    overflow-y: auto;
}

.pnl-pos { color: var(--regime-bull); font-family: var(--font-mono); font-size: 13px; }
.pnl-neg { color: var(--regime-bear); font-family: var(--font-mono); font-size: 13px; }

.pnl-pos small, .pnl-neg small {
    font-size: 11px;
    opacity: 0.8;
}

.ticker-cell {
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.regime-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.regime-badge.bull { color: var(--regime-bull); background: var(--regime-bull-bg); }
.regime-badge.bear { color: var(--regime-bear); background: var(--regime-bear-bg); }
.regime-badge.sideways { color: var(--regime-sideways); background: var(--regime-sideways-bg); }

.btn-remove {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    transition: all 0.15s;
}

.btn-remove:hover {
    border-color: var(--regime-bear);
    color: var(--regime-bear);
    background: var(--regime-bear-bg);
}

/* ---- Toast ---- */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    font-size: 13px;
    color: var(--text-secondary);
    box-shadow: var(--shadow);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 3000;
    max-width: 400px;
}

.toast.active {
    transform: translateY(0);
    opacity: 1;
}

.toast.alert-toast {
    border-left: 3px solid var(--regime-sideways);
}

/* ---- Brokerage Accounts ---- */
.broker-accounts-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.broker-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-input);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
}

.broker-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-1px);
}

.broker-icon {
    font-size: 20px;
    flex-shrink: 0;
}

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

.broker-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.broker-type {
    font-size: 10px;
    color: var(--text-muted);
}

.broker-empty {
    text-align: center;
    padding: 16px;
    color: var(--text-muted);
    font-size: 12px;
}

.broker-add-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* ---- Order Builder ---- */
.order-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.order-row {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.order-text {
    background: var(--bg-input);
    color: var(--accent);
    padding: 12px;
    border-radius: 8px;
    font-size: 11px;
    font-family: var(--font-mono);
    white-space: pre;
    overflow-x: auto;
    margin: 0 0 8px;
    border: 1px solid var(--border-color);
}

.order-actions {
    display: flex;
    gap: 8px;
}

/* ---- LTRST Token Dashboard ---- */
.ltrst-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.ltrst-stat {
    background: var(--bg-input);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.ltrst-stat-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.ltrst-stat-value {
    font-size: 16px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.ltrst-details {
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    margin-bottom: 16px;
}

.ltrst-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.ltrst-row:last-child { border-bottom: none; }

.ltrst-mint {
    font-family: var(--font-mono);
    font-size: 12px;
    color: #448aff;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(68,138,255,0.1);
}

.ltrst-mint:hover {
    background: rgba(68,138,255,0.2);
}

.ltrst-ico-badge {
    background: rgba(0,200,83,0.15);
    color: #00c853;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 10px;
    border-radius: 4px;
    font-family: var(--font-mono);
    letter-spacing: 1px;
    animation: icoPulse 2s ease-in-out infinite;
}

@keyframes icoPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.ltrst-actions {
    display: flex;
    gap: 8px;
}

/* ---- Portfolio ---- */
.portfolio-add {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 12px;
}

.portfolio-summary {
    display: flex;
    gap: 20px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 10px;
    font-size: 13px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
}

.pnl-pos { color: var(--regime-bull); }
.pnl-neg { color: var(--regime-bear); }

.regime-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.regime-badge.bull { background: rgba(0,200,83,0.15); color: var(--regime-bull); }
.regime-badge.bear { background: rgba(255,23,68,0.15); color: var(--regime-bear); }
.regime-badge.sideways { background: rgba(255,171,0,0.15); color: var(--regime-sideways); }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .overview-row {
        grid-template-columns: repeat(2, 1fr);
    }

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

@media (max-width: 768px) {
    body {
        flex-direction: column-reverse;
    }

    .sidebar {
        width: 100% !important;
        height: auto;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--border-color);
    }

    .sidebar-header {
        display: none;
    }

    .sidebar-nav {
        flex-direction: row;
        justify-content: space-around;
        padding: 8px;
        width: 100%;
    }

    .nav-item {
        flex-direction: column;
        gap: 4px;
        padding: 8px;
        font-size: 10px;
    }

    .nav-label {
        font-size: 10px;
        opacity: 1 !important;
        width: auto !important;
    }

    .nav-key {
        display: none;
    }

    .sidebar-footer {
        display: none;
    }

    .main-content {
        height: calc(100vh - 70px);
    }

    .overview-row {
        grid-template-columns: repeat(2, 1fr);
    }

    #view-dashboard.active {
        padding: 12px;
    }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
