/* ==========================================================================
   PicVote – unified stylesheet
   ========================================================================== */

/* ── Shared variables ── */
:root {
    --pv-blue:       #2563eb;
    --pv-blue-dark:  #1d4ed8;
    --pv-blue-light: #eff6ff;
    --pv-green:      #059669;
    --pv-amber:      #d97706;
    --pv-red:        #dc2626;
    --pv-gray-50:    #f9fafb;
    --pv-gray-100:   #f3f4f6;
    --pv-gray-200:   #e5e7eb;
    --pv-gray-400:   #9ca3af;
    --pv-gray-500:   #6b7280;
    --pv-gray-700:   #374151;
    --pv-gray-900:   #111827;
    --pv-radius:     8px;
    --pv-shadow-sm:  0 1px 3px rgba(0,0,0,.07);
    --pv-shadow-md:  0 4px 14px rgba(0,0,0,.1);
    --pv-font:       -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Base reset scoped to our wrappers ── */
.picvote-admin-wrap *,
.picvote-form-wrap * {
    box-sizing: border-box;
}

/* ==========================================================================
   ADMIN SETTINGS  [picvote_settings]
   ========================================================================== */

.picvote-admin-wrap {
    max-width: 860px;
    font-family: var(--pv-font);
    margin: 0 auto;
    padding: 28px 0 48px;
    color: var(--pv-gray-900);
}

/* ── Tabs ── */
.picvote-tabs {
    display: flex;
    border-bottom: 2px solid var(--pv-gray-200);
    margin-bottom: 32px;
    gap: 4px;
}

.picvote-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 22px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    color: var(--pv-gray-500);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color .18s, border-color .18s;
    border-radius: var(--pv-radius) var(--pv-radius) 0 0;
}

.picvote-tab-btn:hover { color: var(--pv-gray-900); }
.picvote-tab-btn.active {
    color: var(--pv-blue);
    border-bottom-color: var(--pv-blue);
}

.picvote-tab-count {
    background: var(--pv-gray-200);
    color: var(--pv-gray-500);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    padding: 1px 7px;
    line-height: 1.6;
}
.picvote-tab-btn.active .picvote-tab-count {
    background: #dbeafe;
    color: var(--pv-blue);
}

.picvote-tab-panel { display: none; }
.picvote-tab-panel.active { display: block; }

/* ── Settings form ── */
.picvote-settings-row {
    display: grid;
    grid-template-columns: 1fr 160px;
    gap: 20px;
}

.picvote-field-group {
    margin-bottom: 22px;
}

.picvote-field-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--pv-gray-700);
    margin-bottom: 6px;
}

.picvote-field-hint {
    margin: -2px 0 8px;
    font-size: 13px;
    color: var(--pv-gray-400);
    line-height: 1.5;
}

.picvote-input {
    width: 100%;
    padding: 9px 13px;
    border: 1px solid var(--pv-gray-200);
    border-radius: 6px;
    font-size: 14px;
    color: var(--pv-gray-900);
    background: #fff;
    transition: border-color .18s, box-shadow .18s;
    font-family: var(--pv-font);
    line-height: 1.4;
}
.picvote-input:focus {
    outline: none;
    border-color: var(--pv-blue);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.picvote-input-sm { max-width: 100%; }

.picvote-form-footer {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-top: 22px;
    border-top: 1px solid var(--pv-gray-200);
    margin-top: 6px;
}

.picvote-save-status {
    font-size: 14px;
    font-weight: 600;
    color: var(--pv-green);
}
.picvote-save-status.pv-error { color: var(--pv-red); }

/* ── Photos tab ── */
.picvote-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 60px 24px;
    color: var(--pv-gray-400);
    text-align: center;
}
.picvote-empty-state p {
    font-size: 15px;
    margin: 0;
}

/* ── Photos toolbar ── */
.pv-photos-toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    align-items: center;
}

.pv-filter-input {
    flex: 1;
}

.pv-per-page-select {
    width: auto;
    flex-shrink: 0;
}

.pv-loading {
    padding: 40px;
    text-align: center;
    color: var(--pv-gray-400);
    font-size: 14px;
}

/* ── Entries grid ── */
.picvote-entries-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    gap: 20px;
}

/* ── Entry card ── */
.picvote-entry-card {
    border: 1px solid var(--pv-gray-200);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    box-shadow: var(--pv-shadow-sm);
}

.picvote-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--pv-gray-100);
}

.picvote-entry-name {
    display: block;
    font-size: 15px;
    color: var(--pv-gray-900);
    margin-bottom: 3px;
}

