/* ─── Thisara Ranjeewa Student Manager — Front-end Portal CSS ─────── */

:root {
    --tsm-primary:       #2563eb;
    --tsm-primary-dark:  #1d4ed8;
    --tsm-accent:        #7c3aed;
    --tsm-success:       #059669;
    --tsm-danger:        #dc2626;
    --tsm-surface:       #ffffff;
    --tsm-surface2:      #f8fafc;
    --tsm-border:        #e2e8f0;
    --tsm-text:          #1e293b;
    --tsm-text-muted:    #64748b;
    --tsm-radius:        14px;
    --tsm-shadow:        0 4px 24px rgba(0,0,0,.10);
}

/* Portal wrapper */
.tsm-portal { font-family: 'Segoe UI', system-ui, sans-serif; color: var(--tsm-text); max-width: 1000px; margin: 0 auto; }

/* ─── Login Screen ───────────────────────────────────────────────── */
.tsm-login-screen { display: flex; justify-content: center; padding: 40px 16px; }
.tsm-login-card {
    background: var(--tsm-surface);
    border-radius: var(--tsm-radius);
    box-shadow: var(--tsm-shadow);
    padding: 48px 40px;
    width: 100%;
    max-width: 440px;
    border-top: 5px solid var(--tsm-primary);
}
.tsm-login-brand { text-align: center; margin-bottom: 32px; }
.tsm-login-icon { font-size: 3rem; display: block; margin-bottom: 10px; }
.tsm-login-brand h2 { margin: 0 0 4px; font-size: 1.5rem; font-weight: 800; color: var(--tsm-primary); }
.tsm-login-brand p  { margin: 0; color: var(--tsm-text-muted); font-size: .9rem; }

