:root {
    --pwa-theme: #2563eb;
    --pwa-safe-bottom: env(safe-area-inset-bottom, 0px);
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

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

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive > .table {
    min-width: 680px;
}

.table {
    --bs-table-cell-padding-y: 0.38rem;
    --bs-table-cell-padding-x: 0.5rem;
}

.table th,
.table td {
    vertical-align: middle;
    line-height: 1.25;
}

.table thead th {
    white-space: nowrap;
    font-size: 0.86rem;
}

.table td {
    font-size: 0.88rem;
}

.table .btn-sm {
    --bs-btn-padding-y: 0.16rem;
    --bs-btn-padding-x: 0.4rem;
    --bs-btn-font-size: 0.78rem;
}

.table .badge {
    font-size: 0.72rem;
}

.btn,
.badge,
.nav-link {
    text-wrap: balance;
}

.print-report-header,
.print-report-footer {
    display: none;
}

.mobile-shortcuts {
    display: none;
}

.mobile-shortcut-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.mobile-shortcut-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 4.25rem;
    padding: 0.9rem;
    color: #111827;
    text-decoration: none;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
}

.mobile-shortcut-card i {
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: var(--pwa-theme);
    border-radius: 0.5rem;
}

.mobile-shortcut-card span {
    font-weight: 700;
    line-height: 1.2;
}

.mobile-shortcut-card small {
    display: block;
    color: #6c757d;
    line-height: 1.2;
    margin-top: 0.15rem;
}

.cameraman-bottom-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    display: none;
    grid-template-columns: repeat(auto-fit, minmax(4.25rem, 1fr));
    gap: 0;
    padding: 0.35rem 0.45rem calc(0.35rem + var(--pwa-safe-bottom));
    background: rgba(255, 255, 255, 0.98);
    border-top: 1px solid #dee2e6;
    box-shadow: 0 -0.35rem 1rem rgba(15, 23, 42, 0.08);
}

.cameraman-bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-height: 3.2rem;
    color: #6c757d;
    text-decoration: none;
    font-size: 0.68rem;
    font-weight: 700;
    border-radius: 0.5rem;
}

.cameraman-bottom-nav a.active {
    color: #0d6efd;
    background: rgba(13, 110, 253, 0.1);
}

.cameraman-bottom-nav i {
    font-size: 1rem;
}

.cameraman-top-actions,
.cameraman-page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.55rem;
}

.cameraman-top-actions .btn,
.cameraman-page-actions .btn,
.cameraman-action-form,
.cameraman-action-form .btn {
    min-width: max-content;
}

.cameraman-action-form {
    margin: 0;
}

.live-ops-strip {
    background: linear-gradient(135deg, #102a43 0%, #1d4ed8 100%);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 0.85rem;
    padding: 0.85rem;
    color: #fff;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.18);
}

.live-ops-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.65rem;
}

.live-ops-eyebrow {
    color: rgba(255, 255, 255, 0.76);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.live-ops-header p {
    color: rgba(255, 255, 255, 0.78);
}

.live-ops-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
}

.live-ops-actions .badge,
.live-ops-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 31px;
    padding: 0.36rem 0.58rem;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
}

.live-ops-empty {
    background: rgba(255, 255, 255, 0.94);
    border-radius: 0.75rem;
    color: #1f2937;
    padding: 0.9rem 1rem;
}

.live-recording-list {
    display: grid;
    gap: 0.55rem;
}

.live-recording-row {
    display: grid;
    grid-template-columns: minmax(240px, 1.45fr) repeat(4, minmax(118px, 1fr)) minmax(96px, 0.7fr) minmax(140px, auto);
    align-items: center;
    gap: 0.55rem;
    background: rgba(255, 255, 255, 0.97);
    border-left: 5px solid #ffc107;
    border-radius: 0.68rem;
    color: #111827;
    padding: 0.58rem 0.78rem;
}

.live-recording-row.live-row-success {
    border-left-color: #198754;
}

.live-recording-row.live-row-warning {
    border-left-color: #ffc107;
    background: #fffaf0;
}

.live-recording-row.live-row-danger {
    border-left-color: #dc3545;
    background: #fff5f5;
}

