/*
=====================================================
CCFT Post-Mortem Photography Camera Add-on v1.8.0
=====================================================
*/

.ccft-pm-camera-open {
    overflow: hidden;
}

.ccft-pm-camera-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;

    display: none;
    place-items: center;

    padding: 18px;

    overflow: auto;

    background: rgba(12, 24, 34, 0.80);
}

.ccft-pm-camera-modal.is-open {
    display: grid;
}

.ccft-pm-camera-shell {
    width: min(1280px, 100%);
    max-height: calc(100vh - 36px);

    overflow: auto;

    border-radius: 18px;

    background: var(--surface, #ffffff);
    color: var(--text, #26343e);

    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.30);
}

.ccft-pm-camera-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;

    gap: 16px;

    padding: 18px 20px;

    border-bottom: 1px solid var(--border, #d8e0e5);
}

.ccft-pm-camera-header h2 {
    margin: 2px 0;
}

.ccft-pm-camera-header p {
    margin: 3px 0 0;

    color: #65717c;
}

.ccft-pm-camera-kicker {
    color: #4a7b8c;

    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ccft-pm-camera-close {
    display: grid;
    place-items: center;

    width: 42px;
    height: 42px;

    padding: 0;

    border: 0;
    border-radius: 50%;

    background: #eef2f5;
    color: #26343e;

    font-size: 28px;
}

.ccft-pm-camera-layout {
    display: grid;
    grid-template-columns:
        minmax(0, 1.35fr)
        minmax(320px, 0.65fr);
}

.ccft-pm-camera-view {
    position: relative;

    display: grid;
    place-items: center;

    min-height: 620px;

    overflow: hidden;

    background: #111820;
}

#ccftPmCameraVideo,
#ccftPmCameraPreview {
    width: 100%;
    height: 100%;

    object-fit: contain;

    background: #111820;
}

.ccft-pm-camera-crosshair {
    position: absolute;
    top: 50%;
    left: 50%;

    width: 120px;
    height: 120px;

    transform: translate(-50%, -50%);

    pointer-events: none;
}

.ccft-pm-camera-crosshair::before {
    content: "";

    position: absolute;
    inset: 0;

    border: 2px solid rgba(255, 255, 255, 0.78);
    border-radius: 50%;
}

.ccft-pm-camera-crosshair span:first-child,
.ccft-pm-camera-crosshair span:last-child {
    position: absolute;

    background: rgba(255, 255, 255, 0.88);
}

.ccft-pm-camera-crosshair span:first-child {
    top: 50%;
    left: 8%;

    width: 84%;
    height: 2px;
}

.ccft-pm-camera-crosshair span:last-child {
    top: 8%;
    left: 50%;

    width: 2px;
    height: 84%;
}

.ccft-pm-camera-angle {
    position: absolute;
    left: 14px;
    bottom: 14px;

    padding: 8px 11px;

    border-radius: 999px;

    background: rgba(20, 32, 42, 0.85);
    color: #ffffff;

    font-size: 12px;
    font-weight: 900;
}

.ccft-pm-camera-angle.is-good {
    background: rgba(31, 126, 84, 0.94);
}

.ccft-pm-camera-angle.is-warning {
    background: rgba(184, 118, 0, 0.94);
}

.ccft-pm-camera-angle.is-bad {
    background: rgba(174, 30, 50, 0.94);
}

.ccft-pm-camera-panel {
    display: flex;
    flex-direction: column;

    gap: 14px;

    padding: 18px;
}

.ccft-pm-position-card {
    display: grid;
    grid-template-columns: 90px 1fr;

    gap: 12px;
    align-items: center;

    padding: 12px;

    border: 1px solid var(--border, #d8e0e5);
    border-radius: 12px;
}

.ccft-pm-position-card p {
    margin: 4px 0 0;

    color: #65717c;

    font-size: 12px;
}

.ccft-pm-level {
    position: relative;

    width: 84px;
    height: 34px;

    border: 2px solid #9fb0bb;
    border-radius: 999px;

    background:
        linear-gradient(
            90deg,
            transparent 49%,
            #7390a2 49%,
            #7390a2 51%,
            transparent 51%
        );
}

#ccftPmLevelDot {
    position: absolute;
    top: 50%;
    left: 50%;

    width: 18px;
    height: 18px;

    border-radius: 50%;

    background: #78c6ae;

    transform: translate(-50%, -50%);
}

.ccft-pm-camera-buttons {
    display: flex;
    flex-wrap: wrap;

    gap: 8px;
}

.ccft-pm-qc-panel {
    display: grid;

    gap: 12px;
}

.ccft-pm-qc-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;

    gap: 12px;
}

