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

:root {
    --color-bg:       #f5f7fa;
    --color-surface:  #ffffff;
    --color-primary:  #4a7c59;
    --color-primary-h:#3a6347;
    --color-danger:   #c0392b;
    --color-danger-h: #a93226;
    --color-text:     #1a1a1a;
    --color-muted:    #6b7280;
    --color-border:   #e5e7eb;
    --radius:         10px;
    --shadow:         0 2px 12px rgba(0,0,0,.08);
    --transition:     .2s ease;
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

/* ── Layout ── */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

/* ── Header / Nav ── */
.site-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky; top: 0; z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: .75rem;
    padding-bottom: .75rem;
}

.site-logo {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-primary);
}
.site-logo:hover { text-decoration: none; }

.site-nav {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.nav-link {
    color: var(--color-text);
    font-weight: 500;
    font-size: .9rem;
    padding: .3rem .5rem;
    border-radius: 6px;
    transition: background var(--transition);
}
.nav-link:hover { background: var(--color-bg); text-decoration: none; }
.nav-link--logout { color: var(--color-muted); }

.nav-user { font-size: .9rem; color: var(--color-muted); }

.nav-toggle {
    display: none;
    background: none; border: none; cursor: pointer;
    font-size: 1.4rem; color: var(--color-text);
}

.mobile-nav {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: .75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
}
.mobile-nav a, .mobile-nav span { font-size: 1rem; color: var(--color-text); }

.hidden { display: none !important; }

@media (max-width: 640px) {
    .site-nav { display: none; }
    .nav-toggle { display: block; }
}

/* ── Auth Pages ── */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.auth-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
}

.auth-logo {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: .5rem;
}

