/*
 * Shared responsive layer.
 * Loaded after page-specific styles so existing desktop visuals and behavior remain intact.
 */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    min-width: 0;
    overflow-x: hidden;
}

img,
svg,
video,
canvas {
    max-width: 100%;
}

button,
a,
input,
textarea,
select {
    -webkit-tap-highlight-color: transparent;
}

input,
textarea,
select,
button {
    max-width: 100%;
}

/* Shared account bar and notices */
.auth-bar,
.flash-list {
    width: min(100%, 1200px);
    margin-left: auto;
    margin-right: auto;
}

.auth-bar {
    min-height: 48px;
    flex-wrap: wrap;
}

.auth-bar > span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.auth-logout-button,
.not-found-action,
.login-card button {
    min-height: 44px;
}

.flash-message {
    overflow-wrap: anywhere;
}

/* Shared student header used by tasks, charts and timeline */
.tasks-page .section,
.archived-tasks-page .section,
.chart-page .section,
.timeline-page .section {
    min-width: 0;
    padding: 20px clamp(16px, 3vw, 42px);
    gap: clamp(18px, 3vw, 42px);
}

.tasks-page .section .container,
.archived-tasks-page .section .container,
.chart-page .section .container,
.timeline-page .section .container {
    width: min(100%, 500px);
    min-width: 0;
}

.tasks-page .section h1,
.archived-tasks-page .section h1,
.chart-page .section h1,
.timeline-page .section h1 {
    font-size: clamp(1.65rem, 4vw, 2.5rem);
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.tasks-page .section p,
.archived-tasks-page .section p,
.chart-page .section p,
.timeline-page .section p {
    margin-bottom: 0;
}

.tasks-page .right-header,
.tasks-page .left-header,
.archived-tasks-page .right-header,
.archived-tasks-page .left-header,
.chart-page .right-header,
.timeline-page .right-header,
.timeline-page .prev-next {
    min-width: 0;
}

.tasks-page .section .right-header a,
.tasks-page .section .left-header a,
.archived-tasks-page .section .right-header a,
.archived-tasks-page .section .left-header a,
.chart-page .section .right-header a,
.timeline-page .section .right-header a {
    display: block;
}

.tasks-page .section .panel,
.tasks-page .section .timeline,
.tasks-page .section .chart,
.tasks-page .section .archived_tasks,
.archived-tasks-page .section .panel,
.archived-tasks-page .section .timeline,
.archived-tasks-page .section .chart,
.archived-tasks-page .section .archived_tasks,
.chart-page .section .panel,
.chart-page .section .tasks,
.chart-page .section .timeline1,
.timeline-page .section .panel,
.timeline-page .section .tasks,
.timeline-page .section .chart {
    min-height: 44px;
    align-items: center;
    justify-content: center;
    white-space: normal;
    text-align: center;
}

#date_from {
    min-height: 44px;
}

.page-title {
    margin: 30px 16px 18px;
    text-align: center;
    font-size: clamp(1.2rem, 3vw, 1.65rem);
    line-height: 1.8;
}

/* Tables: keep semantic tables and provide a keyboard/touch scroll container. */
.table-responsive {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
    border-radius: 10px;
    outline: none;
}

.table-responsive:focus-visible {
    box-shadow: 0 0 0 4px rgba(255, 255, 255, .3);
}

.tasks-page .table-responsive,
.archived-tasks-page .table-responsive {
    width: 90%;
    margin: 20px auto 40px;
}

.panel-page .table-responsive {
    width: 80%;
    margin: 20px auto 40px;
}

.table-responsive .tasks-table,
.table-responsive .students-table {
    width: 100%;
    margin: 0;
}

.table-responsive .tasks-table {
    min-width: 860px;
}

.table-responsive .students-table {
    min-width: 760px;
}

.tasks-table th,
.tasks-table td,
.students-table th,
.students-table td {
    overflow-wrap: anywhere;
}

.tasks-table .btn-view,
.students-table .btn-view {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    margin: 4px;
    white-space: nowrap;
    line-height: 1.4;
}

.students-table td:nth-child(4) {
    min-width: 250px;
}

/* Advisor panel */
.panel-page {
    padding: clamp(14px, 4vw, 50px);
}

.panel-page .page-title {
    margin-top: 8px;
}

/* Task create form */
.tasks-page > form {
    width: min(calc(100% - 24px), 700px);
    padding: clamp(18px, 4vw, 30px);
    margin: clamp(28px, 6vw, 50px) auto;
}

