/* =======================================================
   SEI – style.css
   Compatibility + UI polish layer
   Loads the main design system from assets/css/app.css
   ======================================================= */

@import url('../assets/css/app.css');

/* -------------------------------------------------------
   Legacy selector compatibility
   Use this if old PHP pages still use <header> instead of .main-header
------------------------------------------------------- */

header:not(.main-header) {
    background: linear-gradient(135deg, var(--slate-950, #020617) 0%, #1a2a4a 100%);
    color: var(--white, #ffffff);
    height: var(--header-h, 64px);
    padding: 0 var(--page-pad, 32px);
    display: flex;
    align-items: center;
    gap: var(--space-3, 12px);
    position: sticky;
    top: 0;
    z-index: 200;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 2px 24px rgba(0, 0, 0, 0.35);
}

header:not(.main-header)::before {
    content: '';
    display: block;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--blue-500, #3b82f6), var(--blue-400, #60a5fa));
    border-radius: var(--radius-sm, 6px);
    flex-shrink: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='22 7 13.5 15.5 8.5 10.5 2 17'/%3E%3Cpolyline points='16 7 22 7 22 13'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 18px;
}

header:not(.main-header) > div {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

header:not(.main-header) h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--white, #ffffff);
    letter-spacing: -0.3px;
    line-height: 1.2;
}

header:not(.main-header) p {
    margin: 0;
    font-size: 12px;
    color: var(--slate-400, #94a3b8);
    line-height: 1;
}

/* -------------------------------------------------------
   Global polish
------------------------------------------------------- */

body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(59, 130, 246, 0.10), transparent 34rem),
        linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

.container {
    animation: sei-fade-in 0.18s ease-out;
}

@keyframes sei-fade-in {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* -------------------------------------------------------
   Dashboard cards
------------------------------------------------------- */

.card {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.98), rgba(255,255,255,0.94));
    box-shadow:
        0 1px 2px rgba(15,23,42,0.05),
        0 8px 24px rgba(15,23,42,0.06);
}

.card::after {
    content: '';
    position: absolute;
    right: -30px;
    bottom: -30px;
    width: 90px;
    height: 90px;
    border-radius: 999px;
    background: rgba(59,130,246,0.055);
    pointer-events: none;
}

.card .value {
    font-variant-numeric: tabular-nums;
}

/* Optional semantic KPI accent classes */
.card.kpi-good::before,
.card.good::before {
    background: linear-gradient(90deg, #16a34a, #86efac);
}

.card.kpi-warn::before,
.card.warn::before {
    background: linear-gradient(90deg, #d97706, #fbbf24);
}

.card.kpi-bad::before,
.card.bad::before {
    background: linear-gradient(90deg, #dc2626, #f87171);
}

/* -------------------------------------------------------
   Sections
------------------------------------------------------- */

.section {
    backdrop-filter: blur(8px);
}

.section > h2 {
    min-height: 50px;
}

/* If a section contains a wide table, prevent page breakage */
.section table {
    min-width: max-content;
}

.section:has(table) {
    overflow-x: auto;
}

/* Fallback for browsers without :has support */
.section-scroll {
    overflow-x: auto;
}

/* -------------------------------------------------------
   Tables: better fintech density/readability
------------------------------------------------------- */

table {
    font-variant-numeric: tabular-nums;
}

thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

tbody tr {
    transition: background 0.12s ease;
}

tbody tr:nth-child(even) td {
    background: rgba(248, 250, 252, 0.55);
}

tbody tr:nth-child(even):hover td,
tbody tr:hover td {
    background: var(--blue-50, #eff6ff);
}

td:first-child,
th:first-child {
    padding-left: 22px;
}

td:last-child,
th:last-child {
    padding-right: 22px;
}

td.num,
th.num,
.mono {
    font-variant-numeric: tabular-nums;
}

/* Make important symbols/tickers stronger */
td strong,
.asset-symbol,
.ticker {
    color: var(--slate-950, #020617);
    font-weight: 700;
    letter-spacing: -0.2px;
}

/* -------------------------------------------------------
   Badges
------------------------------------------------------- */

.badge {
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35);
}

.buy,
.increase,
.badge-robust {
    background: #dcfce7;
    color: #166534;
    border-color: #86efac;
}

.sell,
.badge-status-failed,
.badge-error,
.note-risk .badge {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
}

.hold,
.neutral {
    background: #eef2ff;
    color: #3730a3;
    border-color: #c7d2fe;
}

/* -------------------------------------------------------
   Forms and buttons
------------------------------------------------------- */

input,
select,
textarea {
    min-height: 38px;
}

button,
input[type="submit"],
.button-secondary {
    min-height: 38px;
}

button,
input[type="submit"] {
    box-shadow: 0 1px 2px rgba(15,23,42,0.12);
}

button:hover,
input[type="submit"]:hover {
    box-shadow: 0 6px 18px rgba(15,23,42,0.16);
}

.button-secondary:hover {
    color: var(--slate-900, #0f172a);
}

/* -------------------------------------------------------
   Navigation active state polish
------------------------------------------------------- */

.main-nav {
    box-shadow: 0 8px 20px rgba(15,23,42,0.12);
}

.main-nav a {
    min-height: 30px;
}

.main-nav a.active {
    color: #bfdbfe;
    background: rgba(59,130,246,0.18);
}

/* -------------------------------------------------------
   Risk and P&L helpers
------------------------------------------------------- */

.pnl-pos,
.positive,
.up {
    color: #15803d;
    font-weight: 700;
}

.pnl-neg,
.negative,
.down {
    color: #b91c1c;
    font-weight: 700;
}

.pnl-flat,
.flat {
    color: var(--slate-500, #64748b);
    font-weight: 600;
}

/* -------------------------------------------------------
   Empty / muted states
------------------------------------------------------- */

.empty-state {
    padding: 36px 24px;
    text-align: center;
    color: var(--slate-500, #64748b);
    background: var(--slate-50, #f8fafc);
}

.empty-state strong {
    display: block;
    color: var(--slate-800, #1e293b);
    font-size: 15px;
    margin-bottom: 4px;
}

/* -------------------------------------------------------
   Footer
------------------------------------------------------- */

.footer {
    opacity: 0.9;
}

/* -------------------------------------------------------
   Mobile fixes
------------------------------------------------------- */

@media (max-width: 768px) {
    header:not(.main-header) {
        height: 56px;
        padding: 0 16px;
    }

    header:not(.main-header)::before {
        width: 26px;
        height: 26px;
        background-size: 15px;
    }

    header:not(.main-header) h1 {
        font-size: 16px;
    }

    header:not(.main-header) p {
        display: none;
    }

    .container {
        padding: 16px;
    }

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

    .card {
        padding: 15px 16px 17px;
    }

    .card .value {
        font-size: 22px;
    }

    td:first-child,
    th:first-child {
        padding-left: 14px;
    }

    td:last-child,
    th:last-child {
        padding-right: 14px;
    }
}

@media (max-width: 480px) {
    .grid {
        grid-template-columns: 1fr;
    }

    .section > h2 {
        font-size: 13.5px;
    }

    table {
        font-size: 12.5px;
    }
}