.ccft-pm-qc-heading h3 {
    margin: 2px 0;
}

.ccft-pm-qc-score {
    min-width: 90px;

    padding: 10px;

    border-radius: 10px;

    background: #eef2f5;
    color: #34434f;

    text-align: center;

    font-size: 16px;
    font-weight: 900;
}

.ccft-pm-qc-score.is-pass {
    background: rgba(49, 150, 101, 0.12);
    color: #246d4a;
}

.ccft-pm-qc-score.is-check {
    background: rgba(197, 31, 58, 0.09);
    color: #9f1b31;
}

.ccft-pm-qc-results {
    display: grid;

    gap: 7px;
}

.ccft-pm-qc-item {
    display: grid;
    grid-template-columns: 28px 1fr auto;

    gap: 8px;
    align-items: center;

    padding: 9px 10px;

    border: 1px solid var(--border, #d8e0e5);
    border-radius: 9px;
}

.ccft-pm-qc-item > span {
    display: grid;
    place-items: center;

    width: 25px;
    height: 25px;

    border-radius: 50%;

    background: #eef2f5;

    font-weight: 900;
}

.ccft-pm-qc-item strong {
    display: block;

    font-size: 12px;
}

.ccft-pm-qc-item small {
    display: block;

    margin-top: 2px;

    color: #65717c;

    font-size: 10px;
}

.ccft-pm-qc-item em {
    color: #65717c;

    font-size: 9px;
    font-style: normal;
    font-weight: 900;
    text-transform: uppercase;
}

.ccft-pm-qc-item.is-pass {
    border-left: 4px solid #319665;
}

.ccft-pm-qc-item.is-pass > span {
    background: rgba(49, 150, 101, 0.12);
    color: #246d4a;
}

.ccft-pm-qc-item.is-fail {
    border-left: 4px solid #c51f3a;
}

.ccft-pm-qc-item.is-fail > span {
    background: rgba(197, 31, 58, 0.10);
    color: #a71830;
}

.ccft-pm-manual-qc {
    display: grid;

    gap: 8px;

    padding: 10px;

    border-radius: 10px;

    background: #f7fafb;
}

.ccft-pm-manual-qc label {
    display: flex;
    align-items: center;

    gap: 8px;

    font-size: 12px;
    font-weight: 800;
}

.ccft-pm-manual-qc label.is-required {
    color: #a71830;
}

.ccft-pm-manual-qc input {
    width: 18px;
    height: 18px;

    margin: 0;
}

.ccft-pm-qc-note {
    padding: 9px 10px;

    border-left: 4px solid #4a7b8c;

    background: rgba(74, 123, 140, 0.07);

    color: #53626d;

    font-size: 11px;
}


/* Added camera action on existing v1.7 checklist tiles */

.ccft-pm-camera-action {
    display: flex;
    justify-content: flex-start;

    margin-top: 4px;
}

.ccft-pm-camera-action button {
    padding: 6px 9px;

    border: 1px solid #9fb5c2;
    border-radius: 7px;

    background: #f4f8fb;
    color: #17345e;

    font-size: 10px;
    font-weight: 900;
}

.ccft-pm-linked-photo {
    display: grid;
    grid-template-columns: 54px 1fr;

    gap: 7px;
    align-items: center;

    margin-top: 6px;
    padding-top: 6px;

    border-top: 1px solid #e2e7ea;
}

.ccft-pm-linked-photo:empty {
    display: none;
}

.ccft-pm-linked-photo img {
    width: 54px;
    height: 42px;

    border-radius: 5px;

    object-fit: cover;
}

.ccft-pm-linked-photo span {
    color: #246d4a;

    font-size: 9px;
    font-weight: 900;
}


@media (max-width: 900px) {

    .ccft-pm-camera-layout {
        grid-template-columns: 1fr;
    }

    .ccft-pm-camera-view {
        min-height: 52vh;
    }

}


@media (max-width: 560px) {

    .ccft-pm-camera-modal {
        padding: 0;
    }

    .ccft-pm-camera-shell {
        max-height: 100vh;

        border-radius: 0;
    }

    .ccft-pm-camera-view {
        min-height: 48vh;
    }

    .ccft-pm-position-card {
        grid-template-columns: 76px 1fr;
    }

}


/* =====================================================
   v1.9 — Phone ↔ desktop link
===================================================== */

.ccft-pm-phone-link-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;

    margin: 10px 0 16px;
    padding: 12px 14px;

    border: 1px solid #cfd9df;
    border-radius: 12px;

    background: #f7fafb;
}