.tasks-page > form input,
.tasks-page > form textarea,
.tasks-page > form button {
    min-height: 44px;
}

.tasks-page > form input,
.tasks-page > form textarea {
    font-size: 16px;
}

.tasks-page > form .dates {
    min-width: 0;
}

.tasks-page > form .dates > * {
    min-width: 0;
}

.datepicker-plot-area {
    max-width: calc(100vw - 16px) !important;
}

/* Charts */
.chart-page .card-row {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: clamp(16px, 2.5vw, 28px);
    width: min(95%, 1400px);
}

.chart-page .card-row > [class*="col-"] {
    width: 100%;
    max-width: none;
    flex: none;
    padding: 0;
}

.chart-page .monthly {
    width: min(95%, 1100px);
}

.chart-page .card {
    height: 100%;
    margin-bottom: 0;
}

.chart-page .card-body {
    position: relative;
    min-width: 0;
    min-height: 320px;
    overflow: hidden;
}

.chart-page canvas {
    width: 100% !important;
    max-width: 100%;
}

/* Timeline header controls */
.timeline-page .prev-next {
    display: grid;
    gap: 8px;
}

.timeline-page .prev-next-day,
.timeline-page .prev-next-week,
.timeline-page .prev-next-month {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.timeline-page .prev-next img {
    margin: 0 !important;
}

.timeline-page .day-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
}

.timeline-page .timeline {
    max-width: 100vw;
    touch-action: pan-y;
}

.timeline-page .timeline ol li div {
    max-width: min(280px, calc(100vw - 32px));
    overflow-wrap: anywhere;
}

.timeline-page .timeline .arrows {
    bottom: max(18px, env(safe-area-inset-bottom));
}

/* Login and 404 */
.login-page .login-card,
.not-found-page .not-found-card {
    max-width: 100%;
}

@media (max-width: 1024px) {
    .tasks-page .section,
    .archived-tasks-page .section,
    .chart-page .section,
    .timeline-page .section {
        flex-wrap: wrap;
        justify-content: center;
    }

    .tasks-page .section .right-header,
    .tasks-page .section .left-header,
    .archived-tasks-page .section .right-header,
    .archived-tasks-page .section .left-header,
    .chart-page .section .right-header,
    .timeline-page .section .right-header {
        margin-left: 0;
        margin-right: 0;
    }

    .chart-page .card-body {
        min-height: 290px;
    }
}

@media (max-width: 800px) {
    .auth-bar {
        margin-bottom: 12px;
        border-radius: 0 0 10px 10px;
    }

    .tasks-page .section,
    .archived-tasks-page .section,
    .chart-page .section,
    .timeline-page .section {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        margin-bottom: 30px;
        padding: 22px 14px;
        border-radius: 0 0 18px 18px;
    }

    .tasks-page .section .container,
    .archived-tasks-page .section .container,
    .chart-page .section .container,
    .timeline-page .section .container {
        margin: 0 auto;
    }

    .tasks-page .section .container,
    .archived-tasks-page .section .container {
        order: -3;
    }

    .tasks-page .section .right-header,
    .archived-tasks-page .section .right-header {
        order: -2;
    }

    .tasks-page .section .left-header,
    .archived-tasks-page .section .left-header {
        order: -1;
    }

    .chart-page .section .container {
        order: -2;
    }

    .chart-page .section .right-header {
        order: -1;
    }

    .timeline-page .section .container {
        order: -3;
    }

    .timeline-page .section .right-header {
        order: -2;
    }

    .timeline-page .section .prev-next {
        order: -1;
    }

    .tasks-page .right-header,
    .tasks-page .left-header,
    .archived-tasks-page .right-header,
    .archived-tasks-page .left-header,
    .chart-page .right-header,
    .timeline-page .right-header {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
        gap: 10px;
        width: 100%;
    }

    .tasks-page .left-header,
    .archived-tasks-page .left-header {
        margin-bottom: 0;
    }

    .tasks-page .left-header #date_from,
    .archived-tasks-page .left-header #date_from {
        width: 100%;
    }

    .tasks-page .section .panel,
    .tasks-page .section .timeline,
    .tasks-page .section .chart,
    .tasks-page .section .archived_tasks,
    .archived-tasks-page .section .panel,
    .archived-tasks-page .section .timeline,
    .archived-tasks-page .section .chart,
    .archived-tasks-page .section .archived_tasks,
    .chart-page .section .panel,
    .chart-page .section .tasks,
    .chart-page .section .timeline1,
    .timeline-page .section .panel,
    .timeline-page .section .tasks,
    .timeline-page .section .chart {
        width: 100%;
        margin: 0;
        padding: 10px 12px;
        font-size: 16px;
    }

    .tasks-page .table-responsive,
    .archived-tasks-page .table-responsive,
    .panel-page .table-responsive {
        width: calc(100% - 24px);
    }

    .chart-page .card-row {
        grid-template-columns: minmax(0, 1fr);
        width: calc(100% - 24px);
    }

    .chart-page .monthly {
        width: calc(100% - 24px);
        margin-bottom: 90px;
    }

    .chart-page .card-body {
        min-height: 300px;
        padding: 14px;
    }

    .timeline-page .section .prev-next {
        width: 100%;
        margin: 0;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .timeline-page .prev-next-day,
    .timeline-page .prev-next-week,
    .timeline-page .prev-next-month {
        padding: 6px;
        border-radius: 12px;
        background: rgba(255, 255, 255, .1);
    }

    .timeline-page .timeline ol li {
        width: 135px;
    }

    .timeline-page .timeline ol li:last-child {
        width: 220px;
    }

    .timeline-page .timeline ol li div {
        width: min(250px, calc(100vw - 32px));
        padding: 12px;
        font-size: .92rem;
    }

    .timeline-page .timeline time {
        font-size: 1rem;
    }

    .timeline-page .timeline .arrows {
        gap: 12px;
        padding: 8px 14px;
    }

    .timeline-page .timeline .arrows img {
        width: 38px;
        height: 38px;
    }
}

