/* ============================================================
   Panel / Login dizajn — polovni-racunari.rs
   Koristi se na: /login, /panel/*
   ============================================================ */

:root {
    --p-primary: #2563eb;
    --p-primary-dark: #1d4ed8;
    --p-primary-soft: #eff6ff;
    --p-bg: #f1f5f9;
    --p-card: #ffffff;
    --p-border: #e2e8f0;
    --p-text: #0f172a;
    --p-muted: #64748b;
    --p-success: #16a34a;
    --p-success-soft: #f0fdf4;
    --p-danger: #dc2626;
    --p-danger-soft: #fef2f2;
    --p-warning: #d97706;
    --p-warning-soft: #fffbeb;
    --p-radius: 14px;
    --p-shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }

body.panel-body {
    margin: 0;
    font-family: 'Poppins', -apple-system, 'Segoe UI', sans-serif;
    background: var(--p-bg);
    color: var(--p-text);
    font-size: 15px;
    line-height: 1.55;
    min-height: 100vh;
}

a { text-decoration: none; }

/* ---------------- "View as" baner ---------------- */
.p-impersonation-bar {
    background: #fef3c7;
    border-bottom: 1px solid #fde68a;
    color: #92400e;
    padding: 9px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 13.5px;
    font-weight: 500;
}

.p-impersonation-bar button {
    background: #d97706;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 6px 14px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.p-impersonation-bar button:hover { background: #b45309; }

/* ---------------- Topbar ---------------- */
.p-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--p-card);
    border-bottom: 1px solid var(--p-border);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.p-topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
    height: 62px;
    display: flex;
    align-items: center;
    gap: 18px;
}

.p-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 16px;
    color: var(--p-text);
    white-space: nowrap;
}

.p-logo img { height: 34px; width: auto; }

.p-logo span b { color: var(--p-primary); font-weight: 700; }

.p-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 10px;
}

.p-nav a {
    padding: 8px 14px;
    border-radius: 10px;
    color: var(--p-muted);
    font-weight: 500;
    font-size: 14px;
    transition: all .15s ease;
}

.p-nav a:hover { color: var(--p-text); background: var(--p-bg); }

.p-nav a.active { color: var(--p-primary); background: var(--p-primary-soft); font-weight: 600; }

.p-topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.p-quota-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--p-primary-soft);
    color: var(--p-primary-dark);
    border: 1px solid #dbeafe;
    padding: 6px 13px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.p-quota-pill.empty { background: var(--p-danger-soft); color: var(--p-danger); border-color: #fecaca; }

.p-user {
    color: var(--p-muted);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.p-logout-btn {
    background: none;
    border: 1px solid var(--p-border);
    border-radius: 10px;
    padding: 7px 14px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--p-muted);
    cursor: pointer;
    transition: all .15s ease;
}

.p-logout-btn:hover { color: var(--p-danger); border-color: #fecaca; background: var(--p-danger-soft); }

/* ---------------- Kontejner ---------------- */
.p-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 28px 20px 80px;
}

.p-container-narrow { max-width: 860px; }

.p-page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}

.p-page-head h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -.02em;
}

.p-page-head .p-sub { color: var(--p-muted); font-size: 14px; margin-top: 3px; }

/* ---------------- Dugmad ---------------- */
.p-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 11px;
    padding: 11px 22px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s ease;
    line-height: 1.3;
}

