/* === Appointment Header (patient info) === */
.appointment-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}

.appointment-header__avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4fc3f7, #0288d1);
    color: #fff;
    font-size: 17px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-transform: uppercase;
}

.appointment-header__info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.appointment-header__name {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.appointment-header__date {
    font-size: 13px;
    color: #4fc3f7;
    font-weight: 500;
}

/* === Patient Form (fallback manual input) === */
.patient-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.patient-form__field {
    flex: 1 1 140px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.patient-form__input {
    padding: 8px 10px;
    border: 1px solid #333;
    border-radius: 8px;
    background: #2a2a2a;
    color: #fff;
    font-size: 15px;
    outline: none;
    transition: border-color .2s;
}

.patient-form__input:focus {
    border-color: #4fc3f7;
}

/* === Autocomplete === */
.patient-form__field--autocomplete {
    position: relative;
}

.autocomplete-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 200;
    list-style: none;
    background: #2a2a2a;
    border: 1px solid #444;
    border-top: none;
    border-radius: 0 0 10px 10px;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 6px 16px rgba(0,0,0,.5);
}

.autocomplete-list--open {
    display: block;
}

.autocomplete-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    font-size: 15px;
    color: #e0e0e0;
    transition: background .12s;
}

.autocomplete-item:hover,
.autocomplete-item--active {
    background: #333;
}

.autocomplete-item__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: #4fc3f7;
    text-transform: uppercase;
    flex-shrink: 0;
}

.autocomplete-item--create {
    color: #4fc3f7;
    font-weight: 500;
    border-top: 1px solid #333;
}

.autocomplete-item--create .autocomplete-item__avatar {
    background: rgba(79, 195, 247, .15);
}

/* === Section Headers === */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}

.section-header__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: #e0e0e0;
}

.section-header__count {
    font-size: 13px;
    font-weight: 600;
    color: #4fc3f7;
    background: rgba(79, 195, 247, .15);
    padding: 2px 10px;
    border-radius: 12px;
}

/* === Unified Photos Grid === */
.photos-section {
    width: 100%;
    max-width: 640px;
}

.photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
}

.photos-grid__item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #1e1e1e;
    border: 1px solid #2a2a2a;
    transition: border-color .2s;
}

.photos-grid__item:hover {
    border-color: #4fc3f7;
}

.photos-grid__item--new {
    border-color: #43a047;
}

.photos-grid__item--new:hover {
    border-color: #66bb6a;
}

.photos-grid__img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    cursor: pointer;
    display: block;
}

.photos-grid__name {
    font-size: 10px;
    color: #9e9e9e;
    padding: 4px 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}



/* Upload status indicator on new photos */
.photos-grid__status {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    transition: opacity .3s;
}

.photos-grid__status--uploading,
.photos-grid__status--done,
.photos-grid__status--error {
    opacity: 1;
}

.photos-grid__status--uploading {
    background: rgba(0, 0, 0, .55);
}

.photos-grid__status--done {
    background: rgba(67, 160, 71, .85);
    color: #fff;
}

.photos-grid__status--error {
    background: rgba(239, 83, 80, .9);
    color: #fff;
    pointer-events: auto;
    cursor: pointer;
    animation: pulse-error 1.5s ease infinite;
}

@keyframes pulse-error {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.15); }
}

/* Mini spinner inside status indicator */
.mini-spinner {
    display: block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

/* Delete button on new photos */
.photos-grid__delete {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, .6);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .2s;
}

.photos-grid__item:hover .photos-grid__delete {
    opacity: 1;
}

@media (hover: none) {
    .photos-grid__delete {
        opacity: 1;
    }
}

/* Camera last-photo mini preview (shown in overlay) */
.camera__last-preview {
    position: absolute;
    bottom: 16px;
    left: 16px;
    width: 56px;
    height: 56px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s, transform .15s;
}

.camera__last-preview--visible {
    opacity: 1;
    pointer-events: auto;
    cursor: pointer;
}

.camera__last-preview--visible:active {
    transform: scale(.92);
}