.picvote-entry-contact {
    font-size: 12px;
    color: var(--pv-gray-500);
}

.picvote-entry-aside {
    text-align: right;
    flex-shrink: 0;
}

.picvote-entry-date {
    font-size: 12px;
    color: var(--pv-gray-400);
    margin-bottom: 4px;
}

.picvote-photo-count {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    background: var(--pv-gray-100);
    color: var(--pv-gray-500);
    border-radius: 10px;
    padding: 2px 8px;
}

/* ── Photos grid inside card ── */
.picvote-entry-photos {
    display: grid;
    gap: 4px;
    padding: 4px;
    /* default: 3 columns */
    grid-template-columns: repeat(3, 1fr);
}

.picvote-entry-photos[data-count="1"] {
    grid-template-columns: 1fr;
}

.picvote-entry-photos[data-count="2"] {
    grid-template-columns: repeat(2, 1fr);
}

.picvote-entry-photo {
    position: relative;
    aspect-ratio: 16/10;
    overflow: hidden;
    border-radius: 5px;
    background: var(--pv-gray-100);
}

.picvote-entry-photo.picvote-portrait {
    outline: 2px solid var(--pv-amber);
}

.picvote-entry-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .25s;
    cursor: zoom-in;
}
.picvote-entry-photo:hover img {
    transform: scale(1.05);
}

/* ── Lightbox ── */
.pv-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0,0,0,.88);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5vh 5vw;
    animation: pvLbFade .2s ease both;
    cursor: zoom-out;
}

@keyframes pvLbFade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.pv-lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 24px 80px rgba(0,0,0,.7);
    animation: pvLbScale .22s ease both;
    cursor: default;
    display: block;
}

@keyframes pvLbScale {
    from { transform: scale(.93); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

.pv-lightbox-caption {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,.65);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    padding: 7px 18px;
    border-radius: 20px;
    white-space: nowrap;
    pointer-events: none;
}

.pv-lightbox-close {
    position: fixed;
    top: 18px;
    right: 22px;
    background: rgba(255,255,255,.15);
    border: none;
    color: #fff;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .18s;
}
.pv-lightbox-close:hover {
    background: rgba(255,255,255,.3);
}

.picvote-photo-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,.65) 0%, transparent 55%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 5px 6px;
    opacity: 0;
    transition: opacity .2s;
    pointer-events: none;
}
.picvote-entry-photo:hover .picvote-photo-overlay {
    opacity: 1;
}

.picvote-photo-title-label {
    font-size: 10px;
    color: #fff;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.picvote-portrait-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    background: var(--pv-amber);
    color: #fff;
    padding: 2px 5px;
    border-radius: 3px;
    margin-top: 3px;
    align-self: flex-start;
}

/* ==========================================================================
   SUBMISSION FORM  [picvote_submit]
   ========================================================================== */

.picvote-form-wrap {
    max-width: 660px;
    margin: 0 auto;
    font-family: var(--pv-font);
    padding-bottom: 60px;
}

.picvote-form-title {
    text-align: center;
    font-size: 28px;
    font-weight: 800;
    color: var(--pv-gray-900);
    margin: 0 0 30px;
    letter-spacing: -.3px;
}

/* ── Step indicator ── */
.picvote-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 36px;
}

.picvote-step {
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: .35;
    transition: opacity .3s;
}

.picvote-step.active { opacity: 1; }
.picvote-step.done   { opacity: .7; }

.picvote-step-num {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--pv-gray-200);
    color: var(--pv-gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    transition: background .3s, color .3s;
    flex-shrink: 0;
}

.picvote-step.active .picvote-step-num {
    background: var(--pv-blue);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(37,99,235,.2);
}
.picvote-step.done .picvote-step-num {
    background: var(--pv-green);
    color: #fff;
}

.picvote-step-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--pv-gray-700);
    white-space: nowrap;
}

.picvote-step-line {
    flex: 1;
    max-width: 60px;
    height: 2px;
    background: var(--pv-gray-200);
    margin: 0 10px;
}

/* ── Step panels ── */
.picvote-form-step {
    display: none;
    animation: pvFadeUp .28s ease both;
}
.picvote-form-step.active { display: block; }

@keyframes pvFadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Step 1 – description ── */
.picvote-description {
    background: var(--pv-gray-50);
    border: 1px solid var(--pv-gray-200);
    border-radius: 10px;
    padding: 24px 28px;
    margin-bottom: 28px;
    font-size: 15px;
    line-height: 1.75;
    color: var(--pv-gray-700);
}
.picvote-description p:last-child { margin-bottom: 0; }

