/* ============================================================
   Photo Print — Frontend Styles v2
   ============================================================ */

/* ---- Upload button on product page ---- */
.ppp-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 13px 28px !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    letter-spacing: .02em;
    cursor: pointer;
}
.ppp-upload-btn svg { width: 20px; height: 20px; flex-shrink: 0; }

/* ---- Summary panel (post-finalize) ---- */
.ppp-summary-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
    padding: 16px 20px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 0;
    margin-top: 16px;
}
.ppp-summary-stats {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 14px;
    color: #555;
}
.ppp-summary-stat strong { color: #1e1e1e; font-size: 16px; }
.ppp-summary-sep { color: #ccc; }
.ppp-summary-price { font-weight: 600; }
.ppp-summary-actions { display: flex; gap: 10px; }
.ppp-btn-secondary { background: #fff !important; border: 1px solid #ddd !important; color: #333 !important; }
.ppp-add-to-cart { min-width: 160px; }
.ppp-error { color: #c0392b; font-size: 13px; margin-top: 8px; }

/* ---- Price display ---- */
.ppp-from-price small { font-size: 0.75em; color: #888; }

/* ============================================================
   MODAL OVERLAY
   ============================================================ */
.ppp-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 0;
    overflow: hidden;
}

.ppp-modal {
    background: #fff;
    width: 100%;
    max-width: 1200px;
    margin: 20px auto;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    max-height: calc(100vh - 40px);
}

/* Header */
.ppp-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}
.ppp-modal-title {
    font-size: 17px;
    font-weight: 700;
    margin: 0;
    color: #1e1e1e;
}
.ppp-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: #666;
    border-radius: 0;
    transition: background .15s;
    display: flex;
    align-items: center;
}
.ppp-modal-close:hover { background: #f0f0f0; color: #111; }
.ppp-modal-close svg { width: 22px; height: 22px; }

/* Body: two panes */
.ppp-modal-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ---- LEFT PANE ---- */
.ppp-pane-left {
    width: 300px;
    flex-shrink: 0;
    border-right: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
    padding: 20px;
    background: #fafafa;
}

/* Drop zone */
.ppp-dropzone {
    border: 2px dashed #ccc;
    border-radius: 0;
    background: #fff;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    outline: none;
    flex-shrink: 0;
}
.ppp-dropzone:hover,
.ppp-dropzone:focus,
.ppp-dropzone.ppp-drag-over {
    border-color: #f5a623;
    background: #fffbf3;
}
.ppp-dropzone-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 16px;
    text-align: center;
    gap: 6px;
}
.ppp-dropzone-inner svg { width: 52px; height: 52px; color: #bbb; }
.ppp-dropzone-title { margin: 0; font-size: 14px; font-weight: 700; color: #333; }
.ppp-dropzone-sub   { margin: 0; font-size: 13px; color: #666; }
.ppp-dropzone-hint  { font-size: 11px; color: #aaa; }

/* Upload progress (global) */
#ppp-upload-progress { padding: 12px 0 0; }
.ppp-progress-track {
    height: 5px;
    background: #e8e8e8;
    border-radius: 0;
    overflow: hidden;
}
.ppp-progress-fill {
    height: 100%;
    background: #f5a623;
    width: 0%;
    transition: width .3s ease;
}
.ppp-progress-text { font-size: 12px; color: #777; margin-top: 5px; display: block; }

/* Global settings */
#ppp-global-settings {
    padding-top: 18px;
    border-top: 1px solid #eee;
    margin-top: 18px;
}
.ppp-global-title {
    font-size: 13px;
    font-weight: 700;
    color: #333;
    margin: 0 0 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.ppp-global-field {
    margin-bottom: 10px;
}
.ppp-global-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    margin-bottom: 4px;
}
.ppp-global-select {
    width: 100%;
    font-size: 13px;
    border-radius: 0;
}
.ppp-apply-all-btn {
    width: 100%;
    margin-top: 6px;
    font-size: 13px !important;
    padding-top: 12px !important;
    padding-bottom: 12px !important;
    border-radius: 0 !important;
}

/* Qty control */
.ppp-qty-control {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid #ddd;
    border-radius: 0;
    overflow: hidden;
    width: fit-content;
}
.ppp-qty-btn {
    background: #f5f5f5;
    border: none;
    width: 30px;
    height: 30px;
    font-size: 16px;
    cursor: pointer;
    transition: background .15s;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
    border-radius: 0;
}
.ppp-qty-btn:hover { background: #e8e8e8; }
.ppp-qty-btn:active { background: #ddd; }
.ppp-qty-control input[type="number"] {
    width: 48px;
    text-align: center;
    border: none;
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
    border-radius: 0;
    height: 30px;
    font-size: 13px;
    padding: 0;
    -moz-appearance: textfield;
    margin: 0;
}
.ppp-qty-control input[type="number"]::-webkit-outer-spin-button,
.ppp-qty-control input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }

/* ---- RIGHT PANE ---- */
.ppp-pane-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.ppp-pane-right-header {
    padding: 10px 18px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
    color: #666;
    flex-shrink: 0;
}

/* Empty state */
.ppp-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #bbb;
    text-align: center;
    gap: 12px;
    padding: 40px;
}
.ppp-empty-state svg { width: 64px; height: 64px; }
.ppp-empty-state p { font-size: 14px; margin: 0; }

/* Photo grid */
.ppp-photo-grid {
    display: grid;
    grid-template-columns: repeat( auto-fill, minmax(190px, 1fr) );
    gap: 14px;
    padding: 16px;
    overflow-y: auto;
    flex: 1;
    align-content: start;
}

/* Photo card */
.ppp-photo-card {
    border: 1px solid #e4e4e4;
    border-radius: 0;
    background: #fff;
    overflow: hidden;
    transition: box-shadow .15s;
    display: flex;
    flex-direction: column;
}
.ppp-photo-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.1); }

/* Thumb */
.ppp-card-thumb-wrap {
    position: relative;
    width: 100%;
    padding-top: 75%;
    background: #f0f0f0;
    overflow: hidden;
    flex-shrink: 0;
}
.ppp-card-thumb {
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center center;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
}
.ppp-card-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: #e0e0e0;
}
.ppp-card-progress-fill {
    height: 100%;
    background: #f5a623;
    width: 0%;
    transition: width .2s;
}
.ppp-card-status {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.7);
}
.ppp-card-status svg { width: 32px; height: 32px; }
.ppp-card-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    border-radius: 0;
    background: rgba(0,0,0,.55);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background .15s;
    z-index: 4; /* above the edit hover overlay (z-index:3) */
}
.ppp-card-remove:hover { background: #c0392b; }

/* Card body */
.ppp-card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.ppp-card-filename {
    font-size: 11px;
    color: #999;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ppp-card-error { font-size: 11px; color: #c0392b; }
.ppp-card-field label {
    font-size: 11px;
    font-weight: 600;
    color: #666;
    display: block;
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.ppp-card-select { width: 100%; font-size: 13px; border-radius: 0; }
.ppp-card-select:disabled,
.ppp-global-select:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background-color: #f5f5f5;
    color: #999;
}
.ppp-card-body .ppp-qty-control input { width: 48px; }
.ppp-card-body .ppp-qty-btn { width: 30px; height: 30px; font-size: 16px; }
.ppp-card-price {
    font-size: 13px;
    font-weight: 700;
    color: #f5a623;
    text-align: right;
    margin-top: 2px;
}

/* ---- FOOTER ---- */
.ppp-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 22px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
    gap: 16px;
    flex-wrap: wrap;
    background: #fafafa;
}
.ppp-footer-stats {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #555;
    flex-wrap: wrap;
}
.ppp-footer-stats strong { color: #1e1e1e; }
.ppp-footer-sep { color: #ccc; }
.ppp-finalize-btn {
    min-width: 200px;
    font-size: 14px !important;
    font-weight: 700 !important;
    padding-top: 13px !important;
    padding-bottom: 13px !important;
    border-radius: 0 !important;
}
.ppp-finalize-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Spinner */
.ppp-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(0,0,0,.15);
    border-top-color: #f5a623;
    border-radius: 50%;
    animation: ppp-spin .7s linear infinite;
}
@keyframes ppp-spin { to { transform: rotate(360deg); } }

/* Notice */
.ppp-notice { color: #777; font-style: italic; }

/* ============================================================
   Aspect / Polaroid overlays
   ============================================================ */

/* Shared diagonal-stripe pattern used for both Umplere and Potrivire */
.ppp-stripe {
    background: repeating-linear-gradient(
        -45deg,
        rgba(0, 0, 0, 0.62) 0px,
        rgba(0, 0, 0, 0.62) 3px,
        rgba(255, 255, 255, 0.18) 3px,
        rgba(255, 255, 255, 0.18) 9px
    );
}

/* --- Umplere (fill/crop) overlay --- */
.ppp-crop-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}
.ppp-crop-top,
.ppp-crop-bottom {
    position: absolute;
    left: 0;
    right: 0;
}
.ppp-crop-top    { top: 0; }
.ppp-crop-bottom { bottom: 0; }
.ppp-crop-left,
.ppp-crop-right  { position: absolute; }
.ppp-crop-left   { left: 0; }
.ppp-crop-right  { right: 0; }
/* Stripe pattern applied by JS via addClass */
.ppp-crop-top,
.ppp-crop-bottom,
.ppp-crop-left,
.ppp-crop-right {
    background: repeating-linear-gradient(
        -45deg,
        rgba(0, 0, 0, 0.62) 0px,
        rgba(0, 0, 0, 0.62) 3px,
        rgba(255, 255, 255, 0.18) 3px,
        rgba(255, 255, 255, 0.18) 9px
    );
}

/* --- Umplere (fill) — top-aligned so the subject at the top stays in frame --- */
.ppp-thumb-umplere .ppp-card-thumb {
    object-fit: cover !important;
    object-position: center top !important;
}

/* --- Polaroid — CSS-only frame: image repositioned inside the frame ---
   The wrapper background (warm off-white) becomes visible as the polaroid border.
   No overlay divs needed.
----------------------------------------------------------------- */
.ppp-thumb-polaroid {
    background: #f8f4ef;
    /* Subtle outer shadow gives depth like a real print */
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12);
}
/* Reposition image inside the polaroid frame area */
.ppp-thumb-polaroid .ppp-card-thumb {
    top:    7% !important;
    left:   7% !important;
    right:  auto !important;
    bottom: auto !important;
    width:  86% !important;   /* 100% − 7% left − 7% right */
    height: 70% !important;   /* 100% − 7% top − 23% bottom */
    object-fit: cover !important;
    object-position: center center !important;
}
/* Subtle 1px border around the inner photo area */
.ppp-thumb-polaroid::before {
    content: '';
    position: absolute;
    top: 7%;
    left: 7%;
    width: 86%;
    height: 70%;
    border: 1px solid rgba(160, 160, 160, 0.45);
    pointer-events: none;
    z-index: 5;
    box-sizing: border-box;
}
/* Thin rule between photo area and bottom tab */
.ppp-thumb-polaroid::after {
    content: '';
    position: absolute;
    bottom: 23%;
    left: 7%;
    right: 7%;
    height: 1px;
    background: rgba(0,0,0,0.08);
    pointer-events: none;
    z-index: 4;
}

/* Polaroid overlay divs kept in DOM but unused (hidden by default) */
.ppp-polaroid-overlay { display: none !important; }

/* --- Upload tip --- */
.ppp-upload-tip {
    font-size: 12px;
    color: #777;
    margin: 0 0 14px;
    padding: 7px 10px;
    background: #f9f5ee;
    border-left: 3px solid #f5a623;
    font-style: italic;
    line-height: 1.45;
}

/* --- Card hover edit overlay --- */
.ppp-card-edit-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    opacity: 0;
    transition: opacity .18s;
    cursor: pointer;
    z-index: 3;
    color: #fff;
}
.ppp-card-thumb-wrap:hover .ppp-card-edit-overlay {
    opacity: 1;
}
/* Thumb wrap is the click target — always show pointer */
.ppp-card-thumb-wrap { cursor: pointer; }
.ppp-card-edit-overlay svg {
    width: 22px;
    height: 22px;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,.45));
}
.ppp-card-edit-overlay span {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    text-shadow: 0 1px 3px rgba(0,0,0,.5);
}