.auth-card h1 {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

.auth-card label {
    display: block;
    font-size: .875rem;
    font-weight: 600;
    margin-bottom: .3rem;
    margin-top: 1rem;
    color: var(--color-text);
}

.auth-card input {
    width: 100%;
    padding: .6rem .75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color var(--transition);
    background: var(--color-bg);
}
.auth-card input:focus { outline: none; border-color: var(--color-primary); background: #fff; }

.auth-link { text-align: center; margin-top: 1.25rem; font-size: .9rem; color: var(--color-muted); }

/* ── Forms (shared) ── */
label {
    display: block;
    font-size: .875rem;
    font-weight: 600;
    margin-bottom: .3rem;
    margin-top: 1.25rem;
}

input[type="date"],
input[type="text"],
input[type="email"],
input[type="password"] {
    width: 100%;
    padding: .6rem .75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 1rem;
    background: var(--color-bg);
    transition: border-color var(--transition);
}
input:focus { outline: none; border-color: var(--color-primary); background: #fff; }

/* ── Buttons ── */
.btn {
    display: inline-block;
    padding: .6rem 1.2rem;
    border-radius: 6px;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background var(--transition), transform var(--transition);
    text-align: center;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-h); }

.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: var(--color-danger-h); }

.btn-full { width: 100%; margin-top: 1.25rem; padding: .75rem; font-size: 1rem; }

.btn-delete {
    background: none; border: none; cursor: pointer;
    font-size: 1.1rem; padding: .2rem .4rem;
    border-radius: 4px;
    transition: background var(--transition);
    line-height: 1;
}
.btn-delete:hover { background: #fde8e8; }

/* ── Alerts ── */
.alert {
    padding: .85rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: .9rem;
}
.alert-error   { background: #fde8e8; color: #7b1d1d; border-left: 3px solid var(--color-danger); }
.alert-success { background: #e6f4ea; color: #1b5e20; border-left: 3px solid var(--color-primary); }
.alert-warning { background: #fffbeb; color: #92400e; border-left: 3px solid #f59e0b; }
.alert ul, .alert p { margin: 0; }
.alert li { margin-left: 1.2rem; }

.alert-rejection {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    background: #1a1a1a;
    color: #f9fafb;
    border-left: 4px solid #dc2626;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    font-size: .92rem;
    animation: shake .4s ease;
}
.alert-rejection__icon { font-size: 2rem; line-height: 1; flex-shrink: 0; }
.alert-rejection strong { font-size: 1.05rem; color: #f87171; display: block; margin-bottom: .25rem; }
.alert-rejection__file  { font-size: .8rem; color: #9ca3af; }
.alert-rejection__reason { font-size: .82rem; color: #d1d5db; margin-top: .2rem; display: block; }

@keyframes shake {
    0%,100% { transform: translateX(0); }
    20%      { transform: translateX(-6px); }
    40%      { transform: translateX(6px); }
    60%      { transform: translateX(-4px); }
    80%      { transform: translateX(4px); }
}

/* ── Gallery ── */
.gallery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.gallery-header h1 { font-size: 1.6rem; }

.photo-count { color: var(--color-muted); font-size: .9rem; margin-bottom: 1rem; }

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.photo-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform var(--transition), box-shadow var(--transition);
}
.photo-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,.12); }

.photo-card__link img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

.photo-card__info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .5rem .75rem;
    border-top: 1px solid var(--color-border);
}

.photo-card__meta {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    min-width: 0;    /* umožní text-overflow fungovat uvnitř flex kontejneru */
    overflow: hidden;
}

.photo-date { font-size: .78rem; color: var(--color-muted); }

.ai-badge {
    display: inline-block;
    font-size: .68rem;
    font-weight: 600;
    padding: .15rem .45rem;
    border-radius: 99px;
    cursor: default;
    /* Fix overflow */
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ai-badge--gold    { background: #fef3c7; color: #78350f; border: 1px solid #f59e0b; }
.ai-badge--silver  { background: #f1f5f9; color: #334155; border: 1px solid #94a3b8; }
.ai-badge--bronze  { background: #fdf4ed; color: #7c3a1a; border: 1px solid #c2885a; }
.ai-badge--fail    { background: #fef3c7; color: #92400e; }
.ai-badge--unknown { background: #f3f4f6; color: #6b7280; }

/* ── AI výsledky po uploadu ── */
.ai-results {
    margin-top: .75rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    border-top: 1px solid rgba(0,0,0,.08);
    padding-top: .75rem;
}
.ai-result-row {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    font-size: .85rem;
}
.ai-result-badge {
    flex-shrink: 0;
    display: inline-block;
    font-weight: 700;
    padding: .2rem .6rem;
    border-radius: 99px;
    font-size: .78rem;
    white-space: nowrap;
}
.ai-result-badge--gold   { background: #fef3c7; color: #78350f; border: 1px solid #f59e0b; }
.ai-result-badge--silver { background: #f1f5f9; color: #334155; border: 1px solid #94a3b8; }
.ai-result-badge--bronze { background: #fdf4ed; color: #7c3a1a; border: 1px solid #c2885a; }
.ai-result-info { color: #374151; line-height: 1.4; }
.ai-result-total {
    font-size: .85rem;
    color: #1b5e20;
    font-weight: 700;
    padding-top: .35rem;
    border-top: 1px solid rgba(0,0,0,.06);
}

.delete-form { margin: 0; }

/* ── Pagination ── */
.pagination {
    display: flex;
    gap: .5rem;
    justify-content: center;
    margin-top: 2rem;
    flex-wrap: wrap;
}
.page-link {
    padding: .4rem .8rem;
    border-radius: 6px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    font-size: .9rem;
    transition: background var(--transition);
}
.page-link:hover { background: var(--color-bg); text-decoration: none; }
.page-link.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ── Upload Card ── */
.upload-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    max-width: 520px;
}

.drop-zone {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    padding: 2.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    position: relative;
}
.drop-zone.drag-over { border-color: var(--color-primary); background: #edf7f0; }

.drop-zone__icon { font-size: 2.5rem; display: block; margin-bottom: .5rem; }
.drop-zone p { color: var(--color-muted); font-size: .9rem; margin-bottom: .25rem; }
.drop-zone .link { color: var(--color-primary); cursor: pointer; font-weight: 600; }

.drop-zone input[type="file"] {
    position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%;
}

.drop-zone__hint { font-size: .8rem !important; }

/* ── Multi-photo preview grid ── */
.multi-preview {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .75rem;
    margin-top: 1rem;
}

.preview-card {
    position: relative;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.preview-card img {
    width: 100%;
    height: 110px;
    object-fit: cover;
    display: block;
}

.preview-card__name {
    font-size: .72rem;
    color: var(--color-muted);
    padding: .3rem .5rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.preview-card__remove {
    position: absolute;
    top: 4px; right: 4px;
    background: rgba(0,0,0,.55);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 22px; height: 22px;
    font-size: .7rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--transition);
    line-height: 1;
}
.preview-card__remove:hover { background: var(--color-danger); }

.upload-counter {
    font-size: .82rem;
    color: var(--color-muted);
    margin-top: .5rem;
    text-align: right;
}

/* ── Photo Detail ── */
.back-link {
    display: inline-block;
    margin-bottom: 1.25rem;
    color: var(--color-muted);
    font-size: .9rem;
}
.back-link:hover { color: var(--color-primary); }

.photo-detail {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 0;
}

.photo-detail img {
    width: 100%;
    max-height: 70vh;
    object-fit: contain;
    background: #111;
}

.photo-detail__meta {
    padding: 1.5rem;
    border-left: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: .75rem;
}
.photo-detail__meta h1 {
    font-size: 1.1rem;
    word-break: break-all;
}
.photo-detail__meta p { font-size: .9rem; color: var(--color-muted); }

@media (max-width: 700px) {
    .photo-detail { grid-template-columns: 1fr; }
    .photo-detail__meta { border-left: none; border-top: 1px solid var(--color-border); }
}

/* ── Lightbox ── */
.lightbox {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.92);
    display: flex; align-items: center; justify-content: center;
    z-index: 999;
}
.lightbox img {
    max-width: 90vw; max-height: 90vh;
    border-radius: 6px;
    object-fit: contain;
}
.lightbox__close,
.lightbox__prev,
.lightbox__next {
    position: absolute;
    background: rgba(255,255,255,.15);
    border: none; color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 50%;
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--transition);
}
.lightbox__close:hover,
.lightbox__prev:hover,
.lightbox__next:hover { background: rgba(255,255,255,.3); }
.lightbox__close { top: 1rem; right: 1rem; }
.lightbox__prev  { left: 1rem; top: 50%; transform: translateY(-50%); }
.lightbox__next  { right: 1rem; top: 50%; transform: translateY(-50%); }

/* ── Dashboard ── */
.stats-row {
    display: flex;
    gap: 1rem;
    margin: 1.25rem 0 2rem;
    flex-wrap: wrap;
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 140px;
}

.stat-card__value {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1;
}

.stat-card__label {
    font-size: .8rem;
    color: var(--color-muted);
    margin-top: .4rem;
    text-align: center;
}

.dashboard-table-wrap {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
}

.dashboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .95rem;
}

.dashboard-table th {
    text-align: left;
    padding: .75rem 1rem;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--color-muted);
    border-bottom: 2px solid var(--color-border);
}

.dashboard-table td {
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.dashboard-table tbody tr:last-child td { border-bottom: none; }

.dashboard-table tbody tr:hover { background: var(--color-bg); }

.dashboard-table tr.current-user { background: #edf7f0; }
.dashboard-table tr.current-user:hover { background: #e0f2e8; }

.rank { color: var(--color-muted); width: 40px; }

.username { font-weight: 600; }

.count { font-weight: 700; width: 100px; }

.you-badge {
    display: inline-block;
    font-size: .7rem;
    background: var(--color-primary);
    color: #fff;
    padding: .1rem .4rem;
    border-radius: 99px;
    margin-left: .4rem;
    font-weight: 600;
    vertical-align: middle;
}

.bar-cell {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-width: 160px;
}

.bar-wrap {
    flex: 1;
    background: var(--color-border);
    border-radius: 99px;
    height: 8px;
    overflow: hidden;
}

.bar {
    height: 100%;
    background: var(--color-primary);
    border-radius: 99px;
    transition: width .4s ease;
    min-width: 2px;
}

.bar-pct {
    font-size: .8rem;
    color: var(--color-muted);
    white-space: nowrap;
    width: 40px;
    text-align: right;
}

/* ── CAPTCHA ── */
.captcha-wrap {
    margin-top: 1.25rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: .85rem 1rem;
}
.captcha-wrap label {
    margin-top: 0;
    margin-bottom: .45rem;
    font-size: .9rem;
    color: var(--color-text);
}
.captcha-wrap input {
    width: 100%;
    margin-bottom: .35rem;
}
.captcha-hint {
    display: block;
    font-size: .75rem;
    color: var(--color-muted);
    margin-top: .25rem;
}

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--color-muted);
}
.empty-state__icon { font-size: 4rem; display: block; margin-bottom: 1rem; }