/* ── Upload area ── */
.picvote-upload-area {
    border: 2px dashed var(--pv-gray-200);
    border-radius: 12px;
    padding: 44px 24px 36px;
    text-align: center;
    background: var(--pv-gray-50);
    cursor: pointer;
    transition: border-color .2s, background .2s;
    margin-bottom: 20px;
    user-select: none;
}

.picvote-upload-area:hover,
.picvote-upload-area.pv-drag-over {
    border-color: var(--pv-blue);
    background: var(--pv-blue-light);
}

.picvote-upload-area.pv-drag-over {
    box-shadow: 0 0 0 4px rgba(37,99,235,.15);
}

.picvote-upload-area.pv-max-reached {
    opacity: .45;
    cursor: not-allowed;
    pointer-events: none;
}

.picvote-upload-icon {
    color: var(--pv-gray-400);
    margin-bottom: 14px;
    transition: color .2s, transform .2s;
}
.picvote-upload-area:hover .picvote-upload-icon,
.picvote-upload-area.pv-drag-over .picvote-upload-icon {
    color: var(--pv-blue);
    transform: translateY(-3px);
}

.picvote-upload-headline {
    font-size: 16px;
    font-weight: 600;
    color: var(--pv-gray-700);
    margin: 0 0 8px;
}

.picvote-upload-browse {
    color: var(--pv-blue);
    text-decoration: underline;
    cursor: pointer;
    font-weight: 700;
}

.picvote-upload-hint {
    font-size: 13px;
    color: var(--pv-gray-400);
    margin: 0;
}

/* ── Upload list ── */
.picvote-upload-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
    min-height: 0;
}

/* ── Photo item ── */
.picvote-photo-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: #fff;
    border: 1px solid var(--pv-gray-200);
    border-radius: 10px;
    padding: 12px 12px 12px 14px;
    transition: border-color .18s, background .18s;
    animation: pvFadeUp .22s ease both;
}

.picvote-photo-item.pv-uploading {
    background: var(--pv-gray-50);
}

.picvote-photo-item.pv-portrait-warn {
    border-color: #fbbf24;
    background: #fffbeb;
}

/* thumbnail */
.picvote-thumb {
    width: 84px;
    height: 58px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    display: block;
    background: var(--pv-gray-100);
}

.picvote-thumb-placeholder {
    width: 84px;
    height: 58px;
    border-radius: 6px;
    flex-shrink: 0;
    background: var(--pv-gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--pv-gray-200);
}

/* photo info column */
.picvote-photo-body {
    flex: 1;
    min-width: 0;
}

.picvote-photo-filename {
    font-size: 12px;
    color: var(--pv-gray-400);
    margin-bottom: 7px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.picvote-title-input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--pv-gray-200);
    border-radius: 5px;
    font-size: 13px;
    font-family: var(--pv-font);
    color: var(--pv-gray-900);
    transition: border-color .18s, box-shadow .18s;
}
.picvote-title-input:focus {
    outline: none;
    border-color: var(--pv-blue);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.picvote-title-input.pv-err {
    border-color: var(--pv-red);
}

/* landscape warning */
.picvote-landscape-warn {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 7px;
    font-size: 12px;
    font-weight: 600;
    color: #92400e;
    line-height: 1.4;
}
.picvote-landscape-warn svg { flex-shrink: 0; }

/* upload progress bar */
.picvote-progress {
    height: 3px;
    background: var(--pv-gray-200);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}
.picvote-progress-bar {
    height: 100%;
    background: var(--pv-blue);
    border-radius: 3px;
    animation: pvProgressPulse 1.4s ease-in-out infinite;
}
@keyframes pvProgressPulse {
    0%   { width: 5%;  margin-left: 0; }
    50%  { width: 55%; margin-left: 20%; }
    100% { width: 5%;  margin-left: 95%; }
}

/* delete button */
.picvote-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--pv-gray-400);
    padding: 4px;
    border-radius: 5px;
    line-height: 0;
    flex-shrink: 0;
    transition: color .18s, background .18s;
    margin-top: 1px;
}
.picvote-delete-btn:hover {
    color: var(--pv-red);
    background: #fef2f2;
}
.picvote-delete-btn:disabled { opacity: .4; cursor: default; }

/* ── Step nav / buttons ── */
.picvote-step-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 22px;
    border-top: 1px solid var(--pv-gray-200);
    margin-top: 4px;
    gap: 12px;
}

