/* Campus VMS — mobile layout, no zoom, responsive tables & dashboards */

/* —— Strict viewport: no pinch/double-tap zoom —— */
html {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    touch-action: manipulation;
}

body {
    overflow-x: hidden;
    max-width: 100vw;
    touch-action: manipulation;
}

/* iOS Safari zooms focused inputs smaller than 16px */
@media (max-width: 1024px) {
    input,
    select,
    textarea,
    button {
        font-size: 16px;
    }

    input[type="checkbox"],
    input[type="radio"] {
        font-size: inherit;
    }
}

.safe-area-x {
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
}

.safe-area-bottom {
    padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
}

/* App shell */
.vms-app main {
    width: 100%;
    min-width: 0;
}

.vms-app img,
.vms-app video,
.vms-app canvas,
.vms-app svg {
    max-width: 100%;
    height: auto;
}

.vms-app canvas.vms-chart-canvas {
    display: block;
    width: 100% !important;
    max-height: 220px;
}

/* Page title + actions row */
.vms-toolbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
}

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

.vms-toolbar .vms-toolbar-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

@media (min-width: 640px) {
    .vms-toolbar .vms-toolbar-actions {
        flex-direction: row;
        flex-wrap: wrap;
        width: auto;
        justify-content: flex-end;
    }
}

/* Stack crowded card rows on phones */
@media (max-width: 639px) {
    .vms-stack-sm {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }

    .vms-stack-sm > * {
        width: 100% !important;
        min-width: 0 !important;
    }
}

/* Stat cards on dashboards */
.vms-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

@media (min-width: 640px) {
    .vms-stat-grid {
        gap: 1rem;
    }
}