.p-btn-primary { background: var(--p-primary); color: #fff; box-shadow: 0 2px 8px rgba(37, 99, 235, .3); }
.p-btn-primary:hover { background: var(--p-primary-dark); color: #fff; transform: translateY(-1px); }

.p-btn-secondary { background: var(--p-card); color: var(--p-text); border: 1px solid var(--p-border); }
.p-btn-secondary:hover { background: var(--p-bg); }

.p-btn-danger-ghost { background: none; color: var(--p-danger); border: 1px solid transparent; }
.p-btn-danger-ghost:hover { background: var(--p-danger-soft); border-color: #fecaca; }

.p-btn-sm { padding: 7px 14px; font-size: 13px; border-radius: 9px; }

.p-btn-lg { padding: 14px 30px; font-size: 15px; }

.p-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ---------------- Flash poruke ---------------- */
.p-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border-radius: var(--p-radius);
    padding: 13px 17px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 20px;
    border: 1px solid;
}

.p-alert-success { background: var(--p-success-soft); color: #166534; border-color: #bbf7d0; }
.p-alert-error { background: var(--p-danger-soft); color: #991b1b; border-color: #fecaca; }
.p-alert-warning { background: var(--p-warning-soft); color: #92400e; border-color: #fde68a; }

.p-alert ul { margin: 4px 0 0; padding-left: 18px; }

/* ---------------- Kartice / sekcije forme ---------------- */
.p-card-box {
    background: var(--p-card);
    border: 1px solid var(--p-border);
    border-radius: var(--p-radius);
    box-shadow: var(--p-shadow);
    padding: 24px;
    margin-bottom: 18px;
}

.p-section-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}

.p-section-num {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-radius: 9px;
    background: var(--p-primary-soft);
    color: var(--p-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.p-section-head h2 { margin: 0; font-size: 16.5px; font-weight: 600; }

.p-section-head .p-optional {
    margin-left: auto;
    font-size: 12px;
    color: var(--p-muted);
    background: var(--p-bg);
    padding: 3px 10px;
    border-radius: 999px;
    font-weight: 500;
}

.p-section-desc { color: var(--p-muted); font-size: 13.5px; margin: 0 0 16px 42px; }

/* ---------------- Forme ---------------- */
.p-field { margin-bottom: 16px; }
.p-field:last-child { margin-bottom: 0; }

.p-label {
    display: block;
    font-size: 13.5px;
    font-weight: 600;
    margin-bottom: 7px;
    color: var(--p-text);
}

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

.p-input, .p-textarea, .p-select {
    width: 100%;
    border: 1.5px solid var(--p-border);
    border-radius: 11px;
    padding: 11px 14px;
    font-family: inherit;
    font-size: 14.5px;
    color: var(--p-text);
    background: #fff;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.p-input:focus, .p-textarea:focus, .p-select:focus {
    border-color: var(--p-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.p-input.is-invalid { border-color: var(--p-danger); }

.p-hint { font-size: 12.5px; color: var(--p-muted); margin-top: 6px; }

.p-error-text { font-size: 12.5px; color: var(--p-danger); margin-top: 6px; font-weight: 500; }

.p-char-count { font-size: 12px; color: var(--p-muted); float: right; font-weight: 500; }
.p-char-count.limit { color: var(--p-danger); }

.p-row { display: flex; gap: 16px; flex-wrap: wrap; }
.p-row > .p-field { flex: 1; min-width: 220px; }

/* Cena input sa € sufiksom */
.p-price-wrap { position: relative; max-width: 260px; }
.p-price-wrap .p-input { padding-right: 44px; font-weight: 600; font-size: 16px; }
.p-price-wrap .p-price-cur {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--p-muted);
    font-weight: 600;
    pointer-events: none;
}

/* Checkbox / toggle red */
.p-check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: 1.5px solid var(--p-border);
    border-radius: 11px;
    cursor: pointer;
    transition: all .15s ease;
    font-size: 14px;
    font-weight: 500;
    user-select: none;
}

.p-check-row:hover { border-color: #cbd5e1; background: #f8fafc; }

.p-check-row input { width: 17px; height: 17px; accent-color: var(--p-primary); cursor: pointer; }

/* ---------------- Dropzone za fotografije ---------------- */
.p-dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: var(--p-radius);
    background: #f8fafc;
    padding: 34px 20px;
    text-align: center;
    cursor: pointer;
    transition: all .15s ease;
    margin-left: 42px;
}

.p-dropzone:hover, .p-dropzone.dragover {
    border-color: var(--p-primary);
    background: var(--p-primary-soft);
}

.p-dropzone .dz-icon { font-size: 34px; margin-bottom: 6px; }

.p-dropzone .dz-title { font-weight: 600; font-size: 14.5px; }
.p-dropzone .dz-title span { color: var(--p-primary); text-decoration: underline; }

.p-dropzone .dz-sub { color: var(--p-muted); font-size: 12.5px; margin-top: 4px; }

.p-photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
    margin: 14px 0 0 42px;
}

.p-photo-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    border: 1.5px solid var(--p-border);
    aspect-ratio: 4 / 3;
    background: #f8fafc;
}

.p-photo-item img { width: 100%; height: 100%; object-fit: cover; display: block; }

.p-photo-item .ph-main-badge {
    position: absolute;
    left: 7px;
    top: 7px;
    background: var(--p-primary);
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
    letter-spacing: .02em;
}

.p-photo-item .ph-remove {
    position: absolute;
    right: 7px;
    top: 7px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: rgba(15, 23, 42, .65);
    color: #fff;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s ease;
}

.p-photo-item .ph-remove:hover { background: var(--p-danger); }

.p-photo-item.marked-remove { opacity: .45; }
.p-photo-item.marked-remove::after {
    content: 'Biće uklonjena';
    position: absolute;
    inset: auto 0 0 0;
    background: var(--p-danger);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    padding: 3px 0;
}

.p-photos-counter { margin: 10px 0 0 42px; font-size: 12.5px; color: var(--p-muted); font-weight: 500; }

/* ---------------- Sticky action bar ---------------- */
.p-actionbar {
    position: sticky;
    bottom: 0;
    z-index: 40;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--p-border);
    margin: 24px -20px 0;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.p-actionbar .ab-note { font-size: 13px; color: var(--p-muted); }

/* ---------------- Kartice oglasa (Moji oglasi) ---------------- */
.p-ads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
    gap: 18px;
}

.p-ad-card {
    background: var(--p-card);
    border: 1px solid var(--p-border);
    border-radius: var(--p-radius);
    overflow: hidden;
    box-shadow: var(--p-shadow);
    display: flex;
    flex-direction: column;
    transition: transform .15s ease, box-shadow .15s ease;
}

.p-ad-card:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(15, 23, 42, .1); }

.p-ad-thumb {
    aspect-ratio: 4 / 3;
    background: #e2e8f0 url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="%2394a3b8" stroke-width="1.5"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><path d="m21 15-5-5L5 21"/></svg>') center / 44px no-repeat;
    position: relative;
    display: block;
}

.p-ad-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.p-ad-badges { position: absolute; left: 9px; top: 9px; display: flex; gap: 6px; flex-wrap: wrap; }

.p-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    letter-spacing: .02em;
}

.p-badge-live { background: var(--p-success); color: #fff; }
.p-badge-hidden { background: #475569; color: #fff; }
.p-badge-sold { background: var(--p-danger); color: #fff; }

.p-ad-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }

.p-ad-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--p-text);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 39px;
}

.p-ad-meta { display: flex; align-items: center; justify-content: space-between; }

.p-ad-price { font-size: 17px; font-weight: 700; color: var(--p-primary); }

.p-ad-views { font-size: 12.5px; color: var(--p-muted); }

.p-ad-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--p-bg);
}