@media (max-width: 600px) {
    .auth-bar {
        align-items: stretch;
        gap: 10px;
        padding: 10px 12px;
    }

    .auth-bar > span {
        flex: 1 1 100%;
        text-align: center;
    }

    .auth-logout-form,
    .auth-logout-button {
        width: 100% !important;
    }

    .flash-list {
        width: calc(100% - 24px);
    }

    .tasks-page .right-header,
    .tasks-page .left-header,
    .archived-tasks-page .right-header,
    .archived-tasks-page .left-header,
    .chart-page .right-header,
    .timeline-page .right-header {
        grid-template-columns: 1fr;
    }

    .tasks-page > form .dates {
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .tasks-page > form textarea {
        min-height: 120px;
    }

    .table-responsive .tasks-table {
        min-width: 780px;
    }

    .table-responsive .students-table {
        min-width: 700px;
    }

    .chart-page .card-body {
        min-height: 270px;
    }

    .timeline-page .section .prev-next {
        grid-template-columns: 1fr;
    }

    .timeline-page .timeline .arrows {
        width: max-content;
        max-width: calc(100vw - 24px);
    }

    .login-page {
        padding: 14px;
    }

    .login-page .login-card {
        padding: 24px 18px;
        border-radius: 14px;
    }

    .not-found-page {
        padding: 14px;
    }

    .not-found-page .not-found-card {
        padding: 34px 18px;
        border-radius: 20px;
    }
}

@media (max-width: 380px) {
    .tasks-page .section,
    .archived-tasks-page .section,
    .chart-page .section,
    .timeline-page .section {
        padding-left: 10px;
        padding-right: 10px;
    }

    .tasks-page > form {
        width: calc(100% - 16px);
        padding: 16px 12px;
    }

    .page-title {
        margin-left: 10px;
        margin-right: 10px;
    }

    .chart-page .card-row,
    .chart-page .monthly,
    .tasks-page .table-responsive,
    .archived-tasks-page .table-responsive,
    .panel-page .table-responsive {
        width: calc(100% - 16px);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}

@supports (min-height: 100dvh) {
    .login-page,
    .not-found-page {
        min-height: 100dvh;
    }
}


/* --- QA refinements after visual review --- */
.tasks-page .table-responsive,
.archived-tasks-page .table-responsive,
.panel-page .table-responsive {
    direction: rtl;
    box-sizing: border-box;
    padding-inline: 8px;
}

.tasks-page .tasks-table th:first-child,
.archived-tasks-page .tasks-table th:first-child {
    position: sticky;
    right: 0;
    z-index: 3;
}

.tasks-page .tasks-table td:first-child,
.archived-tasks-page .tasks-table td:first-child {
    position: sticky;
    right: 0;
    z-index: 2;
    background: inherit;
    box-shadow: -1px 0 0 rgba(255,255,255,.18);
}

.tasks-page .tasks-table .btn-view,
.archived-tasks-page .tasks-table .btn-view {
    margin: 0;
    padding: 10px 14px;
    white-space: normal;
    min-width: 132px;
}

@media (max-width: 1100px) {
    .tasks-page .section,
    .archived-tasks-page .section,
    .chart-page .section,
    .timeline-page .section {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        justify-items: center;
        align-items: start;
        gap: 18px;
        margin-bottom: 32px;
        padding: 24px 18px;
    }

    .tasks-page .section .container,
    .archived-tasks-page .section .container,
    .chart-page .section .container,
    .timeline-page .section .container {
        width: min(100%, 760px);
        margin: 0 auto;
    }

    .tasks-page .section .right-header,
    .archived-tasks-page .section .right-header,
    .chart-page .section .right-header,
    .timeline-page .section .right-header {
        width: min(100%, 760px);
        margin: 0;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 12px;
    }

    .tasks-page .section .right-header a,
    .archived-tasks-page .section .right-header a,
    .chart-page .section .right-header a,
    .timeline-page .section .right-header a {
        flex: 1 1 160px;
        max-width: 220px;
    }

    .tasks-page .section .left-header,
    .archived-tasks-page .section .left-header {
        width: min(100%, 760px);
        margin: 0;
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
        gap: 12px;
        align-items: center;
    }

    .tasks-page .section .left-header a,
    .archived-tasks-page .section .left-header a {
        display: block;
    }

    .tasks-page .section .left-header #date_from,
    .archived-tasks-page .section .left-header #date_from {
        width: 100%;
    }

    .timeline-page .section .prev-next {
        width: min(100%, 760px);
        margin: 0;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 12px;
    }

    .timeline-page .section .prev-next-day,
    .timeline-page .section .prev-next-week,
    .timeline-page .section .prev-next-month {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        padding: 10px 12px;
        border-radius: 14px;
        background: rgba(255, 255, 255, .10);
    }

    .timeline-page .section .prev-next a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .chart-page .card-row,
    .chart-page .monthly {
        width: calc(100% - 24px);
    }

    .chart-page .card-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .chart-page .card-body {
        min-height: 350px;
        padding: 16px;
    }

    .chart-page #pieChart,
    .chart-page #pointchart,
    .chart-page #barChart {
        height: 290px !important;
    }
}

