/* ═══════════════════════════════════════════════════════════════════════════
   app.css  –  Hlavni skenovaci aplikace
   Barvy: #ee8027 (oranzova), #f6ebd8 (kremova)
   Fonty: SkautBold, TheMixC5
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Fonty ──────────────────────────────────────────────────────────────── */
@font-face {
    font-family: 'SkautBold';
    src: url('../fonts/SkautBold.woff2') format('woff2'),
         url('../fonts/SkautBold.woff')  format('woff');
    font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'TheMixC5';
    src: url('../fonts/TheMixC5-Regular.woff2') format('woff2'),
         url('../fonts/TheMixC5-Regular.woff')  format('woff');
    font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'TheMixC5';
    src: url('../fonts/TheMixC5-Regular-Italic.woff2') format('woff2'),
         url('../fonts/TheMixC5-Regular-Italic.woff')  format('woff');
    font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
    font-family: 'TheMixC5';
    src: url('../fonts/TheMixC5-Bold.woff2') format('woff2'),
         url('../fonts/TheMixC5-Bold.woff')  format('woff');
    font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'TheMixC5';
    src: url('../fonts/TheMixC5-Bold-Italic.woff2') format('woff2'),
         url('../fonts/TheMixC5-Bold-Italic.woff')  format('woff');
    font-weight: 700; font-style: italic; font-display: swap;
}

/* ── Promenne ───────────────────────────────────────────────────────────── */
:root {
    --orange:       #ee8027;
    --orange-dark:  #d06a15;
    --orange-light: #f5a05a;
    --orange-pale:  #fdeedd;
    --cream:        #f6ebd8;
    --cream-dark:   #e8d5b7;
    --cream-deeper: #d4b98a;
    --brown:        #2c1a06;
    --brown-mid:    #6b4c2a;
    --text:         #3a2510;
    --text-muted:   #9b8060;
    --success:      #2d7a4f;
    --success-bg:   #e8f5ee;
    --error:        #b91c1c;
    --error-bg:     #fee2e2;
    --white:        #ffffff;
    --shadow:       0 2px 12px rgba(44,26,6,0.13);
    --shadow-lg:    0 8px 32px rgba(44,26,6,0.18);
    --radius:       14px;
    --radius-sm:    8px;
    --transition:   .18s ease;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: 'TheMixC5', system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    color: var(--text);
    background: var(--cream);
    min-height: 100dvh;
    overflow-x: hidden;
}

img, video { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ── Lepici hlavicka s jmenem ditete ────────────────────────────────────── */
.app-header {
    position: sticky;
    top: 0;
    z-index: 200;
    background: var(--brown);
    color: var(--cream);
    padding: 0 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.app-header-logo {
    font-family: 'SkautBold', sans-serif;
    font-size: 1.1rem;
    color: var(--cream);
    white-space: nowrap;
    flex-shrink: 0;
}

.app-header-child {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--orange);
    color: var(--white);
    border-radius: 99px;
    padding: 4px 14px;
    font-weight: 700;
    font-size: 0.9rem;
    max-width: 240px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity var(--transition);
}
.app-header-child.hidden { opacity: 0; pointer-events: none; }

/* ── Hlavni obsah ───────────────────────────────────────────────────────── */
.app-main {
    max-width: 520px;
    margin: 0 auto;
    padding: 24px 16px 100px;
}

/* ── Krok – obecny ──────────────────────────────────────────────────────── */
.step {
    display: none;
    flex-direction: column;
    gap: 20px;
    animation: fadeIn .22s ease;
}
.step.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.step-title {
    font-family: 'SkautBold', sans-serif;
    font-size: 1.3rem;
    color: var(--brown);
}

.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

/* ── KROK 1: Vyhledavac ─────────────────────────────────────────────────── */
.search-wrap { position: relative; }

.search-input-main {
    width: 100%;
    padding: 14px 48px 14px 16px;
    border: 2px solid var(--cream-dark);
    border-radius: var(--radius-sm);
    font-family: 'TheMixC5', sans-serif;
    font-size: 1rem;
    color: var(--text);
    background: var(--cream);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.search-input-main:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px var(--orange-pale);
}
.search-input-main::placeholder { color: var(--text-muted); }

.search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    color: var(--text-muted);
    padding: 4px;
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
}
.search-clear.visible { display: block; }

/* Dropdown seznam */
.autocomplete-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--white);
    border: 1.5px solid var(--cream-dark);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    max-height: 320px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}
.autocomplete-list.open { display: block; }

.autocomplete-item {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid var(--cream);
    transition: background var(--transition);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover,
.autocomplete-item.highlighted { background: var(--orange-pale); }

.ac-name { font-weight: 700; flex: 1; }
.ac-nick { font-size: 0.85rem; color: var(--text-muted); }

.ac-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 99px;
    white-space: nowrap;
    flex-shrink: 0;
}
.ac-badge--done    { background: var(--success-bg); color: var(--success); }
.ac-badge--pending { background: var(--cream);      color: var(--text-muted); }

.search-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
    padding: 8px 0 0;
}

/* ── KROK 2: Vyber zdroje ───────────────────────────────────────────────── */
.source-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.source-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 28px 16px;
    border-radius: var(--radius);
    border: 2.5px solid var(--cream-dark);
    background: var(--white);
    color: var(--brown);
    font-family: 'TheMixC5', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    transition: all var(--transition);
    cursor: pointer;
    box-shadow: var(--shadow);
}
.source-btn:hover {
    border-color: var(--orange);
    background: var(--orange-pale);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.source-btn:active { transform: translateY(0); }

.source-btn-icon {
    font-size: 2.5rem;
    line-height: 1;
}

.source-back {
    text-align: center;
    margin-top: 4px;
}

/* ── KROK 3: Nahled + rotace ────────────────────────────────────────────── */
.preview-wrap {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--brown);
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#previewImage {
    max-width: 100%;
    max-height: 60dvh;
    object-fit: contain;
    border-radius: var(--radius-sm);
    transition: transform .3s ease;
    display: block;
}

