/* === RESET & BASE === */

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

html,
body {
    min-height: 100%;
}

body {
    background: radial-gradient(circle at 10% 10%, #121721 0%, var(--bg) 42%, #0a0c0f 100%);
    color: var(--text-1);
    font-family: "Plus Jakarta Sans", sans-serif;
}

img {
    max-width: 100%;
    display: block;
}

button,
input,
select {
    font: inherit;
}


/* === CSS VARIABLES === */

:root {
    --bg: #0d0f12;
    --surface: #161a20;
    --surface-2: #1e2329;
    --surface-3: #252b33;
    --border: #2a3040;
    --border-bright: #3d4859;
    --accent: #6c63ff;
    --accent-dim: #4f49cc;
    --accent-glow: rgba(108, 99, 255, 0.15);
    --green: #2dd4a0;
    --amber: #f5a623;
    --red: #ff5c5c;
    --blue: #4da6ff;
    --text-1: #f0f2f5;
    --text-2: #8b95a5;
    --text-3: #525d6e;
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
}


/* === TYPOGRAPHY === */

h1,
h2,
h3,
h4 {
    font-weight: 600;
    letter-spacing: -0.02em;
}

p,
small,
label,
span {
    color: var(--text-2);
}

.mono-number {
    font-family: "JetBrains Mono", monospace;
}


/* === LAYOUT & SHELL === */

.app-shell {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: 100vh;
}

.main-content {
    padding: 20px 24px;
    overflow-y: auto;
}

.page-content {
    margin-top: 16px;
    animation: fade-in 150ms ease;
}

.hidden {
    display: none !important;
}


/* === SIDEBAR NAV === */

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    height: 100vh;
    position: sticky;
    top: 0;
    display: grid;
    grid-template-rows: auto 1fr auto;
    padding: 20px 14px;
}

.sidebar-head h1 {
    color: var(--text-1);
    font-size: 18px;
}

.sidebar-head p {
    color: var(--text-3);
    font-size: 12px;
    margin-top: 2px;
}

.sidebar-nav {
    margin-top: 24px;
    display: grid;
    align-content: start;
    grid-auto-rows: min-content;
    gap: 8px;
}

.nav-item {
    height: 40px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px;
    color: var(--text-2);
    background: transparent;
    cursor: pointer;
    text-align: left;
    transition: all 200ms ease;
}

.nav-item:hover {
    background: var(--surface-3);
    border-color: var(--border-bright);
}

.nav-item.active {
    background: var(--accent-glow);
    color: var(--accent);
    border-left: 3px solid var(--accent);
}

.nav-item svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.sidebar-foot {
    padding: 10px 8px;
    border-top: 1px solid var(--border);
}

.sidebar-foot small {
    color: var(--text-3);
    font-size: 11px;
}


/* === TOP BAR === */

.topbar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topbar h2 {
    color: var(--text-1);
    font-size: 24px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-cgpa .mono-number {
    font-size: 32px;
    font-weight: 600;
}


/* === CARDS & SURFACES === */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    transition: transform 200ms ease;
}

.card:hover {
    transform: translateY(-2px);
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

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

.stack {
    display: grid;
    gap: 14px;
}

.section-title {
    color: var(--text-1);
    font-size: 18px;
    margin-bottom: 8px;
}

.resource-item {
    padding: 14px;
}

.resource-item-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

.resource-item-head h4 {
    margin-bottom: 4px;
}


/* === GRADE TABLE === */

.semester-block {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--surface);
}

.semester-head {
    position: sticky;
    top: 0;
    z-index: 2;
    background: rgba(22, 26, 32, 0.96);
    border-bottom: 1px solid var(--border);
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.semester-head h3 {
    color: var(--text-1);
    font-size: 16px;
}

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

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 10px;
    font-size: 14px;
    text-align: left;
}

th {
    color: var(--text-2);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}

tbody tr:nth-child(odd) {
    background: var(--surface);
}

tbody tr:nth-child(even) {
    background: var(--surface-2);
}

tbody tr.completed {
    border-left: 3px solid var(--green);
}

tbody tr.empty {
    border-left: 3px solid var(--border);
}

tfoot td {
    border-top: 1px solid var(--border-bright);
    background: var(--surface-2);
    color: var(--text-1);
}

.code-pill {
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(77, 166, 255, 0.1);
    color: var(--blue);
    font-size: 12px;
    font-weight: 600;
}


/* === BUTTONS === */

.btn {
    border: none;
    border-radius: var(--radius-md);
    padding: 10px 20px;
    font-weight: 600;
    cursor: pointer;
    transition: all 200ms ease;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-dim);
    transform: scale(1.02);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-bright);
    color: var(--text-1);
}

.btn-secondary:hover {
    background: var(--surface-2);
}

.btn-sm {
    padding: 6px 10px;
    font-size: 12px;
}

.pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pill {
    border: 1px solid var(--border-bright);
    background: var(--surface-2);
    color: var(--text-1);
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
    max-width: 100%;
}

.pill.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}


/* === INPUTS & SELECTS === */

input,
select,
textarea {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-1);
    padding: 10px 12px;
    width: 100%;
}

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

label {
    font-size: 13px;
    color: var(--text-2);
    margin-bottom: 6px;
    display: block;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

select.grade-select {
    appearance: none;
}

select.grade-A,
select.grade-Bplus,
select.grade-B {
    color: var(--green);
}

select.grade-Cplus,
select.grade-C {
    color: var(--amber);
}

select.grade-Dplus,
select.grade-D,
select.grade-F {
    color: var(--red);
}


/* === GPA DISPLAY === */

.metric-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px 20px;
}

.metric-label {
    font-size: 12px;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.metric-value {
    margin-top: 4px;
    font-size: 28px;
    color: var(--text-1);
    font-family: "JetBrains Mono", monospace;
    font-weight: 600;
}

.degree-banner {
    border-radius: 999px;
    border: 1px solid var(--border-bright);
    padding: 14px 18px;
    text-align: center;
    background: linear-gradient(90deg, rgba(108, 99, 255, 0.08), rgba(77, 166, 255, 0.08));
}

.degree-banner h3 {
    color: var(--text-1);
}

.degree-banner.degree-first {
    border-color: var(--green);
}

.degree-banner.degree-upper {
    border-color: var(--blue);
}

.degree-banner.degree-lower {
    border-color: var(--amber);
}

.degree-banner.degree-pass {
    border-color: var(--red);
}


/* === BADGES & PILLS === */

.badge {
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.badge-first {
    background: rgba(45, 212, 160, 0.15);
    color: var(--green);
}

.badge-upper {
    background: rgba(77, 166, 255, 0.15);
    color: var(--blue);
}

.badge-lower {
    background: rgba(245, 166, 35, 0.15);
    color: var(--amber);
}

.badge-pass,
.badge-future {
    background: rgba(255, 92, 92, 0.15);
    color: var(--red);
}


/* === CHART AREA === */

.chart-wrap {
    height: 320px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px;
}


/* === TIMETABLE VIEWER === */

.timetable-wrap {
    display: grid;
    gap: 10px;
}

.timetable-note {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 13px;
}

.timetable-image {
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    width: 100%;
}

.timetable-placeholder {
    border: 1px dashed var(--border-bright);
    border-radius: var(--radius-md);
    padding: 30px;
    text-align: center;
    background: var(--surface-2);
}

.future-lock-note {
    border: none;
    border-radius: 0;
}

.drag-item-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
}

.text-primary {
    color: var(--text-1);
}

.text-positive {
    color: var(--green);
}

.text-negative {
    color: var(--red);
}

.text-warn {
    color: var(--amber);
}

.link-blue {
    color: var(--blue);
}

.mt-8 {
    margin-top: 8px;
}

.mt-10 {
    margin-top: 10px;
}

.mt-12 {
    margin-top: 12px;
}

.onboard-sem-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.onboard-sem-grid .pill {
    width: 100%;
    min-height: 44px;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: center;
    line-height: 1.25;
}


/* === TOAST === */

.toast-container {
    position: fixed;
    right: 16px;
    bottom: 16px;
    display: grid;
    gap: 10px;
    z-index: 120;
}

.toast {
    min-width: 280px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: var(--surface);
    border: 1px solid var(--border-bright);
    color: var(--text-1);
    animation: slide-in 300ms ease;
}


/* === ONBOARDING MODAL === */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 18px;
}

.modal-card {
    width: min(480px, 100%);
    border-radius: var(--radius-xl);
    background: var(--surface);
    border: 1px solid var(--border-bright);
    padding: 32px;
}

.modal-card h2 {
    color: var(--text-1);
    margin-bottom: 6px;
}

.modal-card p {
    margin-bottom: 14px;
}

.onboard-check-row {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    color: var(--text-1);
    font-size: 14px;
    cursor: pointer;
}

.onboard-check-input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.onboard-check-row span {
    color: var(--text-1);
    line-height: 1.2;
}

.pin-dots {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 14px 0;
}

.pin-dot {
    width: 16px;
    height: 16px;
    border: 1px solid var(--border-bright);
    border-radius: 50%;
    background: transparent;
}

.pin-dot.filled {
    background: var(--accent);
    border-color: var(--accent);
}

.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.numpad button {
    height: 46px;
    border-radius: var(--radius-md);
}


/* === ANIMATIONS & TRANSITIONS === */

@keyframes slide-in {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}


/* === RESPONSIVE (≤768px) === */

