/* Veri Girişi + Analiz Listesi — screenshot layout match.
   Renkler: krom mavisi tema (theme_kobalt.css ile aynı aile). */

:root {
    --lab-card: #ffffff;
    --lab-primary: #2a5bd0;
    --lab-primary-2: #1d4499;
    --lab-border: #e9ecef;
    --lab-muted: #6c757d;
    --lab-success: #28a745;
    --lab-danger: #dc3545;
    --lab-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    /* Orijinal ekran: plaka genişliği sol alanlarla aynı yükseklikte büyük kutu */
    --plaka-w: 12cm;
    --plaka-min-h: 10.08cm;
}

* {
    box-sizing: border-box;
}

/* Lab sayfaları: kenarlarda tarayıcı boşluğu/zemini görünmesin */
body {
    margin: 0;
    background: #dce7f7;
}

.lab-page {
    min-height: 100vh;
    background: #dce7f7 url('/static/img/bg-kaplama.svg?v=3') center / cover fixed no-repeat;
    color: #212529;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    padding: 20px 16px 48px;
}

.lab-wrap {
    max-width: 1180px;
    margin: 0 auto;
}

.lab-topnav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.lab-topnav a,
.lab-topnav .lab-nav-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid #b3c7e6;
    background: #fff;
    color: #1f4ab3;
    box-shadow: 0 1px 2px rgba(16, 40, 90, 0.08);
    text-decoration: none;
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.lab-topnav a.is-active {
    background: #2a5bd0;
    border-color: #2a5bd0;
    color: #fff;
}

.lab-topnav .lab-nav-back:hover,
.lab-topnav .lab-nav-back:focus-visible {
    background: #eef4fd;
    outline: none;
}

.lab-firm-context-band {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    margin: 0 0 16px;
    background: rgba(42, 91, 208, 0.12);
    border-radius: 10px;
    border: 1px solid rgba(42, 91, 208, 0.35);
    font-size: 13px;
    color: #2d3748;
}
.lab-firm-context-band .lab-firm-context-text strong {
    color: #1f4ab3;
}
.lab-firm-context-hint {
    opacity: 0.85;
}
.lab-firm-context-clear {
    flex: 0 0 auto;
    border: 1px solid rgba(42, 91, 208, 0.4);
    background: #fff;
    color: #1f4ab3;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.lab-firm-context-clear:hover {
    background: rgba(42, 91, 208, 0.08);
}

.lab-card {
    background: var(--lab-card);
    border-radius: 12px;
    box-shadow: var(--lab-shadow);
    padding: 25px;
}

#laboratoryForm {
    width: 100%;
}

/* ---- Sections ---- */

.lab-section {
    margin-bottom: 25px;
}

.lab-section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--lab-primary);
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--lab-border);
}

/* Üst satır: sol alanlar + sağ plaka (ekran görüntüsü) */
.lab-basics-top {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 20px;
    width: 100%;
}

.lab-basics-fields {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    /* Sol kolon plaka kadar uzamasın; alanlar dikey yığılır */
    max-width: calc(100% - var(--plaka-w) - 20px);
}

/* Alan genişlikleri (orijinal max-width hiyerarşisi) */
.lab-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.lab-group label {
    font-size: 13px;
    font-weight: 600;
    color: #495057;
}

.lab-group label .req {
    color: var(--lab-danger);
}

.lab-group input,
.lab-group select,
.lab-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--lab-border);
    border-radius: 6px;
    font: inherit;
    font-size: 14px;
    background: #fff;
    color: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.lab-group input:focus,
.lab-group select:focus,
.lab-group textarea:focus {
    outline: none;
    border-color: var(--lab-primary);
    box-shadow: 0 0 0 3px rgba(42, 91, 208, 0.1);
}

.lab-group input[readonly] {
    background: #e9ecef;
    cursor: not-allowed;
}

.lab-group textarea {
    resize: vertical;
    min-height: 60px;
}

.lab-group-sira {
    max-width: 250px;
}