/* --- Collapsible card controls --- */
.ppp-card-controls {
    border-top: 1px solid #f0f0f0;
    margin-top: 6px;
    padding-top: 6px;
}

/* --- Active (expanded) card — spans full grid width, thumbnail left + controls right --- */
.ppp-photo-card.ppp-card-active {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: flex-start;
    box-shadow: 0 4px 18px rgba(0,0,0,.12);
    border-color: #f5a623;
    overflow: visible;
}
.ppp-photo-card.ppp-card-active .ppp-card-thumb-wrap {
    width: 220px;
    min-width: 220px;
    flex-shrink: 0;
    padding-top: 0;
    height: 165px; /* definite height — inset:0 children fill this reliably */
}
.ppp-photo-card.ppp-card-active .ppp-card-body {
    flex: 1;
    min-width: 0;
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 0;
}
.ppp-photo-card.ppp-card-active .ppp-card-controls {
    display: flex !important;
    flex-wrap: wrap;
    gap: 8px 16px;
    border-top: none;
    margin-top: 6px;
    padding-top: 0;
}
.ppp-photo-card.ppp-card-active .ppp-card-field {
    flex: 1 1 130px;
    min-width: 110px;
}
.ppp-photo-card.ppp-card-active .ppp-card-field--polaroid {
    flex-basis: 100%;
}
.ppp-photo-card.ppp-card-active .ppp-card-price {
    margin-top: auto;
    padding-top: 10px;
    font-size: 15px;
}