.ccft-pm-phone-link-bar strong {
    margin-right: auto;
}

.ccft-pm-phone-status {
    padding: 6px 9px;
    border-radius: 999px;
    background: #eef2f5;
    font-size: 10px;
    font-weight: 900;
}

.ccft-pm-phone-status.is-connected {
    background: rgba(49,150,101,.12);
    color: #246d4a;
}

.ccft-pm-phone-dialog {
    position: fixed;
    inset: 0;
    z-index: 10020;
    display: none;
    place-items: center;
    padding: 18px;
    background: rgba(12,24,34,.78);
}

.ccft-pm-phone-dialog.is-open {
    display: grid;
}

.ccft-pm-phone-card {
    width: min(650px, 100%);
    padding: 22px;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 24px 80px rgba(0,0,0,.3);
}

.ccft-pm-phone-card h2 {
    margin: 0 0 8px;
}

.ccft-pm-phone-card code {
    display: block;
    margin: 12px 0;
    padding: 12px;
    border-radius: 9px;
    background: #f1f5f7;
    white-space: normal;
    overflow-wrap: anywhere;
    font-size: 12px;
}

.ccft-pm-phone-code {
    font-size: 30px;
    font-weight: 900;
    letter-spacing: .08em;
    color: #17345e;
}

.ccft-pm-phone-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}


/* =====================================================
   v1.9.1 — Directly rendered smartphone link panel
===================================================== */

#pmPhotoContent > .ccft-pm-phone-link-bar,
#postmortem-photography .ccft-pm-phone-link-bar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px 18px;
    align-items: center;

    margin: 14px 0;
    padding: 16px 18px;

    border: 2px solid #8fb0c2;
    border-radius: 14px;

    background:
        linear-gradient(
            135deg,
            #f4f9fc,
            #ffffff
        );
}

#pmPhotoContent > .ccft-pm-phone-link-bar > div,
#postmortem-photography .ccft-pm-phone-link-bar > div {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

#pmPhotoContent > .ccft-pm-phone-link-bar strong,
#postmortem-photography .ccft-pm-phone-link-bar strong {
    color: #17345e;
    font-size: 18px;
}

#pmPhotoContent > .ccft-pm-phone-link-bar p,
#postmortem-photography .ccft-pm-phone-link-bar p {
    grid-column: 1 / 2;

    margin: 0;

    color: #65717c;
    font-size: 12px;
    line-height: 1.4;
}

#pmPhotoContent > .ccft-pm-phone-link-bar button,
#postmortem-photography .ccft-pm-phone-link-bar button {
    grid-column: 2;
    grid-row: 1 / 3;

    min-width: 150px;
    min-height: 46px;
}

@media (max-width: 700px) {

    #pmPhotoContent > .ccft-pm-phone-link-bar,
    #postmortem-photography .ccft-pm-phone-link-bar {
        grid-template-columns: 1fr;
    }

    #pmPhotoContent > .ccft-pm-phone-link-bar p,
    #postmortem-photography .ccft-pm-phone-link-bar p,
    #pmPhotoContent > .ccft-pm-phone-link-bar button,
    #postmortem-photography .ccft-pm-phone-link-bar button {
        grid-column: 1;
        grid-row: auto;
    }
}


/* =====================================================
   v1.9.2 — Guaranteed visible Smartphone Photography panel
===================================================== */

.ccft-pm-phone-link-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;

    gap: 22px;

    margin: 14px 0;
    padding: 18px 20px;

    border: 2px solid #8fb0c2;
    border-left: 7px solid #0f3567;
    border-radius: 14px;

    background:
        linear-gradient(
            135deg,
            #f3f8fc,
            #ffffff
        );
}

.ccft-pm-phone-link-panel-copy {
    display: flex;
    align-items: center;

    gap: 14px;

    min-width: 0;
}

.ccft-pm-phone-link-icon {
    display: grid;
    place-items: center;

    flex: 0 0 auto;

    width: 58px;
    height: 58px;

    border-radius: 13px;

    background: rgba(15,53,103,.10);

    font-size: 34px;
}

.ccft-pm-phone-link-panel h2 {
    margin: 0 0 4px;

    color: #17345e;

    font-size: 20px;
}