.lab-group-firma {
    max-width: 500px;
}

.lab-group-banyo {
    max-width: 400px;
}

.lab-group-hacim {
    max-width: 200px;
}

.lab-group-not {
    margin-top: 18px;
    width: 100%;
    max-width: 100%;
}

.lab-sira-wrap {
    display: flex;
    align-items: center;
    gap: 5px;
}

.lab-sira-wrap input {
    flex: 1;
    min-width: 0;
    max-width: 200px;
}

.lab-sira-btns {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.lab-sira-btns button {
    width: 32px;
    height: 22px;
    border: 1px solid var(--lab-primary);
    background: linear-gradient(180deg, #4a7ce6 0%, #2b5bc8 48%, #224ead 52%, #1d4499 100%);
    color: #fff;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
    line-height: 1;
    padding: 0;
    box-shadow: 0 2px 4px rgba(42, 91, 208, 0.2);
}

.lab-sira-btns button:hover {
    transform: scale(1.08);
}

/* ---- Plaka Resimleri paneli ---- */

.lab-plaka {
    flex: 0 0 var(--plaka-w);
    width: var(--plaka-w);
    min-height: var(--plaka-min-h);
    border: 2px solid var(--lab-primary);
    border-radius: 8px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    align-self: flex-start;
}

.lab-plaka-header {
    flex: 0 0 auto;
    padding: 8px;
    background: linear-gradient(180deg, #4a7ce6 0%, #2b5bc8 48%, #224ead 52%, #1d4499 100%);
    color: #fff;
    text-align: center;
    font-weight: 600;
    font-size: 12px;
}

.lab-plaka-display {
    flex: 1 1 auto;
    width: 100%;
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #fff;
    cursor: pointer;
    /* 10:7 yaklaşık görüntü alanı (orijinal aspect-ratio) */
    aspect-ratio: 10 / 7;
    max-height: none;
}

.lab-plaka-display img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.lab-plaka-placeholder {
    color: var(--lab-muted);
    font-size: 14px;
    text-align: center;
    padding: 20px;
    pointer-events: none;
}

.lab-plaka-nav {
    flex: 0 0 auto;
    width: 100%;
    padding: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    background: #fff;
    border-top: 1px solid #dee2e6;
}

.lab-plaka-nav-btn {
    padding: 6px 12px;
    border: 1px solid var(--lab-primary);
    background: linear-gradient(180deg, #4a7ce6 0%, #2b5bc8 48%, #224ead 52%, #1d4499 100%);
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.lab-plaka-nav-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(42, 91, 208, 0.3);
}

.lab-plaka-nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.lab-plaka-counter {
    font-size: 12px;
    color: #495057;
    font-weight: 600;
}

.lab-plaka-actions {
    flex: 0 0 auto;
    padding: 8px;
    width: 100%;
    background: #fff;
}

.lab-plaka-upload {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--lab-success);
    background: var(--lab-success);
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.lab-plaka-upload:hover {
    background: #218838;
    transform: translateY(-1px);
}

.lab-plaka-delete {
    margin-top: 6px;
    border-color: var(--lab-danger);
    background: var(--lab-danger);
}

.lab-plaka-delete:hover:not(:disabled) {
    background: #c82333;
}

.lab-plaka-delete:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    background: var(--lab-danger);
}

/* ---- Tarihler: yan yana iki sütun ---- */

.lab-dates-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* ---- Analiz tablosu ---- */

.lab-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--lab-border);
    border-radius: 8px;
    margin-top: 8px;
}

.lab-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 680px;
    font-size: 13px;
}

.lab-table th,
.lab-table td {
    border: 1px solid var(--lab-border);
    padding: 10px;
    text-align: start;
    vertical-align: middle;
}

