/* ================================================
   Solana Meme Trader Dashboard — Dark Theme
   Based on OKX Trading Dashboard styling
   ================================================ */

/* CSS Custom Properties */
:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-hover: #292e36;
    --border: #30363d;
    --border-light: #3d444d;
    --text: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #656d76;
    --green: #3fb950;
    --green-bg: rgba(63, 185, 80, 0.1);
    --red: #f85149;
    --red-bg: rgba(248, 81, 73, 0.1);
    --blue: #58a6ff;
    --blue-bg: rgba(88, 166, 255, 0.1);
    --yellow: #d29922;
    --yellow-bg: rgba(210, 153, 34, 0.15);
    --orange: #f0883e;
    --purple: #bc8cff;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

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

body {
    background: var(--bg-primary);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}

/* ================================================
   Header
   ================================================ */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    font-size: 24px;
}

.header-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

.nav {
    display: flex;
    gap: 4px;
    margin-left: 16px;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
}

.nav-link:hover {
    color: var(--text);
    background: var(--bg-tertiary);
}

.nav-link.active {
    color: var(--text);
    background: var(--bg-tertiary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.live {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
    animation: pulse 2s infinite;
}

.status-dot.paper {
    background: var(--yellow);
    box-shadow: 0 0 6px var(--yellow);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ================================================
   Main Content
   ================================================ */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 24px;
}

/* ================================================
   Portfolio Summary Strip (top metric cards)
   ================================================ */
.portfolio-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.portfolio-strip .metric-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.metric-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.metric-value {
    font-size: 22px;
    font-weight: 700;
    font-family: var(--mono);
    color: var(--text);
}

.metric-sub {
    font-size: 14px;
    font-weight: 400;
}

.metric-sub-detail {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ================================================
   Colors
   ================================================ */
.positive { color: var(--green); }
.negative { color: var(--red); }
.neutral { color: var(--text-secondary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: 700; }
.mono { font-family: var(--mono); }

/* ================================================
   Sections
   ================================================ */
.section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--mono);
    color: var(--text-secondary);
    padding: 1px 8px;
    min-width: 24px;
}

.section-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin: -8px 0 16px 0;
}

.see-all {
    font-size: 12px;
    font-weight: 400;
    color: var(--blue);
    text-decoration: none;
    margin-left: auto;
}

.see-all:hover {
    text-decoration: underline;
}

/* ================================================
   Performance Stats Grid
   ================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.stat-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    padding: 16px;
}

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

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

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

/* ================================================
   Tables
   ================================================ */
.table-container {
    overflow-x: auto;
}

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

.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    font-size: 13px;
}

.data-table.compact td {
    padding: 8px 10px;
    font-size: 12px;
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

.row-profit {
    border-left: 3px solid var(--green);
}

.row-loss {
    border-left: 3px solid var(--red);
}

/* Coin cell */
.coin-name {
    font-weight: 600;
    color: var(--text);
}

.coin-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.narrative-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font);
    font-style: italic;
}

/* ================================================
   Confidence Bar
   ================================================ */
.confidence-bar {
    position: relative;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    height: 20px;
    overflow: hidden;
    min-width: 60px;
}

.confidence-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--blue) 0%, var(--green) 100%);
    border-radius: var(--radius-sm);
    opacity: 0.3;
}

.confidence-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
    font-family: var(--mono);
}

.confidence-badge {
    display: inline-block;
    padding: 2px 6px;
    background: var(--blue-bg);
    color: var(--blue);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: var(--mono);
    font-weight: 600;
}

/* ================================================
   Badges
   ================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
    letter-spacing: 0.3px;
}

.badge-success {
    background: var(--green-bg);
    color: var(--green);
}

.badge-warning {
    background: var(--yellow-bg);
    color: var(--yellow);
}

.badge-info {
    background: var(--blue-bg);
    color: var(--blue);
}

/* Exit reason badges */
.badge-exit {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.badge-hard-stop { background: var(--red-bg); color: var(--red); border-color: transparent; }
.badge-trail-stop { background: var(--yellow-bg); color: var(--yellow); border-color: transparent; }
.badge-time-stop { background: var(--blue-bg); color: var(--blue); border-color: transparent; }
.badge-moonbag { background: rgba(188, 140, 255, 0.1); color: var(--purple); border-color: transparent; }
.badge-breakeven-sell { background: var(--green-bg); color: var(--green); border-color: transparent; }
.badge-partial-sell { background: rgba(240, 136, 62, 0.1); color: var(--orange); border-color: transparent; }

/* ================================================
   Exit Reasons Grid
   ================================================ */
.exit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
}

.exit-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    padding: 14px;
    text-align: center;
}

.exit-icon {
    font-size: 20px;
    margin-bottom: 4px;
}

.exit-name {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.exit-count {
    font-size: 20px;
    font-weight: 700;
    font-family: var(--mono);
    color: var(--text);
}

/* ================================================
   Two Column Layout
   ================================================ */
.two-column {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ================================================
   Empty State
   ================================================ */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state.small {
    padding: 20px;
}

.empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* ================================================
   Filter Bar (trades page)
   ================================================ */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.filter-select, .filter-input {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    font-family: var(--font);
    outline: none;
    min-width: 120px;
}

.filter-select:focus, .filter-input:focus {
    border-color: var(--blue);
}

.filter-button, .filter-btn {
    padding: 8px 20px;
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}

.filter-button:hover, .filter-btn:hover {
    opacity: 0.85;
}

.filter-reset {
    padding: 8px 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
}

.filter-reset:hover {
    color: var(--text);
}

/* ================================================
   Login Page
   ================================================ */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
}

.login-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 360px;
    text-align: center;
}

.login-logo {
    font-size: 48px;
    margin-bottom: 8px;
}

.login-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--text);
}

.login-error {
    background: var(--red-bg);
    color: var(--red);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13px;
}

.login-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    margin-bottom: 12px;
    outline: none;
}

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

.login-button {
    width: 100%;
    padding: 10px;
    background: var(--green);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}

.login-button:hover {
    opacity: 0.9;
}

/* ================================================
   Footer
   ================================================ */
.footer {
    text-align: center;
    padding: 16px 24px;
    color: var(--text-muted);
    font-size: 12px;
    border-top: 1px solid var(--border);
    margin-top: 20px;
}

/* Date input styling for dark mode */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.8);
}

/* ================================================
   Responsive
   ================================================ */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 8px;
        padding: 12px 16px;
    }

    .header-left {
        width: 100%;
        flex-wrap: wrap;
    }

    .nav {
        margin-left: 0;
    }

    .main-content {
        padding: 12px;
    }

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

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

    .two-column {
        grid-template-columns: 1fr;
    }

    .metric-value {
        font-size: 18px;
    }

    .stat-value {
        font-size: 18px;
    }
}