.live-source-badge {
    display: inline-flex;
    width: fit-content;
    background: #e9f2ff;
    color: #0d6efd;
    border-radius: 999px;
    padding: 0.12rem 0.5rem;
    font-size: 0.68rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.live-recording-title .fw-bold,
.live-recording-title .small {
    line-height: 1.15;
}

.live-recording-field span {
    display: block;
    color: #6b7280;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    line-height: 1.1;
    margin-bottom: 0.08rem;
}

.live-recording-field strong {
    display: block;
    color: #111827;
    font-size: 0.86rem;
    font-weight: 700;
    line-height: 1.15;
}

.live-recording-status {
    text-align: right;
    justify-self: end;
    min-width: 132px;
}

.live-recording-status .badge {
    white-space: nowrap;
}

.live-recording-status .small {
    line-height: 1.15;
    margin-top: 0.18rem !important;
}

@media (max-width: 991.98px) {
    .mobile-shortcuts {
        display: block;
    }

    .dashboard-sidebar {
        min-height: auto !important;
        border-right: 0 !important;
        border-bottom: 1px solid #dee2e6;
    }

    .dashboard-sidebar .nav {
        flex-direction: column !important;
        flex-wrap: nowrap !important;
        overflow-x: visible;
        padding-bottom: 0;
    }

    .dashboard-sidebar .nav-link,
    .dashboard-sidebar .sidebar-section-toggle {
        width: 100%;
        white-space: normal;
    }

    .dashboard-sidebar .sidebar-subnav {
        margin-left: 0.85rem;
    }

    .cameraman-portal-body {
        padding-bottom: calc(7.25rem + var(--pwa-safe-bottom));
    }

    .cameraman-bottom-nav {
        display: grid;
    }

    .cameraman-page-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.65rem;
    }

    .cameraman-page-actions .cameraman-action-form {
        width: 100%;
        min-width: 0;
    }

    .cameraman-page-actions .btn {
        width: 100%;
        min-height: 3rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.25rem;
        padding-right: 0.6rem;
        padding-left: 0.6rem;
        line-height: 1.15;
        text-align: center;
        white-space: normal;
    }

    .live-ops-header {
        flex-direction: column;
    }

    .live-ops-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .live-recording-row {
        grid-template-columns: minmax(220px, 1.35fr) repeat(4, minmax(118px, 1fr)) minmax(96px, 0.8fr) minmax(132px, auto);
        overflow-x: auto;
    }

    .fc .fc-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .fc .fc-toolbar-chunk {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.25rem;
    }

    .fc .fc-toolbar-title {
        width: 100%;
        font-size: 1rem !important;
        text-align: center;
    }

    .fc .fc-button {
        padding: 0.35rem 0.5rem;
        font-size: 0.82rem;
    }

    #calendar {
        min-height: 520px !important;
    }
}

@media (max-width: 767.98px) {
    body {
        font-size: 0.94rem;
    }

    .container,
    .container-fluid,
    .container-sm,
    .container-md,
    .container-lg,
    .container-xl,
    .container-xxl {
        padding-right: 0.75rem !important;
        padding-left: 0.75rem !important;
    }

    .navbar .container-fluid {
        gap: 0.65rem;
    }

    .navbar-brand {
        max-width: 72vw;
        white-space: normal;
        line-height: 1.2;
    }

    .navbar .cameraman-top-actions {
        width: 100%;
        margin-left: 0 !important;
        display: flex;
        justify-content: center;
        gap: 0;
    }

    .cameraman-top-actions > .text-muted {
        width: 100%;
        text-align: center;
    }

    .cameraman-top-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .live-ops-strip {
        border-radius: 0.7rem;
        padding: 0.8rem;
    }

    .live-recording-list {
        overflow-x: auto;
        padding-bottom: 0.2rem;
    }

    .live-recording-row {
        min-width: 880px;
        padding: 0.75rem;
    }

    .d-flex.gap-2,
    .d-flex.gap-3 {
        flex-wrap: wrap;
    }

    .btn {
        max-width: 100%;
        white-space: normal;
    }

    form.row > [class*="col-"],
    .row.g-3 > [class*="col-"],
    .row.g-4 > [class*="col-"] {
        min-width: 0;
    }

    input,
    select,
    textarea,
    .form-control,
    .form-select,
    .input-group {
        max-width: 100%;
    }

    .h1,
    h1 {
        font-size: 1.6rem;
    }

    .h3,
    h3 {
        font-size: 1.35rem;
    }

    .mobile-shortcut-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media print {
    nav,
    .navbar,
    .dashboard-sidebar,
    .cameraman-bottom-nav,
    .mobile-shortcuts,
    form,
    .btn,
    button,
    .no-print,
    script {
        display: none !important;
    }

    .print-report-header,
    .print-report-footer {
        display: block !important;
        color: #111 !important;
    }

    .print-report-header {
        margin-bottom: 0.45rem;
        padding-bottom: 0.35rem;
        border-bottom: 1px solid #111;
        text-align: center;
    }

    .print-report-header .institute {
        font-size: 15px;
        font-weight: 800;
        text-transform: uppercase;
    }

    .print-report-header .report-title {
        font-size: 13px;
        font-weight: 700;
    }

    .print-report-header .printed-at,
    .print-report-footer {
        font-size: 10px;
    }

    .print-report-footer {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        padding-top: 0.25rem;
        border-top: 1px solid #111;
        text-align: center;
    }

    body {
        background: #fff !important;
        overflow: visible !important;
    }

    main,
    section,
    .container,
    .container-fluid {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .bg-white,
    .border,
    .rounded-3,
    .card {
        border: 0 !important;
        box-shadow: none !important;
    }

    .table-responsive {
        overflow: visible !important;
    }

    .table-responsive > .table,
    table {
        min-width: 0 !important;
        width: 100% !important;
        font-size: 9.5px;
        border-collapse: collapse !important;
    }

    table th,
    table td {
        padding: 3px 4px !important;
        border: 1px solid #777 !important;
        vertical-align: middle !important;
    }

    table thead th {
        background: #f1f1f1 !important;
        color: #111 !important;
        font-weight: 800 !important;
        text-align: left !important;
    }

    table .badge {
        border: 0 !important;
        color: #111 !important;
        background: transparent !important;
        padding: 0 !important;
        font-weight: 700 !important;
    }
}

@media (max-width: 420px) {
    .mobile-shortcut-grid {
        grid-template-columns: 1fr;
    }

    .cameraman-page-actions,
    .navbar .cameraman-top-actions {
        gap: 0.5rem;
    }

    .cameraman-page-actions .btn {
        font-size: 0.84rem;
    }

    .cameraman-bottom-nav a {
        font-size: 0.66rem;
    }
}

@media print {
    .cameraman-bottom-nav,
    .mobile-shortcuts {
        display: none !important;
    }
}