.ccft-pm-phone-link-panel p {
    max-width: 720px;

    margin: 0;

    color: #65717c;

    font-size: 12px;
    line-height: 1.4;
}

.ccft-pm-phone-link-panel-actions {
    display: flex;
    align-items: center;

    gap: 10px;

    flex: 0 0 auto;
}

.ccft-pm-phone-link-panel
    .ccft-pm-phone-status {
    padding: 7px 10px;

    border-radius: 999px;

    background: #eef2f5;
    color: #65717c;

    font-size: 10px;
    font-weight: 900;
}

.ccft-pm-phone-link-panel
    .ccft-pm-phone-status.is-connected {
    background: rgba(49,150,101,.12);
    color: #246d4a;
}

.ccft-pm-phone-link-panel
    .primary-button {
    min-width: 130px;
    min-height: 44px;
}

@media (max-width: 760px) {

    .ccft-pm-phone-link-panel {
        display: grid;
    }

    .ccft-pm-phone-link-panel-actions {
        justify-content: space-between;
    }

}


/* =====================================================
   v1.10 — QR smartphone linking
===================================================== */

.ccft-pm-qr-layout {
    display: grid;
    grid-template-columns: minmax(220px, 300px) 1fr;
    gap: 22px;
    align-items: center;
    margin: 18px 0;
}

.ccft-pm-qr-box {
    display: grid;
    place-items: center;
    padding: 14px;
    border: 1px solid #d7e0e5;
    border-radius: 14px;
    background: #fff;
}

#ccftPmPhoneQR {
    display: block;
    width: min(100%, 300px);
    height: auto;
    image-rendering: pixelated;
}

.ccft-pm-qr-step {
    display: grid;
    grid-template-columns: 30px 1fr;
    gap: 9px;
    align-items: center;
    margin: 9px 0;
    font-size: 13px;
    font-weight: 750;
}

.ccft-pm-qr-step > span {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #17345e;
    color: #fff;
    font-weight: 900;
}

.ccft-pm-phone-manual-link {
    margin-top: 10px;
}

.ccft-pm-phone-manual-link summary {
    cursor: pointer;
    color: #4a6575;
    font-size: 12px;
    font-weight: 800;
}

@media (max-width: 650px) {
    .ccft-pm-qr-layout {
        grid-template-columns: 1fr;
    }

    .ccft-pm-qr-box {
        max-width: 330px;
        margin: 0 auto;
    }
}


/* =====================================================
   v1.10.1 — QR display fix using existing QRCode library
===================================================== */

#ccftPmPhoneQR {
    display: grid;
    place-items: center;

    width: 280px;
    min-height: 280px;

    margin: 0 auto;
}

#ccftPmPhoneQR img,
#ccftPmPhoneQR canvas {
    display: block !important;

    width: 280px !important;
    height: 280px !important;

    max-width: 100%;
}

@media (max-width: 420px) {

    #ccftPmPhoneQR {
        width: 240px;
        min-height: 240px;
    }

    #ccftPmPhoneQR img,
    #ccftPmPhoneQR canvas {
        width: 240px !important;
        height: 240px !important;
    }

}


/* =====================================================
   v1.11 — LAN-aware QR phone link
===================================================== */

.ccft-pm-lan-address {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 5px;

    margin: 8px 0 2px;
    padding: 7px 10px;

    border-radius: 8px;

    background: rgba(15,53,103,.07);
    color: #50616d;

    font-size: 11px;
}

.ccft-pm-lan-address strong {
    color: #17345e;
}


/* =====================================================
   v1.13 — Automatic network discovery
===================================================== */

.ccft-pm-network-row {
    display: grid;
    grid-template-columns:
        auto
        minmax(0, 1fr)
        auto;

    gap: 8px;
    align-items: center;

    margin: 12px 0;
    padding: 10px;

    border: 1px solid #d5e0e6;
    border-radius: 10px;

    background: #f7fafb;
}

.ccft-pm-network-row label {
    color: #536672;
    font-size: 11px;
    font-weight: 900;
}

.ccft-pm-network-row select {
    min-width: 0;
    width: 100%;
    padding: 8px 9px;
    border: 1px solid #bfcdd5;
    border-radius: 7px;
    background: #ffffff;
    color: #26343e;
}

.ccft-pm-network-message {
    margin: -4px 0 10px;
    color: #65717c;
    font-size: 10px;
    line-height: 1.4;
}

@media (max-width: 650px) {
    .ccft-pm-network-row {
        grid-template-columns: 1fr;
    }
}