#previewPdf {
    width: 100%;
    height: 60dvh;
    border: none;
    border-radius: var(--radius-sm);
    display: none;
}

.preview-pdf-icon {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: var(--cream);
    padding: 40px;
    text-align: center;
}
.preview-pdf-icon span { font-size: 3.5rem; }
.preview-pdf-icon p { font-weight: 700; font-size: 1rem; }

.rotate-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.rotate-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--cream-dark);
    background: var(--white);
    font-family: 'TheMixC5', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--brown);
    transition: all var(--transition);
    box-shadow: var(--shadow);
    flex: 1;
    justify-content: center;
}
.rotate-btn:hover { border-color: var(--orange); background: var(--orange-pale); }

/* Pouze obrazky mozno tocit – PDF ne */
.rotate-controls.hidden { display: none; }

/* ── Tlacitko odeslat ───────────────────────────────────────────────────── */
.submit-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    padding: 14px 20px;
    background: rgba(246,235,216,0.96);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 -2px 16px rgba(44,26,6,0.12);
    display: none;
    z-index: 150;
}
.submit-bar.visible { display: block; }

.submit-btn {
    width: 100%;
    padding: 16px;
    background: var(--orange);
    color: var(--white);
    font-family: 'SkautBold', sans-serif;
    font-size: 1.1rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
    letter-spacing: 0.02em;
}
.submit-btn:hover:not(:disabled) { background: var(--orange-dark); transform: translateY(-1px); }
.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ── Progress bar ───────────────────────────────────────────────────────── */
.progress-wrap {
    display: none;
    flex-direction: column;
    gap: 10px;
}
.progress-wrap.visible { display: flex; }

.progress-bar-outer {
    width: 100%;
    height: 10px;
    background: var(--cream-dark);
    border-radius: 99px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--orange), var(--orange-light));
    border-radius: 99px;
    transition: width .15s linear;
}

.progress-label {
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--brown-mid);
}

/* ── Tlacitka pro navigaci ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-family: 'TheMixC5', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    text-decoration: none;
}
.btn-secondary {
    background: var(--cream-dark);
    color: var(--brown);
}
.btn-secondary:hover { background: var(--cream-deeper); }

/* ── Modal – potvrzeni odeslani ─────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(44,26,6,0.55);
    z-index: 300;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}
.modal-backdrop.open {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--white);
    border-radius: var(--radius) var(--radius) var(--radius-sm) var(--radius-sm);
    padding: 28px 24px 24px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform .2s ease;
}
.modal-backdrop.open .modal { transform: translateY(0); }

.modal-title {
    font-family: 'SkautBold', sans-serif;
    font-size: 1.2rem;
    color: var(--brown);
    margin-bottom: 10px;
}

.modal-body {
    color: var(--text);
    margin-bottom: 20px;
    line-height: 1.6;
}

.modal-child-name {
    font-weight: 700;
    color: var(--orange);
    font-size: 1.05rem;
}

.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.modal-confirm {
    padding: 13px;
    background: var(--orange);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'TheMixC5', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background var(--transition);
}
.modal-confirm:hover { background: var(--orange-dark); }

.modal-cancel {
    padding: 13px;
    background: var(--cream-dark);
    color: var(--brown);
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'TheMixC5', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background var(--transition);
}
.modal-cancel:hover { background: var(--cream-deeper); }

/* ── Uspesne odeslano ───────────────────────────────────────────────────── */
.success-screen {
    text-align: center;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}
.success-icon {
    font-size: 4rem;
    line-height: 1;
}
.success-title {
    font-family: 'SkautBold', sans-serif;
    font-size: 1.5rem;
    color: var(--success);
}
.success-name {
    color: var(--brown-mid);
    font-size: 1rem;
}

/* ── Chybova hlaska ─────────────────────────────────────────────────────── */
.alert-error {
    background: var(--error-bg);
    color: var(--error);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-weight: 700;
    font-size: 0.9rem;
    display: none;
}
.alert-error.visible { display: block; }

/* ── Nacitaci stav ──────────────────────────────────────────────────────── */
.app-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50dvh;
    gap: 16px;
    color: var(--text-muted);
}
.spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--cream-dark);
    border-top-color: var(--orange);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Kamera overlay ─────────────────────────────────────────────────────── */
.camera-wrap {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #000;
    aspect-ratio: 4/3;
    width: 100%;
}
#cameraVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.camera-capture-btn {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: 64px;
    height: 64px;
    background: var(--white);
    border: 4px solid var(--orange);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: transform var(--transition), background var(--transition);
}
.camera-capture-btn:hover { background: var(--orange-pale); transform: translateX(-50%) scale(1.08); }
.camera-capture-btn:active { transform: translateX(-50%) scale(0.96); }

/* ── Responzivita ───────────────────────────────────────────────────────── */
@media (min-width: 480px) {
    .source-buttons { grid-template-columns: 1fr 1fr; }
    .app-main { padding-top: 32px; }
}
@media (max-width: 360px) {
    .source-buttons { grid-template-columns: 1fr; }
    .rotate-buttons { flex-direction: column; }
    .modal-actions { grid-template-columns: 1fr; }
}