.p-ad-actions form { flex: 1; display: flex; }

.p-ad-actions .p-btn { flex: 1; }

/* ---------------- Prazno stanje ---------------- */
.p-empty {
    text-align: center;
    padding: 70px 20px;
    background: var(--p-card);
    border: 1.5px dashed var(--p-border);
    border-radius: var(--p-radius);
}

.p-empty .e-icon { font-size: 46px; margin-bottom: 10px; }
.p-empty h3 { margin: 0 0 6px; font-size: 18px; font-weight: 600; }
.p-empty p { color: var(--p-muted); margin: 0 0 20px; font-size: 14px; }

/* ---------------- Kvota progres ---------------- */
.p-quota-box {
    background: var(--p-card);
    border: 1px solid var(--p-border);
    border-radius: var(--p-radius);
    box-shadow: var(--p-shadow);
    padding: 16px 20px;
    margin-bottom: 22px;
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.p-quota-box .q-text { font-size: 13.5px; color: var(--p-muted); }
.p-quota-box .q-text b { color: var(--p-text); }

.p-quota-track {
    flex: 1;
    min-width: 160px;
    height: 8px;
    border-radius: 999px;
    background: var(--p-bg);
    overflow: hidden;
}

.p-quota-fill { height: 100%; border-radius: 999px; background: var(--p-primary); transition: width .3s ease; }
.p-quota-fill.full { background: var(--p-danger); }

/* ---------------- Login stranica ---------------- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(160deg, #eff6ff 0%, #f1f5f9 45%, #e0e7ff 100%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--p-card);
    border: 1px solid var(--p-border);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(15, 23, 42, .1);
    padding: 38px 36px;
}

.login-logo { text-align: center; margin-bottom: 8px; }
.login-logo img { height: 44px; }

.login-card h1 {
    margin: 0 0 4px;
    font-size: 21px;
    font-weight: 700;
    text-align: center;
    letter-spacing: -.02em;
}

.login-card .login-sub {
    text-align: center;
    color: var(--p-muted);
    font-size: 13.5px;
    margin: 0 0 26px;
}

.login-footer { text-align: center; margin-top: 22px; font-size: 13px; color: var(--p-muted); }
.login-footer a { color: var(--p-primary); font-weight: 600; }

/* ---------------- Responsive ---------------- */
@media (max-width: 720px) {
    .p-topbar-inner { height: auto; padding: 10px 14px; flex-wrap: wrap; }
    .p-nav { order: 3; width: 100%; margin-left: 0; }
    .p-user { display: none; }
    .p-container { padding: 20px 14px 80px; }
    .p-section-desc, .p-dropzone, .p-photos-grid, .p-photos-counter { margin-left: 0; }
    .p-card-box { padding: 18px 16px; }
    .p-actionbar { margin: 24px -14px 0; padding: 12px 14px; }
    .login-card { padding: 30px 22px; }
}