.lab-table th {
    background: linear-gradient(180deg, #4a7ce6 0%, #2b5bc8 48%, #224ead 52%, #1d4499 100%);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.lab-table th .col-filter {
    display: block;
    width: 100%;
    margin-top: 6px;
    font-weight: 400;
    font-size: 0.78rem;
    color: #333;
    cursor: text;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 4px 6px;
}

.lab-table tbody tr:nth-child(even) {
    background: #f8f9fa;
}

.lab-table tbody tr:hover {
    background: #e9ecef;
}

.lab-table td input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 6px;
    font: inherit;
    font-size: 12px;
}

.lab-table td input[readonly] {
    background: #f0f0f0;
    cursor: not-allowed;
}

/* ---- Butonlar ---- */

.lab-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid var(--lab-border);
}

.lab-btn {
    min-height: 44px;
    padding: 12px 24px;
    border-radius: 8px;
    border: none;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.lab-btn:hover {
    transform: translateY(-2px);
}

.lab-btn-secondary {
    background: #6c757d;
    color: #fff;
}

.lab-btn-secondary:hover {
    background: #5a6268;
}

.lab-btn-primary {
    background: linear-gradient(180deg, #4a7ce6 0%, #2b5bc8 48%, #224ead 52%, #1d4499 100%);
    color: #fff;
}

.lab-btn-primary:hover {
    box-shadow: 0 5px 15px rgba(42, 91, 208, 0.4);
}

.lab-status {
    margin-top: 12px;
    font-size: 0.9rem;
    color: var(--lab-muted);
}

.lab-status.is-error {
    color: var(--lab-danger);
}

.lab-status.is-ok {
    color: var(--lab-success);
}

.lab-empty {
    padding: 28px;
    text-align: center;
    color: var(--lab-muted);
}

.lab-list-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.lab-tuz-basics {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 14px 20px;
    max-width: 100% !important;
    width: 100%;
    margin-bottom: 12px;
    flex-direction: unset;
}

.lab-tuz-basics > .lab-group {
    max-width: none;
    width: 100%;
    min-width: 0;
}

.lab-tuz-basics > .lab-group-sira,
.lab-tuz-basics > .lab-group-firma {
    max-width: none;
}

.lab-section .lab-group-not {
    grid-column: 1 / -1;
}

.lab-obs-form {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    padding: 14px;
    margin-bottom: 16px;
    border: 1px solid var(--lab-border);
    border-radius: 10px;
    background: #f8f9fb;
}

.lab-obs-timeline {
    /* Mobil-first: dar telefon = 1 sütun */
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: stretch;
}

.lab-obs-timeline > .lab-empty {
    grid-column: 1 / -1;
}

/* Geniş telefon / küçük tablet: 2 sütun */
@media (min-width: 560px) {
    .lab-obs-timeline {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }
}

/* Masaüstü / yatay tablet: 3 sütun */
@media (min-width: 960px) {
    .lab-obs-timeline {
        grid-template-columns: repeat(3, 1fr);
    }
}

.lab-obs-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--lab-border);
    border-radius: 10px;
    background: #fff;
    min-width: 0;
}

.lab-obs-thumb {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--lab-border);
    flex-shrink: 0;
    background: #f1f3f5;
}

.lab-obs-thumb--clickable {
    cursor: zoom-in;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.lab-obs-thumb--clickable:hover {
    box-shadow: 0 4px 14px rgba(31, 74, 179, 0.22);
    transform: translateY(-1px);
}

.lab-obs-thumb-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--lab-muted);
}