.camera__last-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Expand hint on the preview */
.camera__last-preview::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 50%, rgba(0,0,0,.35) 100%);
    pointer-events: none;
}

.camera__last-preview__icon {
    position: absolute;
    bottom: 3px;
    right: 3px;
    width: 16px;
    height: 16px;
    color: #fff;
    z-index: 2;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,.5));
    pointer-events: none;
}

/* === Loading State === */
.state-msg {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 32px 16px;
    color: #9e9e9e;
    text-align: center;
    width: 100%;
    max-width: 640px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #333;
    border-top-color: #4fc3f7;
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === Main Area === */
.main {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    padding-bottom: 100px;   /* room for FAB */
    gap: 16px;
}

/* === FAB (Floating Action Button) === */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 200;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: #4fc3f7;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,.45);
    cursor: pointer;
    transition: transform .15s, background .2s, box-shadow .2s;
    -webkit-user-select: none;
    user-select: none;
}

.fab:hover {
    background: #39b0e6;
    box-shadow: 0 6px 20px rgba(0,0,0,.55);
}

.fab:active {
    transform: scale(.9);
}

/* Hide FAB when camera is open */
body.camera-open .fab {
    display: none;
}

/* === Camera Mode Chooser (mobile bottom-sheet) === */
.camera-mode-overlay {
    position: fixed;
    inset: 0;
    z-index: 800;
    background: rgba(0, 0, 0, .55);
    display: none;
    align-items: flex-end;
    justify-content: center;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.camera-mode-overlay--open {
    display: flex;
}

.camera-mode-sheet {
    width: 100%;
    max-width: 420px;
    background: #1e1e1e;
    border-radius: 20px 20px 0 0;
    padding: 0 0 env(safe-area-inset-bottom, 16px);
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.22, .61, .36, 1);
    box-shadow: 0 -4px 32px rgba(0, 0, 0, .6);
}

.camera-mode-overlay--open .camera-mode-sheet {
    transform: translateY(0);
}

.camera-mode-sheet__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 10px;
}

.camera-mode-sheet__title {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.camera-mode-sheet__close {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, .1);
    color: #aaa;
    font-size: 22px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}

.camera-mode-sheet__close:hover {
    background: rgba(255, 255, 255, .2);
}

.camera-mode-sheet__options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 14px 18px;
}

.camera-mode-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid #333;
    border-radius: 14px;
    background: #262626;
    color: #fff;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .1s;
    -webkit-user-select: none;
    user-select: none;
    text-align: left;
}

.camera-mode-option:hover {
    background: #2e2e2e;
    border-color: #4fc3f7;
}

.camera-mode-option:active {
    transform: scale(.97);
    background: #333;
}

.camera-mode-option__icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(79, 195, 247, .12);
    color: #4fc3f7;
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-mode-option__text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.camera-mode-option__name {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
}

.camera-mode-option__desc {
    font-size: 12px;
    color: #888;
    line-height: 1.3;
}

/* === Body scroll lock when camera overlay is open === */
body.camera-open {
    overflow: hidden;
}

/* === Camera Fullscreen Overlay === */
.camera-overlay {
    position: fixed;
    inset: 0;
    z-index: 900;
    background: #000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.camera-overlay--open {
    display: flex;
}

/* Close button inside overlay */
.camera-overlay__close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, .15);
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}

.camera-overlay__close:hover,
.camera-overlay__close:active {
    background: rgba(255, 255, 255, .3);
}

.camera {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 640px;
    gap: 10px;
    padding: 8px;
    height: 100%;
    justify-content: center;
}

.camera__viewport {
    position: relative;
    width: 100%;
    max-height: 65vh;
    aspect-ratio: 4 / 3;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    touch-action: none;          /* prevent browser gestures */
    transition: aspect-ratio .3s ease;
}

/* Aspect-ratio modifiers */
.camera__viewport--4-3  { aspect-ratio: 4 / 3; }
.camera__viewport--1-1  { aspect-ratio: 1 / 1; }
.camera__viewport--16-9 { aspect-ratio: 16 / 9; }

.camera__video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform-origin: center center;
    transition: transform .05s linear, filter .25s ease;
}