@media (max-width: 780px) {
    .tasks-page .section .right-header,
    .archived-tasks-page .section .right-header,
    .chart-page .section .right-header,
    .timeline-page .section .right-header {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .tasks-page .section .right-header a,
    .archived-tasks-page .section .right-header a,
    .chart-page .section .right-header a,
    .timeline-page .section .right-header a {
        max-width: none;
    }

    .tasks-page .section .left-header,
    .archived-tasks-page .section .left-header {
        grid-template-columns: minmax(0, 1fr);
        width: 100%;
    }

    .timeline-page .section .prev-next {
        grid-template-columns: minmax(0, 1fr);
        width: 100%;
    }

    .chart-page .card-body {
        min-height: 320px;
    }

    .chart-page #pieChart,
    .chart-page #pointchart,
    .chart-page #barChart {
        height: 260px !important;
    }
}

@media (max-width: 540px) {
    .tasks-page .section,
    .archived-tasks-page .section,
    .chart-page .section,
    .timeline-page .section {
        padding: 18px 12px;
    }

    .tasks-page .section .right-header,
    .archived-tasks-page .section .right-header,
    .chart-page .section .right-header,
    .timeline-page .section .right-header {
        grid-template-columns: minmax(0, 1fr);
    }

    .chart-page .card-body {
        min-height: 290px;
        padding: 12px;
    }

    .chart-page #pieChart,
    .chart-page #pointchart,
    .chart-page #barChart {
        height: 230px !important;
    }
}


@media (max-width: 1100px) {
    .tasks-page .section .container,
    .archived-tasks-page .section .container,
    .chart-page .section .container,
    .timeline-page .section .container {
        order: 1;
    }

    .tasks-page .section .right-header,
    .archived-tasks-page .section .right-header,
    .chart-page .section .right-header,
    .timeline-page .section .right-header {
        order: 2;
    }

    .tasks-page .section .left-header,
    .archived-tasks-page .section .left-header,
    .timeline-page .section .prev-next {
        order: 3;
    }
}