.lab-obs-gallery {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.lab-obs-gallery-empty {
    padding: 16px 10px;
    text-align: center;
    font-size: 12px;
    color: var(--lab-muted);
    border: 1px dashed var(--lab-border);
    border-radius: 8px;
    background: #f8f9fb;
}

.lab-obs-img-tile {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.lab-obs-img-actions {
    display: flex;
    gap: 6px;
}

.lab-obs-img-actions .lab-btn {
    flex: 1;
    padding: 6px 8px;
    font-size: 12px;
}

.lab-obs-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: auto;
}

.lab-obs-card-actions .lab-btn {
    flex: 1;
    min-width: 0;
}

.lab-obs-card--add {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 220px;
    border: 2px dashed var(--lab-border);
    background: #f8f9fb;
    color: #1f4ab3;
    cursor: pointer;
    text-align: center;
    font: inherit;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.lab-obs-card--add:hover {
    border-color: #1f4ab3;
    background: #f3eefc;
}

.lab-obs-add-plus {
    font-size: 36px;
    font-weight: 700;
    line-height: 1;
}

.lab-obs-add-label {
    font-size: 15px;
    font-weight: 600;
}

.lab-obs-add-hint {
    font-size: 12px;
    color: var(--lab-muted);
}

.lab-obs-body {
    flex: 0 0 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.lab-obs-meta {
    margin-bottom: 6px;
    font-size: 13px;
}

.lab-obs-tag {
    display: inline-block;
    margin-inline-start: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(42, 91, 208, 0.15);
    color: #1f4ab3;
    font-size: 12px;
    font-weight: 600;
}

.lab-obs-caption {
    margin: 0 0 10px;
    white-space: pre-wrap;
    color: #343a40;
    font-size: 13px;
    flex: 1;
}

/* Gözlem resmi lightbox */
.lab-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 18, 28, 0.82);
    cursor: zoom-out;
}

.lab-lightbox.is-open {
    display: flex;
}

.lab-lightbox-inner {
    position: relative;
    max-width: min(960px, 96vw);
    max-height: 92vh;
    cursor: default;
}

.lab-lightbox-inner img {
    display: block;
    max-width: 100%;
    max-height: 88vh;
    width: auto;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    background: #111;
}

.lab-lightbox-close {
    position: absolute;
    top: -12px;
    inset-inline-end: -12px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #fff;
    color: #333;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.lab-lightbox-close:hover {
    background: #f0f0f0;
}

.lab-lightbox-caption {
    margin: 10px 0 0;
    color: #f1f3f5;
    font-size: 14px;
    text-align: center;
}

/* Liste sayfası filtreleri */
.lab-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.lab-filters .lab-group {
    flex: 1 1 220px;
    max-width: 320px;
}

/* Searchable combobox (müşteri firma vb.) */
.lab-combobox {
    position: relative;
}

.lab-combobox-menu {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 2px);
    z-index: 40;
    max-height: 220px;
    overflow-y: auto;
    margin: 0;
    padding: 4px 0;
    list-style: none;
    background: #fff;
    border: 1px solid #ced4da;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.lab-combobox-menu[hidden] {
    display: none !important;
}

.lab-combobox-menu li {
    margin: 0;
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    color: #212529;
}

.lab-combobox-menu li:hover,
.lab-combobox-menu li.is-active {
    background: #eef2ff;
    color: #4338ca;
}

.lab-combobox-menu li.lab-combobox-empty {
    color: #6c757d;
    cursor: default;
}

.lab-combobox-menu li.lab-combobox-empty:hover {
    background: transparent;
    color: #6c757d;
}

/* ---- Mobil: plaka alta ---- */

@media (max-width: 900px) {
    .lab-basics-top {
        flex-direction: column;
    }

    .lab-basics-fields {
        max-width: 100%;
        width: 100%;
        order: 1;
    }

    .lab-plaka {
        order: 0;
        flex: none;
        width: 100%;
        max-width: 100%;
        min-height: 0;
    }

    .lab-plaka-display {
        min-height: 200px;
    }

    .lab-group-firma,
    .lab-group-banyo,
    .lab-group-hacim,
    .lab-group-sira {
        max-width: 100%;
    }

    .lab-dates-row {
        grid-template-columns: 1fr;
    }

    .lab-tuz-basics {
        grid-template-columns: 1fr !important;
    }

    .lab-obs-form {
        grid-template-columns: 1fr;
    }

    .lab-obs-thumb {
        height: 180px;
    }
}

/* R2: analiz onay çubuğu */
.lab-onay {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 12px 0;
}
.lab-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    background: #eef1fb;
    color: #3b4a8a;
    font-size: 13px;
    font-weight: 600;
}
.lab-badge-warn {
    background: #fdecea;
    color: #b42318;
}