/* B&W filter */
.camera__video--bw {
    filter: grayscale(100%);
}

/* === Grid Overlay (rule of thirds) === */
.camera__grid {
    position: absolute;
    inset: 0;
    display: none;
    pointer-events: none;
    z-index: 2;
}

.camera__grid--visible {
    display: block;
}

.camera__grid .grid-h {
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(255, 255, 255, .35);
}

.camera__grid .grid-h:nth-child(1) { top: 33.33%; }
.camera__grid .grid-h:nth-child(2) { top: 66.66%; }

.camera__grid .grid-v {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(255, 255, 255, .35);
}

.camera__grid .grid-v:nth-child(3) { left: 33.33%; }
.camera__grid .grid-v:nth-child(4) { left: 66.66%; }

/* === Horizon Level Indicator === */
.camera__horizon {
    position: absolute;
    left: 5%;
    right: 5%;
    top: 50%;
    height: 2px;
    background: #f44336;          /* red — far from level */
    transform: translateY(-50%) rotate(0deg);
    transform-origin: center center;
    pointer-events: none;
    z-index: 3;
    display: none;
    opacity: .85;
    transition: background .2s;
    border-radius: 1px;
    box-shadow: 0 0 4px rgba(0,0,0,.4);
}

.camera__horizon--visible {
    display: block;
}

.camera__horizon--warn {
    background: #ffea00;          /* yellow — slightly off */
}

.camera__horizon--level {
    background: #00e676;          /* green — level */
}

/* === Camera Toolbar === */
.camera__toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 4px 0;
    flex-wrap: wrap;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #444;
    border-radius: 8px;
    background: rgba(255, 255, 255, .08);
    color: #ccc;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
    -webkit-user-select: none;
    user-select: none;
}

.toolbar-btn:hover {
    background: rgba(255, 255, 255, .15);
}

.toolbar-btn--active {
    background: rgba(79, 195, 247, .25);
    border-color: #4fc3f7;
    color: #4fc3f7;
}

.toolbar-btn--disabled,
.toolbar-btn:disabled {
    opacity: .35;
    cursor: not-allowed;
    pointer-events: none;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: #444;
    margin: 0 4px;
}

/* Zoom indicator */
.camera__zoom-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    font-size: 13px;
    padding: 3px 10px;
    border-radius: 20px;
    pointer-events: none;
    opacity: 0;
    transition: opacity .3s;
}

.camera__zoom-badge--visible {
    opacity: 1;
}

/* === Capture Controls === */
.camera__controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 8px 0;
}

.capture-btn {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    border: 4px solid #fff;
    background: transparent;
    cursor: pointer;
    position: relative;
    transition: transform .15s;
}

.capture-btn::after {
    content: '';
    position: absolute;
    inset: 5px;
    border-radius: 50%;
    background: #fff;
    transition: background .15s;
}

.capture-btn:active {
    transform: scale(.9);
}

.capture-btn:active::after {
    background: #bbb;
}

/* === Hidden Canvas === */
.camera__canvas {
    display: none;
}



/* === Lightbox (full-screen preview with pinch-to-zoom) === */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 950;
    background: rgba(0, 0, 0, .95);
    align-items: center;
    justify-content: center;
    -webkit-user-select: none;
    user-select: none;
}

.lightbox--open {
    display: flex;
}

.lightbox__container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    touch-action: none;   /* we handle all gestures ourselves */
}

.lightbox__img {
    max-width: 95vw;
    max-height: 90vh;
    border-radius: 8px;
    transform-origin: 0 0;
    will-change: transform;
    transition: none;
    pointer-events: none;       /* touches go to container */
}

.lightbox__close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, .15);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Navigation arrows */
.lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, opacity .2s;
    opacity: .7;
}

.lightbox__nav:hover {
    background: rgba(255, 255, 255, .25);
    opacity: 1;
}

.lightbox__nav--prev { left: 12px; }
.lightbox__nav--next { right: 12px; }

.lightbox__nav[disabled] {
    opacity: 0;
    pointer-events: none;
}

