/* =====================================================
   TEREN.CSS – Interfata mobila pentru colectare teren
   Optimizat: iPhone 16 Pro, touch-first, dark mode
   ===================================================== */

:root {
    --bg: #0f1117;
    --card: #1a1d27;
    --border: #2a2d3e;
    --text: #e8eaf0;
    --muted: #8b91a8;
    --green: #22c55e;
    --yellow: #f59e0b;
    --red: #ef4444;
    --blue: #3b82f6;
    --purple: #7c3aed;
    --radius: 12px;
    --safe-bottom: env(safe-area-inset-bottom, 20px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    height: -webkit-fill-available;
    height: 100%;
    font-family: -apple-system, 'SF Pro Text', 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    user-select: none;
}

/* ── TOP BAR ── */
#t-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    padding-top: env(safe-area-inset-top);
    background: rgba(15, 17, 23, 0.95);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    display: flex;
    align-items: flex-end;
    padding-bottom: 10px;
    padding-left: 16px;
    padding-right: 16px;
    gap: 10px;
}

#t-topbar .t-btn-back {
    font-size: 13px;
    color: var(--purple);
    text-decoration: none;
    font-weight: 600;
    padding: 4px 8px;
    background: rgba(124, 58, 237, 0.1);
    border-radius: 8px;
}

#t-topbar .tb-title {
    font-size: 15px;
    font-weight: 600;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#t-status-badge {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
}

#t-status-badge.nefotat {
    background: rgba(239, 68, 68, 0.2);
    color: var(--red);
}

#t-status-badge.fotografiat {
    background: rgba(34, 197, 94, 0.2);
    color: var(--green);
}

/* ── HARTA ── */
#t-map {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    transition: bottom 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

#t-map.panel-open {
    bottom: 55vh;
}

/* ── BOTTOM SHEET (panel colectare) ── */
#t-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: -100%;
    max-height: 80vh;
    background: var(--card);
    border-radius: 20px 20px 0 0;
    border-top: 1px solid var(--border);
    z-index: 200;
    transition: bottom 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    padding-bottom: calc(var(--safe-bottom) + 80px);
}

#t-sheet.open {
    bottom: 0;
}

#t-sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 12px auto 16px;
}

#t-sheet-content {
    padding: 0 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#t-plot-id {
    font-size: 11px;
    color: var(--muted);
    letter-spacing: 0.8px;
    text-transform: uppercase;
    font-weight: 600;
}

#t-foto-area {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

#t-foto-preview {
    width: 80px;
    height: 80px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid var(--border);
    display: none;
    flex-shrink: 0;
}

#t-foto-placeholder {
    width: 80px;
    height: 80px;
    border-radius: 10px;
    border: 1px dashed var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--muted);
    gap: 4px;
    flex-shrink: 0;
    cursor: pointer;
    transition: border-color 0.2s;
}

#t-foto-placeholder:active {
    border-color: var(--purple);
}

#t-foto-placeholder .ico {
    font-size: 24px;
}

#t-btn-foto {
    flex: 1;
    background: linear-gradient(135deg, var(--purple), #c026d3);
    border: none;
    border-radius: var(--radius);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    padding: 10px 16px;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    gap: 4px;
    -webkit-appearance: none;
    appearance: none;
}

#t-btn-foto .btn-icon {
    font-size: 28px;
}

#t-btn-foto:active {
    opacity: 0.85;
    transform: scale(0.98);
}

/* Input ascuns pentru cameră */
#file-camera {
    display: none;
}

/* ── CÂMPURI OCR ── */
.ocr-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ocr-label {
    font-size: 11px;
    color: var(--muted);
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.ocr-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    color: var(--text);
    font-size: 16px;
    font-family: inherit;
    outline: none;
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.2s;
}

.ocr-input:focus {
    border-color: var(--purple);
}

.ocr-input.populated {
    border-color: rgba(34, 197, 94, 0.4);
}

.ocr-row {
    display: flex;
    gap: 10px;
}

.ocr-row .ocr-field {
    flex: 1;
}

/* Multi-person records */
.person-record {
    border-bottom: 1px dashed var(--border);
    padding-bottom: 16px;
    margin-bottom: 16px;
    animation: slideDown 0.3s ease-out;
}

.person-record:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.t-btn-remove-pers {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.1);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    font-size: 14px;
    padding: 8px;
    margin-top: 10px;
    cursor: pointer;
}

/* OCR Status */
#t-ocr-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
    padding: 4px 0;
    display: none;
}

#t-ocr-status.loading {
    display: flex;
    color: var(--yellow);
}

#t-ocr-status.done {
    display: flex;
    color: var(--green);
}

#t-ocr-status.error {
    display: flex;
    color: var(--red);
}

#t-ocr-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: none;
}

.loading #t-ocr-spinner {
    display: block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── BUTOANE ACȚIUNI ── */
#t-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.t-btn {
    flex: 1;
    padding: 14px;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.t-btn:active {
    opacity: 0.85;
    transform: scale(0.98);
}

.t-btn-save {
    background: var(--green);
    color: #fff;
}

.t-btn-skip {
    background: rgba(255, 255, 255, 0.07);
    color: var(--muted);
    border: 1px solid var(--border);
}

/* ── BOTTOM NAV ── */
#t-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding-bottom: var(--safe-bottom);
    background: rgba(15, 17, 23, 0.95);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    z-index: 300;
    display: flex;
    align-items: center;
    padding-left: 16px;
    padding-right: 16px;
    height: calc(54px + var(--safe-bottom));
    gap: 8px;
}

#t-bottom-nav.hidden {
    display: none;
}

.bnav-btn {
    flex: 1;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
}

.bnav-btn.primary {
    background: linear-gradient(135deg, var(--purple), #c026d3);
    border-color: transparent;
}

.bnav-btn:active {
    opacity: 0.85;
}

/* ── PROGRESS ── */
#t-progress-bar {
    position: fixed;
    bottom: calc(54px + var(--safe-bottom));
    left: 0;
    right: 0;
    height: 3px;
    background: var(--border);
    z-index: 150;
}

#t-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--purple), var(--green));
    transition: width 0.4s ease;
    width: 0%;
}

/* ── TOAST ── */
#t-toast {
    position: fixed;
    bottom: calc(70px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
    z-index: 400;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

#t-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── SYNC INDICATOR ── */
#t-sync-status {
    position: fixed;
    top: 60px;
    right: 12px;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 10px;
    z-index: 150;
    display: none;
}

#t-sync-status.pending {
    display: block;
    background: rgba(245, 158, 11, 0.15);
    color: var(--yellow);
}

#t-sync-status.synced {
    display: block;
    background: rgba(34, 197, 94, 0.15);
    color: var(--green);
}