/* ==========================================================================
   Graduation Projects Tracker — custom styles on top of Bootstrap 5.3
   ========================================================================== */

:root {
    --app-primary: #4f46e5;
    --app-primary-rgb: 79, 70, 229;
    --app-sidebar-width: 260px;
    --app-topbar-height: 60px;
    --app-surface: #ffffff;
    --app-bg: #f4f6fb;
    --bs-primary: var(--app-primary);
    --bs-primary-rgb: var(--app-primary-rgb);
    --bs-link-color: var(--app-primary);
    --bs-link-color-rgb: var(--app-primary-rgb);
    --bs-link-hover-color: #4338ca;
}

[data-bs-theme="dark"] {
    --app-surface: #1b1f27;
    --app-bg: #12151b;
    --app-primary: #818cf8;
    --app-primary-rgb: 129, 140, 248;
    --bs-link-hover-color: #a5b4fc;
}

.btn-primary {
    --bs-btn-bg: var(--app-primary);
    --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: #4338ca;
    --bs-btn-hover-border-color: #4338ca;
    --bs-btn-active-bg: #3730a3;
    --bs-btn-active-border-color: #3730a3;
    --bs-btn-disabled-bg: var(--app-primary);
    --bs-btn-disabled-border-color: var(--app-primary);
}
[data-bs-theme="dark"] .btn-primary { --bs-btn-color: #11131a; --bs-btn-hover-color: #11131a; --bs-btn-active-color: #11131a; --bs-btn-hover-bg: #a5b4fc; --bs-btn-hover-border-color: #a5b4fc; }
.btn-outline-primary {
    --bs-btn-color: var(--app-primary);
    --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: var(--app-primary);
    --bs-btn-hover-border-color: var(--app-primary);
    --bs-btn-active-bg: var(--app-primary);
    --bs-btn-active-border-color: var(--app-primary);
}
.text-bg-primary { background-color: var(--app-primary) !important; }
.nav-pills { --bs-nav-pills-link-active-bg: rgba(var(--app-primary-rgb), .12); --bs-nav-pills-link-active-color: var(--app-primary); }
.progress { --bs-progress-bar-bg: var(--app-primary); }
.form-check-input:checked { background-color: var(--app-primary); border-color: var(--app-primary); }
.form-control:focus, .form-select:focus { border-color: rgba(var(--app-primary-rgb), .6); box-shadow: 0 0 0 .2rem rgba(var(--app-primary-rgb), .18); }

body.app-body { background: var(--app-bg); min-height: 100vh; }

/* ---------- Top bar ---------- */
.app-topbar {
    background: var(--app-surface);
    height: var(--app-topbar-height);
    z-index: 1030;
}
.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff; font-size: 1.1rem; flex-shrink: 0;
}
.brand-mark-lg { width: 56px; height: 56px; border-radius: 16px; font-size: 1.75rem; }
.brand-text { max-width: 55vw; }

.avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(var(--app-primary-rgb), .14); color: var(--app-primary);
    font-weight: 600; font-size: .9rem; flex-shrink: 0;
}
.avatar-sm { width: 32px; height: 32px; font-size: .75rem; }
.avatar-leader { background: #fef3c7; color: #b45309; }
[data-bs-theme="dark"] .avatar-leader { background: #3f3112; color: #fbbf24; }

/* ---------- Shell / sidebar ---------- */
.app-shell { display: flex; min-height: calc(100vh - var(--app-topbar-height)); }
.app-main { flex: 1; min-width: 0; }

@media (min-width: 992px) {
    .app-sidebar {
        width: var(--app-sidebar-width);
        flex-shrink: 0;
        background: var(--app-surface);
        border-right: 1px solid var(--bs-border-color);
        position: sticky;
        top: var(--app-topbar-height);
        height: calc(100vh - var(--app-topbar-height));
        overflow-y: auto;
    }
    .app-sidebar .offcanvas-body { display: flex; height: 100%; }
}
@media (max-width: 991.98px) {
    .app-sidebar { --bs-offcanvas-width: 280px; }
}

.app-sidebar .nav-link {
    display: flex; align-items: center; gap: .75rem;
    color: var(--bs-body-color); border-radius: .6rem;
    padding: .55rem .8rem; font-weight: 500; font-size: .94rem;
}
.app-sidebar .nav-link i { font-size: 1.1rem; opacity: .8; }
.app-sidebar .nav-link:hover { background: var(--bs-tertiary-bg); }
.app-sidebar .nav-link.active { font-weight: 600; }
.app-sidebar .nav-link.active i { opacity: 1; }
.nav-section {
    font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
    color: var(--bs-secondary-color); font-weight: 600; padding: .5rem .8rem .25rem;
}

/* ---------- Page header ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.45rem; font-weight: 700; margin-bottom: .15rem; }
.page-header .subtitle { color: var(--bs-secondary-color); font-size: .92rem; }
.breadcrumb { font-size: .85rem; margin-bottom: .35rem; }

/* ---------- Cards ---------- */
.card { border: 1px solid var(--bs-border-color-translucent); border-radius: .9rem; background: var(--app-surface); box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.card-header { background: transparent; border-bottom-color: var(--bs-border-color-translucent); padding: .9rem 1.1rem; font-weight: 600; }
.card-header:first-child { border-radius: .9rem .9rem 0 0; }
.card-body { padding: 1.1rem; }

.stat-card .stat-icon {
    width: 46px; height: 46px; border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.35rem; flex-shrink: 0;
}
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-card .stat-label { font-size: .82rem; color: var(--bs-secondary-color); }
.bg-soft-primary { background: rgba(var(--app-primary-rgb), .12); color: var(--app-primary); }
.bg-soft-success { background: rgba(25, 135, 84, .12); color: #198754; }
.bg-soft-warning { background: rgba(255, 193, 7, .18); color: #b58105; }
.bg-soft-danger  { background: rgba(220, 53, 69, .12); color: #dc3545; }
.bg-soft-info    { background: rgba(13, 202, 240, .14); color: #0a8ea8; }
[data-bs-theme="dark"] .bg-soft-success { color: #4ade80; }
[data-bs-theme="dark"] .bg-soft-warning { color: #fbbf24; }
[data-bs-theme="dark"] .bg-soft-danger  { color: #f87171; }
[data-bs-theme="dark"] .bg-soft-info    { color: #67e8f9; }

.table > :not(caption) > * > * { padding: .7rem .85rem; }
.table thead th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); font-weight: 600; white-space: nowrap; }
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: var(--bs-tertiary-bg); }

.progress-thin { height: 6px; border-radius: 99px; }

/* ---------- Roadmap / timeline ---------- */
.roadmap { list-style: none; padding: 0; margin: 0; position: relative; }
.roadmap::before {
    content: ""; position: absolute; left: 21px; top: 8px; bottom: 8px;
    width: 2px; background: var(--bs-border-color);
}
.roadmap-item { position: relative; padding-left: 58px; margin-bottom: .75rem; }
.roadmap-item:last-child { margin-bottom: 0; }
.roadmap-dot {
    position: absolute; left: 4px; top: 12px;
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .85rem;
    background: var(--app-surface); border: 2px solid var(--bs-border-color); color: var(--bs-secondary-color);
    z-index: 1;
}
.roadmap-item[data-status="Delivered"] .roadmap-dot { background: #198754; border-color: #198754; color: #fff; }
.roadmap-item[data-status="InProgress"] .roadmap-dot { border-color: var(--app-primary); color: var(--app-primary); box-shadow: 0 0 0 4px rgba(var(--app-primary-rgb), .15); }
.roadmap-item[data-status="Submitted"] .roadmap-dot { background: #0dcaf0; border-color: #0dcaf0; color: #052c33; }
.roadmap-item[data-status="NeedsRevision"] .roadmap-dot { background: #ffc107; border-color: #ffc107; color: #3d2e00; }
.roadmap-item[data-status="Delayed"] .roadmap-dot { background: #dc3545; border-color: #dc3545; color: #fff; }
.roadmap-card {
    display: block; text-decoration: none; color: inherit;
    border: 1px solid var(--bs-border-color-translucent); border-radius: .8rem;
    padding: .8rem 1rem; background: var(--app-surface); transition: border-color .15s, box-shadow .15s, transform .15s;
}
a.roadmap-card:hover { border-color: rgba(var(--app-primary-rgb), .5); box-shadow: 0 4px 14px rgba(16, 24, 40, .08); transform: translateY(-1px); color: inherit; }
.roadmap-item.is-current .roadmap-card { border-color: rgba(var(--app-primary-rgb), .55); background: rgba(var(--app-primary-rgb), .04); }
.roadmap-meta { font-size: .8rem; color: var(--bs-secondary-color); }

/* Compact 12-week strip (student dashboard / reports) */
.week-strip { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; }
.week-strip .wk {
    height: 30px; border-radius: 6px; display: flex; align-items: center; justify-content: center;
    font-size: .72rem; font-weight: 600; text-decoration: none;
    background: var(--bs-tertiary-bg); color: var(--bs-secondary-color);
}
.week-strip .wk[data-status="Delivered"] { background: #198754; color: #fff; }
.week-strip .wk[data-status="InProgress"] { background: rgba(var(--app-primary-rgb), .2); color: var(--app-primary); outline: 2px solid var(--app-primary); outline-offset: -2px; }
.week-strip .wk[data-status="Submitted"] { background: #0dcaf0; color: #052c33; }
.week-strip .wk[data-status="NeedsRevision"] { background: #ffc107; color: #3d2e00; }
.week-strip .wk[data-status="Delayed"] { background: #dc3545; color: #fff; }
@media (max-width: 400px) { .week-strip { grid-template-columns: repeat(6, 1fr); } }

/* ---------- Comments ---------- */
.comment { display: flex; gap: .75rem; }
.comment + .comment { margin-top: 1rem; }
.comment-bubble { background: var(--bs-tertiary-bg); border-radius: .2rem .9rem .9rem .9rem; padding: .65rem .9rem; flex: 1; min-width: 0; }
.comment-bubble.is-instructor { background: rgba(var(--app-primary-rgb), .08); border: 1px solid rgba(var(--app-primary-rgb), .18); }
.comment-body { white-space: pre-wrap; word-wrap: break-word; margin: 0; }

/* ---------- Files ---------- */
.file-icon {
    width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 1.3rem;
    background: var(--bs-tertiary-bg);
}
.upload-row { border: 1px dashed var(--bs-border-color); border-radius: .75rem; padding: .85rem; background: var(--bs-tertiary-bg); }
.upload-row + .upload-row { margin-top: .75rem; }

/* ---------- Student picker ---------- */
.student-picker { max-height: 340px; overflow-y: auto; }
.student-picker .list-group-item { cursor: pointer; }
.student-picker .list-group-item.is-selected { background: rgba(var(--app-primary-rgb), .08); }

/* ---------- Guest / login ---------- */
body.guest-body {
    min-height: 100vh;
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(99, 102, 241, .18), transparent 60%),
        radial-gradient(900px 500px at 110% 110%, rgba(16, 185, 129, .12), transparent 60%),
        var(--app-bg);
}
.guest-main { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem 1rem; }

/* ---------- Utilities ---------- */
.min-w-0 { min-width: 0; }
.fs-7 { font-size: .85rem; }
.text-pre { white-space: pre-wrap; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--bs-secondary-color); }
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: .5rem; opacity: .6; }

/* Mobile tweaks */
@media (max-width: 575.98px) {
    .page-header h1 { font-size: 1.25rem; }
    .page-header .btn { flex: 1 1 auto; }
    .card-body { padding: .9rem; }
    .stat-card .stat-value { font-size: 1.35rem; }
    .table-mobile-cards thead { display: none; }
    .table-mobile-cards tbody tr { display: block; border-bottom: 1px solid var(--bs-border-color); padding: .5rem 0; }
    .table-mobile-cards tbody td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .3rem .85rem; text-align: right; }
    .table-mobile-cards tbody td::before { content: attr(data-label); font-weight: 600; color: var(--bs-secondary-color); text-align: left; font-size: .82rem; }
    .table-mobile-cards tbody td.td-main { display: block; text-align: left; }
    .table-mobile-cards tbody td.td-main::before { display: none; }
}

/* ---------- Print (reports) ---------- */
@media print {
    .app-topbar, .app-sidebar, .no-print, .alert { display: none !important; }
    body.app-body, .card { background: #fff !important; }
    .card { box-shadow: none !important; border-color: #ccc !important; break-inside: avoid; }
    .app-main .container-fluid { padding: 0 !important; }
    a { text-decoration: none !important; color: inherit !important; }
}