.picvote-step-nav-right { justify-content: flex-end; }

/* ── Buttons ── */
.picvote-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    border-radius: 7px;
    font-size: 15px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: background .18s, transform .15s, box-shadow .18s, opacity .18s;
    line-height: 1;
    font-family: var(--pv-font);
}

.picvote-btn-primary {
    background: var(--pv-blue);
    color: #fff;
}
.picvote-btn-primary:hover:not(:disabled) {
    background: var(--pv-blue-dark);
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(37,99,235,.35);
}
.picvote-btn-primary:disabled {
    background: #93c5fd;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.picvote-btn-secondary {
    background: var(--pv-gray-100);
    color: var(--pv-gray-700);
}
.picvote-btn-secondary:hover {
    background: var(--pv-gray-200);
}

/* CSS arrows — avoids any font/encoding dependency */
.picvote-btn-next::after {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
    transform: rotate(45deg) translateY(-1px);
    margin-left: 4px;
    flex-shrink: 0;
}
.picvote-back-btn::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-top: 2px solid currentColor;
    border-left: 2px solid currentColor;
    transform: rotate(-45deg) translateY(-1px);
    margin-right: 4px;
    flex-shrink: 0;
}

/* ── Rules agreement ── */
.picvote-rules-check {
    margin: 20px 0 24px;
    padding: 16px 18px;
    background: var(--pv-gray-50);
    border: 1px solid var(--pv-gray-200);
    border-radius: 8px;
}

.picvote-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 15px;
    color: var(--pv-gray-700);
    font-weight: 500;
    user-select: none;
}

.picvote-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    accent-color: var(--pv-blue);
    cursor: pointer;
}

/* ── Step 3 fields ── */
.picvote-form-step .picvote-field-group { margin-bottom: 18px; }
.picvote-form-step .picvote-field-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--pv-gray-700);
    margin-bottom: 6px;
}

.picvote-req { color: var(--pv-red); }
.picvote-opt {
    font-size: 12px;
    color: var(--pv-gray-400);
    font-weight: 400;
    margin-left: 4px;
}

/* ── Error banner ── */
.picvote-form-error {
    padding: 12px 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    color: var(--pv-red);
    font-size: 14px;
    margin-bottom: 16px;
    font-weight: 500;
}

/* ── Success screen ── */
.picvote-success {
    text-align: center;
    padding: 56px 24px;
    animation: pvFadeUp .35s ease both;
}
.picvote-success-icon { color: var(--pv-green); margin-bottom: 18px; }
.picvote-success h3 {
    font-size: 26px;
    font-weight: 800;
    color: var(--pv-gray-900);
    margin: 0 0 12px;
}
.picvote-success p {
    font-size: 16px;
    color: var(--pv-gray-500);
    margin: 0;
}

.picvote-confirmation-msg {
    margin-top: 18px;
    padding: 20px 24px;
    background: var(--pv-gray-50);
    border: 1px solid var(--pv-gray-200);
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.7;
    color: var(--pv-gray-700);
    text-align: left;
}
.picvote-confirmation-msg p:last-child { margin-bottom: 0; }

/* ── Closed state ── */
.picvote-closed {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
    padding: 56px 24px;
    background: var(--pv-gray-50);
    border: 1px solid var(--pv-gray-200);
    border-radius: 12px;
    color: var(--pv-gray-500);
}
.picvote-closed h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--pv-gray-700);
    margin: 0;
}
.picvote-closed p { margin: 0; font-size: 15px; }

/* ── Generic error notice ── */
.picvote-error {
    padding: 12px 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    color: var(--pv-red);
    font-size: 14px;
}

/* ── Pagination ── */
.pv-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--pv-gray-200);
}

.pv-page-info {
    font-size: 14px;
    color: var(--pv-gray-500);
}

.pv-page-btns {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pv-page-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--pv-gray-700);
    white-space: nowrap;
}

/* ── Responsive ── */
@media (max-width: 520px) {
    .picvote-step-label { display: none; }
    .picvote-step-line  { max-width: 28px; }
    .picvote-settings-row { grid-template-columns: 1fr; }
    .picvote-entries-grid { grid-template-columns: 1fr; }
    .pv-photos-toolbar { flex-wrap: wrap; }
    .pv-pagination { flex-direction: column; align-items: flex-start; }
    .picvote-form-title { font-size: 22px; }
    .picvote-btn { padding: 9px 16px; font-size: 14px; }
}