/* Photo counter */
.lightbox__counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    color: rgba(255, 255, 255, .7);
    font-size: 14px;
    font-weight: 500;
    background: rgba(0, 0, 0, .45);
    padding: 4px 14px;
    border-radius: 16px;
}

/* Hint for double-tap */
.lightbox__hint {
    position: absolute;
    bottom: 56px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    color: rgba(255, 255, 255, .5);
    font-size: 12px;
    pointer-events: none;
    transition: opacity .4s;
}

@media (hover: none) {
    .lightbox__nav {
        width: 40px;
        height: 40px;
    }
    .lightbox__nav--prev { left: 8px; }
    .lightbox__nav--next { right: 8px; }
}

/* === Flash Effect === */
.flash {
    position: fixed;
    inset: 0;
    background: #fff;
    z-index: 400;
    pointer-events: none;
    animation: flash-anim .15s ease-out forwards;
}

@keyframes flash-anim {
    from { opacity: .8; }
    to   { opacity: 0; }
}

/* === Upload Toast === */
.upload-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(120px);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 12px;
    background: #1e1e1e;
    border: 1px solid #333;
    color: #e0e0e0;
    font-size: 14px;
    z-index: 600;
    transition: transform .35s ease;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0,0,0,.5);
}

.upload-toast--visible {
    transform: translateX(-50%) translateY(0);
}

.upload-toast--success {
    border-color: #43a047;
    background: #1b2e1b;
}

.upload-toast--error {
    border-color: #ef5350;
    background: #2e1b1b;
}

.upload-toast__icon {
    font-size: 18px;
}

.upload-toast__text {
    white-space: nowrap;
}

/* === Responsive === */
@media (max-width: 480px) {
    .patient-form__input {
        font-size: 14px;
        padding: 7px 8px;
    }

    .camera__viewport {
        border-radius: 8px;
    }

    .capture-btn {
        width: 60px;
        height: 60px;
    }

    .fab {
        bottom: 18px;
        right: 18px;
        width: 56px;
        height: 56px;
    }

    .camera-overlay__close {
        top: 8px;
        right: 8px;
    }
}

/* === Delete Confirmation Dialog === */
.delete-dialog {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, .7);
    align-items: center;
    justify-content: center;
    padding: 16px;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.delete-dialog--open {
    display: flex;
}

.delete-dialog__card {
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 16px;
    padding: 20px;
    max-width: 320px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .6);
    animation: dialog-in .2s ease-out;
}

@keyframes dialog-in {
    from { opacity: 0; transform: scale(.9) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.delete-dialog__preview {
    width: 140px;
    height: 105px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid #333;
}

.delete-dialog__title {
    font-size: 17px;
    font-weight: 600;
    color: #fff;
    margin: 0;
}

.delete-dialog__text {
    font-size: 13px;
    color: #9e9e9e;
    text-align: center;
    margin: 0;
    line-height: 1.4;
}

.delete-dialog__actions {
    display: flex;
    gap: 10px;
    width: 100%;
    margin-top: 4px;
}

.delete-dialog__btn {
    flex: 1;
    padding: 10px 0;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, transform .1s;
}

.delete-dialog__btn:active {
    transform: scale(.96);
}

.delete-dialog__btn--cancel {
    background: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #444;
}

.delete-dialog__btn--cancel:hover {
    background: #333;
}

.delete-dialog__btn--confirm {
    background: #d32f2f;
    color: #fff;
}

.delete-dialog__btn--confirm:hover {
    background: #c62828;
}

.delete-dialog__btn--confirm:disabled {
    background: #555;
    color: #999;
    cursor: not-allowed;
}

/* Delete button on existing OneDrive photos */
.photos-grid__delete-existing {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: rgba(211, 47, 47, .75);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .2s, background .15s;
}

.photos-grid__delete-existing:hover {
    background: rgba(198, 40, 40, .9);
}

.photos-grid__item:hover .photos-grid__delete-existing {
    opacity: 1;
}

@media (hover: none) {
    .photos-grid__delete-existing {
        opacity: 1;
    }
}