@media (max-width: 768px) {
    .app-shell {
        grid-template-columns: 1fr;
    }
    .sidebar {
        display: none;
    }
    .main-content {
        padding: 14px;
        padding-bottom: 72px;
    }
    .grid-4,
    .grid-2,
    .field-grid {
        grid-template-columns: 1fr;
    }
    .onboard-sem-grid {
        grid-template-columns: 1fr;
    }
    .mobile-tabs {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--surface);
        border-top: 1px solid var(--border);
        padding: 8px;
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 8px;
        z-index: 60;
    }
    .mobile-tab {
        border: 1px solid var(--border);
        background: var(--surface-2);
        color: var(--text-2);
        border-radius: var(--radius-md);
        height: 42px;
        display: grid;
        place-items: center;
    }
    .mobile-tab svg {
        width: 20px;
        height: 20px;
        fill: currentColor;
    }
    .mobile-tab.active {
        border-color: var(--accent);
        color: var(--accent);
        background: var(--accent-glow);
    }
    .mobile-more-panel {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: 64px;
        z-index: 61;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        padding: 10px;
        display: grid;
        gap: 8px;
        box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
    }
    .mobile-more-item {
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: var(--surface-2);
        color: var(--text-1);
        padding: 12px;
        text-align: left;
        display: grid;
        gap: 2px;
    }
    .mobile-more-item small {
        color: var(--text-2);
    }
}

@media (min-width: 769px) {
    .mobile-tabs {
        display: none;
    }
    .mobile-more-panel {
        display: none;
    }
}


/* === TOAST NOTIFICATIONS === */

.toast-container {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    display: grid;
    gap: 0.55rem;
    z-index: 30;
}

.toast {
    min-width: 210px;
    max-width: 300px;
    color: #fff;
    padding: 0.65rem 0.85rem;
    border-radius: 9px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
    animation: toastIn 0.25s ease;
}

.toast--success {
    background: var(--accent-dim);
}

.toast--error {
    background: var(--danger);
}

.toast--info {
    background: var(--info);
}

.toast--fade {
    opacity: 0;
    transform: translateY(6px);
}


/* === FOOTER === */

.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface-2);
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-3);
    z-index: 10;
}

.app-footer p {
    margin: 0;
    letter-spacing: 0.3px;
}

transition: opacity 0.2s ease,
transform 0.2s ease;

}

/* === MODAL DIALOG === */
body.modal-open {
    overflow: hidden;
}
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    background: rgba(15, 23, 42, 0.62);
    padding: 1rem;
}
.modal {
    width: min(420px, 100%);
    background: var(--card);
    color: var(--text-primary);
    border-radius: var(--radius);
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.15);
    padding: var(--space-4);
    display: grid;
    gap: var(--space-2);
    animation: panelFade 0.2s ease;
}
.modal__title {
    margin: 0;
    font-size: 1.15rem;
}
.modal__message {
    margin: 0;
    color: var(--text-muted);
}
.modal__input {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0.6rem 0.65rem;
    background: #fff;
    color: var(--text-primary);
}
.modal__input:focus {
    outline: none;
    border-color: var(--accent);
}
.modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-1);
    margin-top: var(--space-1);
}
.modal__btn {
    min-width: 88px;
}

/* === CHARTS SECTION === */
.chart-wrap {
    width: 100%;
    min-height: 260px;
}
.chart-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

/* === INSIGHTS CARDS === */
.insights-stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: var(--space-2);
    margin-top: var(--space-3);
}
.stat-card {
    background: var(--card);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
}
.stat-card__title {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.35rem;
}
.stat-card__value {
    font-weight: 700;
    word-break: break-word;
}
.dragging-list {
    margin-top: var(--space-2);
    display: grid;
    gap: 0.65rem;
}
.dragging-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.65rem;
    border: 1px solid #fecaca;
    background: #fff1f2;
    border-radius: 10px;
    padding: 0.55rem 0.7rem;
}
.dragging-item__badge {
    font-family: var(--font-number);
    background: #fecdd3;
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    color: #9f1239;
    font-weight: 700;
    white-space: nowrap;
}
.result-text {
    margin-top: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* === ANIMATIONS === */
@keyframes panelFade {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === RESPONSIVE === */
@media (max-width: 980px) {
    .insights-stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
@media (max-width: 760px) {
    body {
        padding: 0.8rem;
    }
    
    .app-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .app-header__actions {
        justify-content: flex-start;
    }
    
    .app-main {
        padding: 0.9rem;
    }
    
    .app-footer {
        margin-top: 0.65rem;
    }
    
    .forecast-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .course-row {
        grid-template-columns: 1fr;
    }
    
    .insights-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 430px) {
    .tabs-nav {
        grid-template-columns: repeat(3, minmax(120px, 1fr));
    }
    
    .insights-stats {
        grid-template-columns: 1fr;
    }
    
    .toast-container {
        left: 0.6rem;
        right: 0.6rem;
        bottom: 0.6rem;
    }
    
    .toast {
        max-width: 100%;
    }
}