.tsm-login-error { background: #fee2e2; color: #991b1b; padding: 11px 16px; border-radius: 8px; font-size: .88rem; margin-bottom: 18px; border-left: 4px solid #dc2626; }

.tsm-login-fields { display: flex; flex-direction: column; gap: 18px; }
.tsm-login-field label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 6px; color: var(--tsm-text); }
.tsm-login-field input {
    width: 100%; padding: 12px 16px; border: 1.5px solid var(--tsm-border);
    border-radius: 9px; font-size: .95rem; outline: none; box-sizing: border-box;
    transition: border-color .15s, box-shadow .15s;
}
.tsm-login-field input:focus { border-color: var(--tsm-primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

.tsm-login-btn {
    margin-top: 6px; width: 100%; padding: 14px; background: var(--tsm-primary);
    color: #fff; border: none; border-radius: 9px; font-size: 1rem;
    font-weight: 700; cursor: pointer; transition: background .15s;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.tsm-login-btn:hover { background: var(--tsm-primary-dark); }
.tsm-btn-spinner { animation: tsm-spin .7s linear infinite; display: inline-block; }
@keyframes tsm-spin { to { transform: rotate(360deg); } }

/* ─── Profile Screen ─────────────────────────────────────────────── */
.tsm-profile-header {
    background: linear-gradient(135deg, var(--tsm-primary) 0%, var(--tsm-accent) 100%);
    border-radius: var(--tsm-radius);
    padding: 28px 32px;
    display: flex; align-items: center; gap: 20px;
    margin-bottom: 24px; color: #fff; position: relative;
}
.tsm-profile-avatar {
    width: 70px; height: 70px; border-radius: 50%;
    background: rgba(255,255,255,.25);
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; font-weight: 800; color: #fff;
    flex-shrink: 0; border: 3px solid rgba(255,255,255,.4);
}
.tsm-profile-info { flex: 1; }
.tsm-profile-info h2 { margin: 0 0 8px; font-size: 1.5rem; font-weight: 800; }
.tsm-profile-meta { display: flex; flex-wrap: wrap; gap: 14px; font-size: .88rem; opacity: .92; }
.tsm-profile-meta span { display: flex; align-items: center; gap: 5px; }
.tsm-logout-btn {
    position: absolute; top: 16px; right: 18px;
    background: rgba(255,255,255,.2); color: #fff;
    border: 1.5px solid rgba(255,255,255,.4); border-radius: 7px;
    padding: 7px 16px; font-size: .83rem; font-weight: 600;
    cursor: pointer; transition: background .15s;
}
.tsm-logout-btn:hover { background: rgba(255,255,255,.35); }

/* Results section (now also wraps the overall-performance chart) */
.tsm-results-section {
    background: var(--tsm-surface); border-radius: var(--tsm-radius);
    box-shadow: var(--tsm-shadow); padding: 24px 28px; margin-bottom: 24px;
}
.tsm-results-section h3 {
    margin: 0 0 20px; font-size: 1.1rem; font-weight: 700;
    padding-bottom: 12px; border-bottom: 1px solid var(--tsm-border);
}

/* Overall chart now lives INSIDE .tsm-results-section, below the
   per-year tables — separated with a top divider instead of its own card */
.tsm-overall-chart { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--tsm-border); }

/* Year block */
.tsm-year-block { margin-bottom: 28px; }
.tsm-year-label {
    display: inline-flex; align-items: center; gap: 8px;
    background: linear-gradient(90deg, var(--tsm-primary), var(--tsm-accent));
    color: #fff; padding: 5px 16px; border-radius: 20px;
    font-size: .85rem; font-weight: 700; margin-bottom: 12px;
}
.tsm-year-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tsm-year-table thead th {
    background: var(--tsm-surface2); padding: 9px 13px; text-align: left;
    font-weight: 600; font-size: .78rem; text-transform: uppercase;
    letter-spacing: .04em; color: var(--tsm-text-muted);
    border-bottom: 1px solid var(--tsm-border);
}
.tsm-year-table tbody td { padding: 10px 13px; border-bottom: 1px solid var(--tsm-border); vertical-align: middle; }
.tsm-year-table tbody tr:last-child td { border-bottom: none; }
.tsm-year-table tbody tr:hover { background: #f8fafc; }

/* Pass grade pills */
.tsm-pg { padding: 3px 9px; border-radius: 20px; font-size: .78rem; font-weight: 700; display: inline-block; }
.tsm-pg-aplus, .tsm-pg-a   { background: #dcfce7; color: #166534; }
.tsm-pg-aminus              { background: #d1fae5; color: #065f46; }
.tsm-pg-bplus, .tsm-pg-b, .tsm-pg-bminus { background: #dbeafe; color: #1e40af; }
.tsm-pg-cplus, .tsm-pg-c, .tsm-pg-cminus { background: #fef9c3; color: #854d0e; }
.tsm-pg-d { background: #ffedd5; color: #9a3412; }
.tsm-pg-f { background: #fee2e2; color: #991b1b; }

.tsm-marks-strong { font-weight: 700; font-size: 1rem; color: var(--tsm-primary); }
.tsm-place-badge { background: #fef9c3; color: #78350f; padding: 2px 8px; border-radius: 5px; font-size: .8rem; font-weight: 600; }

/* Chart */
.tsm-chart-wrap { position: relative; height: 300px; }

/* ─── Responsive — Tablet (≤768px) ──────────────────────────────── */
@media (max-width: 768px) {
    .tsm-portal { padding: 0 4px; }

    .tsm-results-section {
        padding: 18px 16px;
        margin-bottom: 16px;
        border-radius: 10px;
    }

    /* Overall chart shorter on tablet */
    .tsm-chart-wrap { height: 240px; }
}

/* ─── Responsive — Mobile (≤600px) ──────────────────────────────── */
@media (max-width: 600px) {
    /* Login */
    .tsm-login-card { padding: 28px 16px; }

    /* Profile header */
    .tsm-profile-header {
        flex-direction: column;
        text-align: center;
        padding: 20px 16px;
        gap: 14px;
    }
    .tsm-profile-meta { justify-content: center; flex-wrap: wrap; gap: 10px; font-size: .82rem; }
    .tsm-logout-btn { position: static; margin-top: 4px; width: 100%; text-align: center; }

    /* Results section card padding */
    .tsm-results-section {
        padding: 16px 12px;
        border-radius: 10px;
    }
    .tsm-results-section h3 { font-size: 1rem; margin-bottom: 14px; }

    /* Tighter divider above the overall chart on mobile */
    .tsm-overall-chart { margin-top: 20px; padding-top: 16px; }

    /* Year block */
    .tsm-year-block { margin-bottom: 20px; }

    /* ── Table: card / stacked layout on mobile ─────────────────── */
    .tsm-year-table,
    .tsm-year-table thead,
    .tsm-year-table tbody,
    .tsm-year-table th,
    .tsm-year-table td,
    .tsm-year-table tr {
        display: block;
    }

    /* Hide the header row — labels come from data-label attributes */
    .tsm-year-table thead tr { display: none; }

    .tsm-year-table tbody tr {
        margin-bottom: 10px;
        border: 1px solid var(--tsm-border);
        border-radius: 9px;
        overflow: hidden;
        background: var(--tsm-surface);
    }
    .tsm-year-table tbody tr:last-child { margin-bottom: 0; }
    .tsm-year-table tbody tr:hover { background: var(--tsm-surface2); }

    .tsm-year-table tbody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 9px 13px;
        border-bottom: 1px solid var(--tsm-border);
        font-size: .85rem;
        gap: 8px;
    }
    .tsm-year-table tbody td:last-child { border-bottom: none; }

    /* Label injected via pseudo-element using data-label attribute */
    .tsm-year-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: .75rem;
        text-transform: uppercase;
        letter-spacing: .04em;
        color: var(--tsm-text-muted);
        flex-shrink: 0;
        min-width: 80px;
    }

    /* Marks bar: full width on its own line inside the cell */
    .tsm-marks-cell {
        min-width: unset;
        flex: 1;
        align-items: flex-end;
    }
    .tsm-marks-bar-wrap { width: 100%; }

    /* Overall chart: shorter on small screens */
    .tsm-chart-wrap { height: 200px; }

    /* Year inner: tighter gap and shorter chart on mobile */
    .tsm-year-inner { gap: 12px; }
    .tsm-year-chart-wrap { height: 180px; }
}

/* ─── Per-year layout (table then chart stacked) ─────────────────── */
.tsm-year-header { margin-bottom: 10px; }
.tsm-year-inner {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.tsm-year-chart-wrap {
    position: relative;
    height: 220px;
    background: var(--tsm-surface2);
    border-radius: 10px;
    padding: 10px;
    border: 1px solid var(--tsm-border);
}

/* Inline marks bar in table */
.tsm-marks-cell { display: flex; flex-direction: column; gap: 4px; min-width: 90px; }
.tsm-marks-num  { font-weight: 700; font-size: .95rem; color: var(--tsm-primary); }
.tsm-marks-bar-wrap { height: 5px; background: var(--tsm-border); border-radius: 10px; overflow: hidden; }
.tsm-marks-bar  { height: 100%; border-radius: 10px; transition: width .5s ease; }

.tsm-no-results { color: var(--tsm-text-muted); text-align: center; padding: 24px 0; }
