/* School IT Ticketing — app shell */
:root {
    --app-bg: #f4f6f9;
    --app-surface: #ffffff;
    --app-border: #e2e8f0;
    --app-text: #1e293b;
    --app-text-muted: #64748b;
    --app-primary: #2563eb;
    --app-primary-hover: #1d4ed8;
    --app-nav-bg: #0f172a;
    --app-nav-border: rgba(255, 255, 255, 0.08);
    --app-radius: 12px;
    --app-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.04);
    --app-font: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: var(--app-font);
    background: var(--app-bg);
    color: var(--app-text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

body.app-auth-body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: linear-gradient(160deg, #e8eef9 0%, #f4f6f9 45%, #eef2f7 100%);
}

body.app-auth-body main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.app-auth-card {
    border-radius: var(--app-radius);
}

/* Ticket attachment thumbnails */
.attachment-thumb-link {
    cursor: zoom-in;
    display: inline-block;
    line-height: 0;
    padding: 0;
    margin: 0;
    background: transparent;
    border: none;
}

.attachment-thumb-link:focus-visible {
    outline: 2px solid var(--app-primary);
    outline-offset: 2px;
    border-radius: 10px;
}

.attachment-thumb-img {
    width: 104px;
    height: 104px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--app-border);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.attachment-thumb-link:hover .attachment-thumb-img {
    box-shadow: var(--app-shadow);
    transform: translateY(-1px);
}

#attachmentModal .modal-body img {
    max-height: min(85vh, 900px);
    width: auto;
    max-width: 100%;
}

/* Ticket view — detail hero */
.ticket-detail-hero {
    position: relative;
    overflow: visible;
}

.ticket-detail-hero-accent {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: var(--app-radius) 0 0 var(--app-radius);
    background: linear-gradient(180deg, var(--app-primary) 0%, #6366f1 100%);
    pointer-events: none;
}

.ticket-detail-hero .app-card-body {
    padding-left: 1.35rem;
}

@media (min-width: 768px) {
    .ticket-detail-hero .app-card-body {
        padding-left: 1.65rem;
    }
}

.ticket-meta-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--app-text-muted);
    margin-bottom: 0.2rem;
}

.ticket-description-body {
    line-height: 1.55;
    color: var(--app-text);
}

/* Activity timeline — scan-friendly hierarchy */
.ticket-timeline-intro {
    max-width: 40rem;
    line-height: 1.5;
}

.ticket-timeline {
    --ticket-tl-gap: 1.25rem;
    --ticket-tl-rail: 20px;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0.25rem 0 0.5rem;
}

.ticket-timeline-item {
    display: flex;
    gap: var(--ticket-tl-gap);
    align-items: stretch;
    min-width: 0;
}

.ticket-timeline-axis {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: var(--ticket-tl-rail);
    flex-shrink: 0;
    padding-top: 0.5rem;
}

.ticket-timeline-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #64748b;
    border: 3px solid var(--app-surface);
    box-shadow: 0 0 0 2px #cbd5e1;
    flex-shrink: 0;
    z-index: 1;
}

.ticket-timeline-item--submission .ticket-timeline-dot {
    background: var(--app-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.ticket-timeline-item--photo .ticket-timeline-dot {
    background: #0d9488;
    box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.28);
}

.ticket-timeline-item--note .ticket-timeline-dot {
    background: #64748b;
}

.ticket-timeline-item--legacy .ticket-timeline-dot {
    background: #d97706;
    box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.25);
}

.ticket-timeline-line {
    flex: 1 1 auto;
    width: 3px;
    min-height: 1.5rem;
    margin-top: 4px;
    background: #e2e8f0;
    border-radius: 2px;
}

.ticket-timeline-item:last-child .ticket-timeline-line {
    display: none;
}

.ticket-timeline-panel {
    flex: 1;
    min-width: 0;
    padding-bottom: 1.75rem;
}

.ticket-timeline-item:last-child .ticket-timeline-panel {
    padding-bottom: 0;
}

.ticket-timeline-card {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 12px;
    padding: 1.2rem 1.35rem 1.35rem;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.ticket-timeline-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.65rem 1.25rem;
    margin-bottom: 0.85rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid #f1f5f9;
}

.ticket-timeline-card-type {
    min-width: 0;
}

.ticket-timeline-pill {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 0.35rem 0.65rem;
    border-radius: 7px;
    line-height: 1.2;
}

.ticket-timeline-pill--submission {
    background: rgba(37, 99, 235, 0.14);
    color: #1d4ed8;
}

.ticket-timeline-pill--note {
    background: #f1f5f9;
    color: #475569;
}

.ticket-timeline-pill--photo {
    background: rgba(13, 148, 136, 0.16);
    color: #0f766e;
}

.ticket-timeline-pill--legacy {
    background: rgba(245, 158, 11, 0.18);
    color: #b45309;
}

.ticket-timeline-time {
    font-size: 0.8125rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: #475569;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.ticket-timeline-author-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 0.5rem;
    margin-bottom: 0.75rem;
}

.ticket-timeline-by {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--app-text-muted);
}

.ticket-timeline-author {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    color: var(--app-text);
}

.ticket-timeline-text {
    font-size: 1rem;
    line-height: 1.65;
    color: var(--app-text);
    margin-bottom: 0;
}

.ticket-timeline-text--lead {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: #475569;
}