/* --- Chart centering and mobile-friendly table cards --- */
.chart-page .pie-card-body {
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-height: 360px;
    overflow: hidden;
}

.chart-page .pie-chart-shell {
    width: min(100%, 680px);
    margin: 0 auto;
    position: relative;
}

.chart-page .pie-chart-shell #pieChart {
    display: block;
    width: 100% !important;
    height: auto !important;
    max-width: 100%;
    margin: 0 auto;
}

/* Clearer desktop/tablet tables */
.table-responsive {
    background: rgba(255, 255, 255, .06);
    box-shadow: 0 12px 30px rgba(0, 0, 0, .14);
}

.table-responsive table {
    direction: rtl;
}

.table-responsive thead th {
    position: sticky;
    top: 0;
    z-index: 4;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .7);
}

.students-table .student-actions {
    min-width: 280px;
}

.students-table .student-actions form {
    display: inline-block !important;
}

@media (max-width: 1100px) {
    .chart-page .pie-card-body {
        min-height: 330px;
    }

    /* Pie chart must not inherit the fixed canvas heights used by line/bar charts. */
    .chart-page #pieChart {
        height: auto !important;
    }
}

@media (max-width: 1280px) {
    .chart-page .pie-card-body {
        min-height: 300px;
        padding: 14px;
    }

    .chart-page .pie-chart-shell {
        width: min(100%, 520px);
    }

    .tasks-page .table-responsive,
    .archived-tasks-page .table-responsive,
    .panel-page .table-responsive {
        width: calc(100% - 20px);
        padding: 0;
        overflow: visible;
        background: transparent;
        box-shadow: none;
        border-radius: 0;
    }

    .table-responsive .tasks-table,
    .table-responsive .students-table {
        min-width: 0;
        width: 100%;
        border: 0;
        border-collapse: separate;
        border-spacing: 0 14px;
        overflow: visible;
        background: transparent;
        table-layout: auto;
    }

    .table-responsive .tasks-table thead,
    .table-responsive .students-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .table-responsive .tasks-table tbody,
    .table-responsive .students-table tbody,
    .table-responsive .tasks-table tr,
    .table-responsive .students-table tr {
        display: block;
        width: 100%;
    }

    .table-responsive .tasks-table tr,
    .table-responsive .students-table tr {
        margin-bottom: 14px;
        overflow: hidden;
        border: 1px solid rgba(255, 255, 255, .55);
        border-radius: 16px;
        background: rgba(55, 15, 110, .92);
        box-shadow: 0 10px 24px rgba(0, 0, 0, .18);
    }

    .table-responsive .tasks-table tr:nth-child(even),
    .table-responsive .students-table tr:nth-child(even) {
        background: rgba(116, 5, 94, .96);
    }

    .table-responsive .tasks-table tr.task-done {
        background: rgb(0, 160, 70) !important;
    }

    .table-responsive .tasks-table tr.task-overdue {
        background: linear-gradient(145deg, #b71c1c, #8e1616) !important;
        border-color: rgba(255, 255, 255, .7);
    }

    .table-responsive .tasks-table td,
    .table-responsive .students-table td {
        position: static !important;
        display: grid;
        grid-template-columns: minmax(105px, 34%) minmax(0, 1fr);
        align-items: start;
        gap: 12px;
        width: 100%;
        min-width: 0;
        padding: 13px 14px;
        border: 0;
        border-bottom: 1px solid rgba(255, 255, 255, .18);
        background: transparent !important;
        box-shadow: none !important;
        text-align: right;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .table-responsive .tasks-table td:last-child,
    .table-responsive .students-table td:last-child {
        border-bottom: 0;
    }

    .table-responsive .tasks-table td::before,
    .table-responsive .students-table td::before {
        content: attr(data-label);
        display: block;
        font-weight: 700;
        color: rgba(255, 255, 255, .8);
    }

    .table-responsive .tasks-table td[data-label="عملیات"],
    .table-responsive .students-table td[data-label="عملیات"] {
        grid-template-columns: 1fr;
        gap: 10px;
        padding-top: 16px;
        padding-bottom: 16px;
    }

    .table-responsive .tasks-table td[data-label="عملیات"]::before,
    .table-responsive .students-table td[data-label="عملیات"]::before {
        text-align: center;
    }

    .table-responsive .tasks-table td[data-label="عملیات"] form,
    .table-responsive .students-table td[data-label="عملیات"] form {
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
    }

    .table-responsive .tasks-table td[data-label="عملیات"] .btn-view,
    .table-responsive .students-table td[data-label="عملیات"] .btn-view {
        display: flex;
        width: 100%;
        min-height: 44px;
        margin: 0;
        align-items: center;
        justify-content: center;
        border-radius: 10px;
    }

    .table-responsive .students-table td[data-label="عملیات"] {
        display: grid;
        grid-template-columns: 1fr;
    }

    .students-table .student-actions {
        min-width: 0;
    }
}

@media (max-width: 420px) {
    .table-responsive .tasks-table td,
    .table-responsive .students-table td {
        grid-template-columns: minmax(90px, 38%) minmax(0, 1fr);
        padding: 12px;
        font-size: .94rem;
    }

    .chart-page .pie-card-body {
        min-height: 270px;
        padding: 10px;
    }
}


/* --- Final visual refinements: card ordering, floating page headers, centered auth bar --- */
* {
    box-sizing: border-box;
}

.auth-bar,
.flash-list {
    box-sizing: border-box;
}

.panel-page {
    margin: 0;
}

.panel-page .auth-bar,
.panel-page .flash-list {
    width: min(100%, 1200px);
    margin-inline: auto;
}

/* Make the colored student header a floating card, consistent with the auth bar. */
.tasks-page .section,
.archived-tasks-page .section,
.chart-page .section,
.timeline-page .section {
    width: min(calc(100% - 24px), 1200px);
    margin: 16px auto 50px;
    border-radius: 22px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, .20);
    overflow: visible;
}

/* In card mode, labels stay on the right and values stay on the left. */
@media (max-width: 1280px) {
    .table-responsive .tasks-table td,
    .table-responsive .students-table td {
        direction: rtl;
    }

    .table-responsive .tasks-table td::before,
    .table-responsive .students-table td::before {
        grid-column: 1;
        grid-row: 1;
        text-align: right;
    }

    .table-responsive .tasks-table td > .cell-value,
    .table-responsive .students-table td > .cell-value {
        grid-column: 2;
        grid-row: 1;
        min-width: 0;
        text-align: right;
        overflow-wrap: anywhere;
    }

    .table-responsive .tasks-table td.start_time,
    .table-responsive .tasks-table td.deadline,
    .table-responsive .tasks-table td.completed_at {
        direction: rtl !important;
    }

    .table-responsive .tasks-table td.start_time > .cell-value,
    .table-responsive .tasks-table td.deadline > .cell-value,
    .table-responsive .tasks-table td.completed_at > .cell-value {
        direction: ltr;
        unicode-bidi: plaintext;
        text-align: left;
    }

    .tasks-page .section,
    .archived-tasks-page .section,
    .chart-page .section,
    .timeline-page .section {
        width: min(calc(100% - 20px), 1200px);
        margin-top: 10px;
        margin-bottom: 30px;
        border-radius: 18px;
    }
}

@media (max-width: 540px) {
    .tasks-page .section,
    .archived-tasks-page .section,
    .chart-page .section,
    .timeline-page .section {
        width: calc(100% - 12px);
        margin-top: 6px;
        border-radius: 16px;
    }
}


/* Switch data tables to cards before the action column becomes cramped. */
@media (min-width: 1281px) {
    .tasks-page .tasks-table td[data-label="عملیات"],
    .archived-tasks-page .tasks-table td[data-label="عملیات"] {
        min-width: 150px;
    }

    .tasks-page .tasks-table td[data-label="عملیات"] .btn-view,
    .archived-tasks-page .tasks-table td[data-label="عملیات"] .btn-view {
        max-width: 100%;
        min-width: 0;
        padding-inline: 12px;
    }
}

/* Center field values inside responsive cards while keeping labels on the right. */
@media (max-width: 1280px) {
    .table-responsive .tasks-table td > .cell-value,
    .table-responsive .students-table td > .cell-value {
        display: flex;
        align-items: center;
        justify-content: center;
        justify-self: stretch;
        width: 100%;
        min-width: 0;
        text-align: center !important;
    }

    .table-responsive .tasks-table td.start_time > .cell-value,
    .table-responsive .tasks-table td.deadline > .cell-value,
    .table-responsive .tasks-table td.completed_at > .cell-value {
        text-align: center !important;
        justify-content: center;
    }
}