/* Mobile: active card stacks vertically */
@media (max-width: 600px) {
    .ppp-photo-card.ppp-card-active {
        flex-direction: column;
        align-items: stretch;
    }
    .ppp-photo-card.ppp-card-active .ppp-card-thumb-wrap {
        width: 100%;
        min-width: 0;
        height: auto;
        padding-top: 75%; /* restore aspect-ratio trick on mobile */
    }
}

/* --- Checkbox labels (aspect / polaroid) --- */
.ppp-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin: 0;
}
.ppp-checkbox-label input[type="checkbox"] {
    width: 15px;
    height: 15px;
    cursor: pointer;
    flex-shrink: 0;
}
.ppp-polaroid-hint {
    font-size: 11px;
    color: #f5a623;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
}
.ppp-global-field--polaroid { margin-top: 4px; }
.ppp-card-field--polaroid   { margin-top: 2px; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .ppp-modal { margin: 0; border-radius: 0; max-height: 100vh; max-height: 100dvh; }
    .ppp-modal-body { flex-direction: column; }
    .ppp-pane-left {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #eee;
        max-height: 320px;
        padding: 12px;
    }
    .ppp-dropzone-inner { padding: 14px 12px; }
    .ppp-dropzone-inner svg { width: 36px; height: 36px; }
    .ppp-global-title { margin-bottom: 8px; }
    .ppp-global-field { margin-bottom: 8px; }
    .ppp-modal-header { padding: 12px 16px; }
    .ppp-modal-title { font-size: 15px; }
    .ppp-photo-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 10px;
    }
    /* Larger touch targets for qty buttons on mobile */
    .ppp-qty-btn {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
    .ppp-qty-control input[type="number"] {
        width: 52px;
        height: 44px;
        font-size: 15px;
    }
    .ppp-card-body .ppp-qty-btn { width: 36px; height: 36px; }
    .ppp-card-body .ppp-qty-control input[type="number"] { height: 36px; }
    /* Card selects slightly larger for touch */
    .ppp-card-select,
    .ppp-global-select { font-size: 14px; padding: 4px 2px; min-height: 34px; }
    .ppp-modal-footer {
        padding: 10px 14px;
        flex-wrap: wrap;
        gap: 10px;
    }
    .ppp-footer-stats { font-size: 13px; }
    .ppp-finalize-btn {
        min-width: 0;
        width: 100%;
        text-align: center;
    }
    .ppp-summary-inner { flex-direction: column; align-items: flex-start; }
    .ppp-summary-actions { width: 100%; }
    .ppp-summary-actions .button { flex: 1; text-align: center; }
    /* Polaroid hint wraps cleanly */
    .ppp-checkbox-label { flex-wrap: wrap; gap: 4px; }
    .ppp-polaroid-hint { flex-basis: 100%; padding-left: 21px; }
    /* Apply-all button full-width on mobile */
    .ppp-apply-all-btn { font-size: 14px !important; }
    /* Remove button accessible size */
    .ppp-card-remove { width: 32px; height: 32px; font-size: 18px; }
}
@media (max-width: 420px) {
    .ppp-photo-grid { grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px; }
    .ppp-card-body { padding: 8px 10px 10px; gap: 6px; }
    .ppp-pane-left { max-height: 280px; }
    /* Single-column grid for very small screens */
    .ppp-photo-grid { grid-template-columns: 1fr; }
}