.ticket-timeline-text--support {
    font-size: 0.875rem;
    line-height: 1.55;
    color: #64748b;
}

.ticket-timeline-media {
    margin-top: 1.1rem;
    padding-top: 1.1rem;
    border-top: 1px solid #e2e8f0;
}

.ticket-timeline-media-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    margin-bottom: 0.65rem;
}

.ticket-timeline-media-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    padding: 0.85rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

.ticket-timeline-media .attachment-thumb-img {
    width: 118px;
    height: 118px;
    border-radius: 10px;
}

.ticket-timeline-thumb-wrap {
    max-width: 8.5rem;
    text-align: center;
}

.ticket-timeline-thumb-wrap .text-truncate {
    font-size: 0.75rem;
}

/* Attachment kind labels — explicit contrast (avoids unreadable subtle badges) */
.ticket-att-kind-badge {
    display: inline-block;
    margin-top: 0.35rem;
    padding: 0.2rem 0.45rem;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.2;
    border-radius: 5px;
    border: 1px solid transparent;
}

.ticket-att-kind-badge--issue {
    color: #1e293b;
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.ticket-att-kind-badge--repair {
    color: #0c4a6e;
    background: #bae6fd;
    border-color: #7dd3fc;
}

.ticket-file-index a {
    text-decoration: none;
}

.ticket-file-index a:hover {
    text-decoration: underline;
}

/* Dashboard — status counts link to filtered ticket list */
a.dashboard-stat-link {
    text-decoration: none;
    line-height: 1.15;
    border-radius: 8px;
    padding: 0.1rem 0.35rem;
    margin: -0.1rem -0.35rem;
    transition: opacity 0.15s ease, box-shadow 0.15s ease;
}

a.dashboard-stat-link:hover {
    text-decoration: underline;
    text-underline-offset: 0.15em;
    opacity: 0.88;
}

a.dashboard-stat-link:focus-visible {
    outline: 2px solid var(--app-primary);
    outline-offset: 3px;
}

/* Reports — classroom volume bars */
.report-classroom-bar {
    height: 6px;
    border-radius: 4px;
    background-color: #e2e8f0;
}

.report-classroom-bar .progress-bar {
    border-radius: 4px;
}

.app-navbar {
    background: var(--app-nav-bg) !important;
    border-bottom: 1px solid var(--app-nav-border);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
}

.app-navbar .navbar-brand {
    font-weight: 600;
    letter-spacing: -0.02em;
    font-size: 1.05rem;
}

.app-navbar .nav-link {
    font-weight: 500;
    padding: 0.5rem 0.85rem !important;
    border-radius: 8px;
    transition: background 0.15s ease, color 0.15s ease;
}

.app-navbar .nav-link:hover,
.app-navbar .nav-link:focus {
    background: rgba(255, 255, 255, 0.08);
    color: #fff !important;
}

.app-main {
    padding-bottom: 2.5rem;
}

.app-page-header {
    margin-bottom: 1.5rem;
}

.app-page-header h1 {
    font-size: clamp(1.35rem, 4vw, 1.65rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    margin: 0 0 0.25rem 0;
    color: var(--app-text);
}

.app-page-header .text-muted {
    color: var(--app-text-muted) !important;
    font-size: 0.9rem;
    max-width: 42rem;
}

.app-card {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
    overflow: hidden;
}

.app-card-body {
    padding: 1.25rem 1.35rem;
}

@media (min-width: 768px) {
    .app-card-body {
        padding: 1.5rem 1.75rem;
    }
}

.app-table-wrap {
    margin: 0 -0.05rem;
}

.app-table-wrap .table {
    margin-bottom: 0;
    font-size: 0.9375rem;
}

.app-table-wrap .table thead th {
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--app-text-muted);
    border-bottom-width: 1px;
    white-space: nowrap;
    background: #f8fafc;
}

.app-table-wrap .table td {
    vertical-align: middle;
}

.app-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.app-actions .btn {
    min-height: 2.25rem;
}

@media (max-width: 575.98px) {
    .app-actions .btn {
        flex: 1 1 auto;
        justify-content: center;
    }
}

.btn-primary {
    background-color: var(--app-primary);
    border-color: var(--app-primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--app-primary-hover);
    border-color: var(--app-primary-hover);
}

.form-label {
    font-weight: 500;
    color: var(--app-text);
}

.form-control,
.form-select {
    border-radius: 10px;
    border-color: var(--app-border);
    padding: 0.55rem 0.85rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.15);
}

/* DataTables + Bootstrap: tighter on small screens */
div.dataTables_wrapper div.dataTables_length select {
    border-radius: 8px;
}

@media (max-width: 767.98px) {
    div.dataTables_wrapper div.dataTables_length,
    div.dataTables_wrapper div.dataTables_filter {
        text-align: left;
        margin-bottom: 0.75rem;
    }

    div.dataTables_wrapper div.dataTables_filter input {
        width: 100% !important;
        margin-left: 0 !important;
        margin-top: 0.35rem;
        border-radius: 10px;
    }

    div.dataTables_wrapper div.dataTables_paginate ul.pagination {
        justify-content: center;
        flex-wrap: wrap;
    }
}

/* Toolbar: stack on narrow screens */
.app-toolbar {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
}

@media (min-width: 576px) {
    .app-toolbar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.app-toolbar .btn {
    width: 100%;
}

@media (min-width: 576px) {
    .app-toolbar .btn {
        width: auto;
    }
}