@media (min-width: 1024px) {
    .vms-stat-grid.vms-stat-grid-6 {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    .vms-stat-grid.vms-stat-grid-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (min-width: 640px) and (max-width: 1023px) {
    .vms-stat-grid.vms-stat-grid-6 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Tables: horizontal scroll on small screens */
.vms-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

main .bg-white.rounded-xl.border.overflow-hidden:not(.vms-no-scroll) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

main table:not(.vms-table-min) {
    min-width: 0;
}

main table.vms-table-min {
    width: 100%;
}

@media (min-width: 768px) {
    main table.vms-table-min {
        min-width: 100%;
    }
}

@media (max-width: 767px) {
    main table.vms-table-min,
    main .vms-table-wrap table {
        min-width: 36rem;
    }
}

/* Fixed / sticky bars */
.vms-fixed-bar {
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
}

/* Wizard / step headers */
.vms-step-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    min-width: 0;
}

.vms-step-header > div:last-child {
    min-width: 0;
    flex: 1;
}

.vms-step-header h2,
.vms-step-header h3 {
    word-break: break-word;
}

/* Chart containers */
.vms-chart-box {
    position: relative;
    width: 100%;
    min-height: 180px;
    overflow: hidden;
}

/* Touch-friendly controls */
.touch-manipulation {
    touch-action: manipulation;
}

@media (max-width: 380px) {
    .mobile-big-input {
        font-size: 1.5rem;
        letter-spacing: 0.12em;
        padding-left: 12px;
        padding-right: 12px;
    }
}

/* Public landing: prevent horizontal bleed */
body.vms-public {
    overflow-x: hidden;
}

body.vms-public .hero-bg {
    overflow: hidden;
}

/* —— Admin lists: contain long names in tables only —— */
.vms-app .vms-main,
.vms-app .vms-content {
    min-width: 0;
}

/* Truncate single-line table cells (department, institute, host) */
.vms-table-wrap .vms-cell-truncate {
    display: block;
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (min-width: 640px) {
    .vms-table-wrap .vms-cell-truncate {
        max-width: 12rem;
    }
}

/* Wrap long names inside table cells when truncation is not used */
.vms-table-wrap .vms-cell-wrap {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.vms-tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.vms-tag {
    display: inline-block;
    max-width: 100%;
    padding: 0.25rem 0.625rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Filter/toolbar rows: drop fixed min-widths on phones */
@media (max-width: 639px) {
    .vms-content {
        padding-left: max(0.75rem, env(safe-area-inset-left, 0px));
        padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
    }

    .vms-content form [class*="min-w-"],
    .vms-content .vms-toolbar-actions a,
    .vms-content .vms-toolbar-actions button {
        min-width: 0 !important;
    }

    .vms-content form .flex-wrap > div,
    .vms-content form .grid > div {
        min-width: 0;
    }

    .vms-content select,
    .vms-content form input[type="search"],
    .vms-content form input[type="text"]:not([type="hidden"]) {
        max-width: 100%;
    }

    .exec-dashboard .exec-hero form {
        width: 100%;
    }

    .exec-dashboard .exec-hero form > div {
        min-width: 0;
        flex: 1 1 100%;
    }
}

/* Tables: horizontal scroll on desktop-sized table views */
.vms-app .vms-table-wrap {
    width: 100%;
    max-width: 100%;
}

/* Mobile: card lists replace wide visitor tables (see vms-visitor-list-cards) */
@media (max-width: 767px) {
    .vms-visitor-list-table {
        display: none !important;
    }

    .vms-visitor-list-cards {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem;
    }
}

@media (min-width: 768px) {
    .vms-visitor-list-cards {
        display: none !important;
    }
}

/* Visitor list cards (mobile) */
.vms-visitor-card {
    display: flex;
    gap: 0.75rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 0.875rem;
    min-width: 0;
}

.vms-visitor-card--pending {
    background: #fffbeb;
    border-color: #fde68a;
}

.vms-visitor-card--circumstance {
    background: #fff7ed;
}

.vms-visitor-card--in {
    background: #f0fdf4;
    border-color: #86efac;
}

.vms-visitor-card--out {
    background: #f8fafc;
    border-color: #cbd5e1;
}

@media (max-width: 767px) {
    .vms-visitor-list-cards-only {
        display: block;
    }
}

@media (min-width: 768px) {
    .vms-visitor-list-cards-only {
        display: none !important;
    }
}

.vms-visitor-card-check {
    padding-top: 0.125rem;
    flex-shrink: 0;
}

.vms-visitor-card-main {
    flex: 1;
    min-width: 0;
}

.vms-visitor-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.vms-visitor-card-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.6875rem;
    font-weight: 700;
    color: #475569;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    padding: 0.15rem 0.4rem;
    border-radius: 0.375rem;
}

.vms-visitor-card-name {
    margin: 0.375rem 0 0;
    font-size: 1rem;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.vms-visitor-card-mobile {
    margin: 0.125rem 0 0;
    font-size: 0.8125rem;
    color: #64748b;
}

.vms-visitor-card-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.875rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: underline;
    white-space: nowrap;
    touch-action: manipulation;
}

.vms-visitor-card-action--primary {
    background: #d97706;
    color: #fff;
    text-decoration: none;
}

.vms-visitor-card-meta {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

.vms-visitor-card-field {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 0.5rem;
    font-size: 0.8125rem;
    line-height: 1.4;
    min-width: 0;
}

.vms-visitor-card-field--gate {
    align-items: flex-start;
}

.vms-visitor-card-label {
    flex: 0 0 5rem;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #94a3b8;
}

.vms-visitor-card-value {
    flex: 1;
    min-width: 0;
    color: #334155;
    overflow-wrap: anywhere;
    word-break: normal;
}

.vms-visitor-card-gate {
    flex: 1;
    min-width: 0;
}

.vms-visitor-card-gate .inline-flex {
    white-space: nowrap;
}

.vms-visitor-card-tag {
    font-size: 0.625rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 9999px;
}

.vms-visitor-card-tag--violet {
    background: #ede9fe;
    color: #6d28d9;
}

.vms-visitor-card-footnote {
    margin: 0.5rem 0 0;
    font-size: 0.6875rem;
    font-weight: 700;
}

.vms-visitor-card-footnote--urgent { color: #be123c; }
.vms-visitor-card-footnote--done { color: #15803d; }
.vms-visitor-card-footnote--campus { color: #1d4ed8; }

.vms-visitor-list-empty {
    padding: 2.5rem 1rem;
    text-align: center;
    color: #64748b;
    font-size: 0.875rem;
}

@media (min-width: 768px) {
    .vms-visitor-list-empty--mobile-only {
        display: none;
    }
}

/* Horizontal tab bars (campus presence, etc.) */
@media (max-width: 639px) {
    .vms-tab-scroll {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    .vms-tab-scroll .tab-btn {
        flex-shrink: 0;
        white-space: nowrap;
    }
}

/* Campus presence: pass-style cards on all screen sizes */
.vms-presence-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
}

@media (min-width: 640px) {
    .vms-presence-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .vms-presence-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1280px) {
    .vms-presence-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.vms-presence-pass-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    overflow: hidden;
    min-width: 0;
}

.vms-presence-pass-top {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    align-items: flex-start;
}

.vms-presence-photo {
    width: 4.25rem;
    height: 5.25rem;
    border-radius: 0.5rem;
    object-fit: cover;
    border: 1px solid #e2e8f0;
    flex-shrink: 0;
    background: #f8fafc;
}

.vms-presence-photo-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
}

.vms-presence-photo-fallback--green {
    background: #dcfce7;
    color: #15803d;
}

.vms-presence-photo-fallback--teal {
    background: #ccfbf1;
    color: #0f766e;
}

.vms-presence-photo-fallback--amber {
    background: #fef3c7;
    color: #b45309;
}

.vms-presence-photo-fallback--cyan {
    background: #cffafe;
    color: #0e7490;
}

.vms-presence-pass-id {
    display: inline-block;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #334155;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    padding: 0.2rem 0.45rem;
    border-radius: 0.375rem;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.vms-presence-pass-id a {
    color: inherit;
    text-decoration: none;
}

.vms-presence-pass-id a:hover {
    color: #4338ca;
}

.vms-presence-in-time {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #15803d;
    line-height: 1.3;
}

.vms-presence-in-time--teal {
    color: #0f766e;
}

.vms-presence-in-time--amber {
    color: #b45309;
}

.vms-presence-in-label {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-right: 0.3rem;
    color: #94a3b8;
}

.vms-presence-duration {
    font-size: 0.6875rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 9999px;
}

.vms-presence-duration--green {
    background: #dcfce7;
    color: #15803d;
}

.vms-presence-duration--red {
    background: #fee2e2;
    color: #b91c1c;
}

.vms-presence-card-body {
    padding: 0.5rem 0.75rem 0.75rem;
    border-top: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.vms-presence-detail {
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.4;
    color: #334155;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.vms-presence-detail .vms-presence-label {
    color: #94a3b8;
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-right: 0.35rem;
}

@media (min-width: 768px) {
    .vms-presence-summary {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Executive dashboard: peak / summary chips */
.exec-dashboard .exec-summary-chip {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}
