/* ==========================================
   AI Photo Editor — Auto-Detection Styles
   ========================================== */

/* AI Enhanced Badge — shows on photos that have been protected */
.ai-enhanced-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.5);
    z-index: 5;
    letter-spacing: 0.3px;
}

.ai-enhanced-badge i {
    font-size: 9px;
}

/* Botón "Proteger" manual sobre el thumbnail */
.protect-photo-btn {
    position: absolute;
    top: 6px;
    left: 6px;
    background: rgba(255,255,255,0.92);
    border: 1px solid #6366f1;
    color: #4f46e5;
    font-size: 10px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    letter-spacing: 0.3px;
    z-index: 5;
    transition: background .15s, color .15s, transform .15s;
    backdrop-filter: blur(4px);
}
.protect-photo-btn:hover {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    transform: translateY(-1px);
}
.protect-photo-btn i { font-size: 9px; }

/* ==========================================
   Plate Detection Notification Card
   ========================================== */

#plate-detection-container {
    margin-top: 12px;
}

.plate-detected-card {
    background: white;
    border: 2px solid #10b981;
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    gap: 14px;
    align-items: flex-start;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.15);
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.35s ease;
}

.plate-detected-card.plate-card-visible {
    opacity: 1;
    transform: translateY(0);
}

.plate-detected-card.plate-card-hiding {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
}

/* Icon */
.plate-card-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(16, 185, 129, 0.3);
}

/* Content */
.plate-card-content {
    flex: 1;
    min-width: 0;
}

.plate-card-title {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 4px;
}

.plate-card-subtitle {
    font-size: 13px;
    color: #666;
    line-height: 1.4;
    margin-bottom: 12px;
}

/* Before/After Preview */
.plate-card-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    background: #f8fafb;
    border-radius: 10px;
    padding: 10px;
}

.plate-preview-item {
    flex: 1;
    text-align: center;
}

.plate-preview-label {
    font-size: 11px;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.plate-preview-img {
    width: 100%;
    max-height: 120px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
}

.plate-preview-item:last-child .plate-preview-img {
    border-color: #10b981;
}

.plate-preview-arrow {
    color: #10b981;
    font-size: 18px;
    flex-shrink: 0;
}

/* Modal SweetAlert para detección de matrículas */
.plate-modal-popup { padding: 18px 22px 26px !important; }
.plate-modal-popup .swal2-title { font-size: 20px !important; padding-bottom: 6px !important; }
.plate-modal-body { text-align: left; }
.plate-modal-subtitle {
    font-size: 14px;
    color: #475569;
    margin: 0 0 18px;
    line-height: 1.45;
}

/* Modal v2 layout */
.plate-modal-popup-v2 .swal2-html-container { margin: 0 !important; padding: 0 !important; }
.plate-modal-popup-v2 .plate-modal-body { padding: 4px 4px 8px; }

.plate-summary-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}
.plate-summary-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 12px;
}
.plate-summary-icon {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #0ea5e9, #6366f1);
    color: #fff; border-radius: 9px; font-size: 16px;
    flex-shrink: 0;
}
.plate-summary-text { display: flex; flex-direction: column; min-width: 0; flex: 1; text-align: left; }
.plate-summary-title { font-size: 16px; font-weight: 700; color: #0f172a; line-height: 1.1; }
.plate-summary-sub { font-size: 11px; color: #64748b; text-transform: uppercase; letter-spacing: .4px; margin-top: 2px; }

.plate-summary-price .plate-summary-icon { background: linear-gradient(135deg, #16a34a, #22c55e); }
.plate-summary-balance .plate-summary-icon { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.plate-summary-balance.plate-balance-low .plate-summary-icon { background: linear-gradient(135deg, #dc2626, #f87171); }
.plate-summary-balance.plate-balance-low .plate-summary-sub { color: #dc2626; font-weight: 700; }

.plate-price-line { display: flex; align-items: baseline; gap: 8px; }
.plate-price-original { color: #94a3b8; font-size: 13px; text-decoration: line-through; }
.plate-price-final { color: #16a34a; font-size: 18px; font-weight: 800; }
.plate-price-badge-inline {
    margin-top: 2px;
    display: inline-block;
    background: #fef3c7; color: #b45309;
    font-size: 10px; font-weight: 700;
    padding: 2px 6px; border-radius: 999px;
    text-transform: uppercase; letter-spacing: .4px;
    width: fit-content;
}

/* Action area buttons */
.plate-action-area {
    display: flex; gap: 10px; justify-content: flex-end;
    margin-top: 16px;
    flex-wrap: wrap;
    align-items: center;
}
.plate-action-msg {
    flex: 1 1 100%;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 4px;
}
.plate-btn {
    border: 0; cursor: pointer;
    padding: 10px 18px;
    font-size: 14px; font-weight: 700;
    border-radius: 8px;
    display: inline-flex; align-items: center; gap: 6px;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.plate-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.plate-btn-primary { background: #16a34a; color: #fff; }
.plate-btn-primary:hover { background: #15803d; }
.plate-btn-secondary { background: #f1f5f9; color: #475569; }
.plate-btn-secondary:hover { background: #e2e8f0; }
.plate-btn-recharge { background: linear-gradient(135deg, #f59e0b, #fbbf24); color: #fff; }
.plate-btn-recharge:hover { background: linear-gradient(135deg, #d97706, #f59e0b); }

@media (max-width: 640px) {
    .plate-summary-row { grid-template-columns: 1fr; }
}

/* Bloque precio con descuento (legacy) */
.plate-price-block {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
    flex-wrap: wrap;
}
.plate-price-original {
    color: #94a3b8;
    font-size: 16px;
    text-decoration: line-through;
}
.plate-price-final {
    color: #16a34a;
    font-size: 22px;
    font-weight: 800;
}
.plate-price-badge {
    background: #fef3c7;
    color: #b45309;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* Grid multi-foto */
.plate-batch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 4px;
}
.plate-batch-item {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px;
    background: #fafbfc;
}
.plate-batch-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 6px;
}
.plate-batch-remove {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: #475569;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background .15s, color .15s, border-color .15s;
}
.plate-batch-remove:hover {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca;
}

.plate-balance-recharge-link {
    background: transparent;
    border: 1px solid #f59e0b;
    color: #b45309;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 999px;
    margin-top: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    width: fit-content;
    transition: background .15s, color .15s;
}
.plate-balance-recharge-link:hover {
    background: #f59e0b;
    color: #fff;
}

.plate-action-msg-info {
    flex: 1 1 100%;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    color: #075985;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 4px;
}

/* ====== Topup Modal (recarga in-modal) ====== */
.topup-modal-popup .swal2-title { font-size: 20px !important; }
.topup-modal-body { text-align: left; padding: 4px; }

.topup-header {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
    color: #fff;
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 14px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 14px rgba(99,102,241,0.25);
}
.topup-header i { font-size: 22px; color: #fbbf24; }

.topup-packages-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}
@media (max-width: 640px) {
    .topup-packages-grid { grid-template-columns: 1fr; }
}

.topup-pkg {
    position: relative;
    background: #fff;
    border: 2px solid #e5e7eb;
    border-radius: 14px;
    padding: 18px 12px 14px;
    text-align: center;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .2s ease, border-color .15s ease;
    overflow: visible;
}
.topup-pkg:hover {
    transform: translateY(-3px);
    border-color: #cbd5e1;
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}
.topup-pkg.selected {
    border-color: #6366f1;
    background: linear-gradient(180deg, #f5f3ff 0%, #fff 100%);
    box-shadow: 0 10px 24px rgba(99,102,241,0.18);
}
.topup-pkg.selected::after {
    content: '✓';
    position: absolute;
    top: 8px; right: 10px;
    background: #6366f1;
    color: #fff;
    width: 22px; height: 22px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px;
}

.topup-pkg-tag {
    position: absolute;
    top: -10px; left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: .8px;
    white-space: nowrap;
    box-shadow: 0 3px 8px rgba(239,68,68,0.35);
}
.topup-pkg.topup-pkg-best .topup-pkg-tag {
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 3px 8px rgba(16,185,129,0.35);
}

.topup-pkg-amount {
    font-size: 28px;
    font-weight: 800;
    color: #0f172a;
    line-height: 1;
}
.topup-pkg-bonus {
    background: linear-gradient(135deg, #10b981, #22c55e);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    display: inline-block;
    margin: 8px 0 4px;
    box-shadow: 0 2px 6px rgba(16,185,129,0.3);
}
.topup-pkg-total {
    font-size: 12px;
    color: #475569;
    margin-top: 4px;
}
.topup-pkg-total strong { color: #16a34a; font-size: 14px; }
.topup-pkg-pct {
    margin-top: 4px;
    font-size: 10px;
    color: #6366f1;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
}

.topup-payment-section {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 14px;
}
.topup-card-label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #475569;
    margin-bottom: 8px;
}
.topup-card-element {
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 12px;
}
.topup-card-errors {
    color: #dc2626;
    font-size: 12px;
    margin-top: 8px;
    min-height: 16px;
}

/* Promo code in topup modal */
.topup-promo-section { margin-bottom: 14px; }
.topup-promo-toggle {
    background: transparent;
    border: 1px dashed #cbd5e1;
    color: #6366f1;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background .15s, border-color .15s;
}
.topup-promo-toggle:hover { background: #f5f3ff; border-color: #6366f1; }
.topup-promo-form {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
    align-items: center;
}
.topup-promo-form input {
    flex: 1;
    min-width: 200px;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.topup-promo-form input:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.plate-btn-promo {
    background: linear-gradient(135deg, #16a34a, #22c55e);
    color: #fff;
    padding: 10px 16px;
    font-size: 14px;
}
.plate-btn-promo:hover { background: linear-gradient(135deg, #15803d, #16a34a); }
.plate-btn-promo:disabled { opacity: 0.7; cursor: not-allowed; }
.topup-promo-msg {
    flex: 1 1 100%;
    font-size: 12.5px;
    margin-top: 4px;
    min-height: 16px;
}
.topup-promo-ok { color: #16a34a; font-weight: 600; }
.topup-promo-err { color: #dc2626; font-weight: 600; }

.topup-actions { display: flex; justify-content: flex-end; gap: 10px; }
.plate-btn-pay {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    padding: 12px 22px;
    font-size: 15px;
}
.plate-btn-pay:hover { background: linear-gradient(135deg, #4f46e5, #7c3aed); }
.plate-btn-pay:disabled { opacity: 0.7; cursor: not-allowed; }

.plate-recharge-toast {
    background: #ecfeff;
    border: 1px solid #a5f3fc;
    color: #0e7490;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 12.5px;
    margin: 10px 0 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.plate-edit-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ecfeff;
    border: 1px solid #a5f3fc;
    color: #0e7490;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12.5px;
    margin-bottom: 10px;
}
.plate-edit-hint i { font-size: 14px; }

.plate-thumb-editable {
    cursor: move;
    pointer-events: auto !important;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.plate-batch-label {
    font-size: 12px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 8px;
    text-align: center;
}

/* Layout dual: thumbnail con bbox + zoom blur */
.plate-preview-zoom {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
}
.plate-zoom-thumb,
.plate-zoom-detail { flex: 0 1 auto; text-align: center; }

.plate-thumb-wrap,
.plate-detail-wrap {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #f8fafb;
    border: 1px solid #e5e7eb;
    padding: 4px;
}

.plate-thumb-canvas,
.plate-zoom-canvas {
    display: block;
    max-width: 100%;
    border-radius: 4px;
    -webkit-user-drag: none;
    user-select: none;
}
.plate-thumb-canvas.plate-thumb-editable {
    pointer-events: auto !important;
    touch-action: none;
    cursor: move;
}
.plate-zoom-canvas {
    pointer-events: none;
}

/* Mobile: stack vertical + thumb mucho más grande para edición táctil */
@media (max-width: 640px) {
    .plate-preview-zoom {
        flex-direction: column;
        gap: 10px;
    }
    .plate-zoom-thumb, .plate-zoom-detail { width: 100%; }
    .plate-thumb-wrap { padding: 6px; }
    .plate-thumb-canvas { width: 100% !important; height: auto !important; }
    .plate-zoom-canvas { width: 100%; height: auto; }
}

/* Controles ajuste fine (botones flechas en móvil) */
.plate-bbox-nudge {
    display: none;
    gap: 8px;
    justify-content: center;
    margin-top: 8px;
    flex-wrap: wrap;
}
@media (max-width: 640px) {
    .plate-bbox-nudge { display: flex; }
}
.plate-nudge-btn {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #475569;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}
.plate-nudge-btn:active { background: #cbd5e1; transform: scale(0.95); }
.plate-nudge-row { display: flex; gap: 6px; align-items: center; }
.plate-nudge-label { font-size: 11px; color: #64748b; font-weight: 600; margin-right: 4px; }

.plate-zoom-detail .plate-detail-wrap { border-color: #10b981; }

/* Action Buttons */
.plate-card-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.plate-btn-apply {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.25s ease;
    font-family: inherit;
    box-shadow: 0 3px 12px rgba(16, 185, 129, 0.3);
}

.plate-btn-apply:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 5px 18px rgba(16, 185, 129, 0.4);
}

.plate-btn-apply:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.plate-btn-dismiss {
    background: transparent;
    color: #999;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.plate-btn-dismiss:hover {
    background: #f5f5f5;
    color: #666;
    border-color: #ccc;
}

/* ==========================================
   Mobile Responsive
   ========================================== */

@media (max-width: 768px) {
    .plate-detected-card {
        flex-direction: column;
        padding: 14px;
        gap: 10px;
    }

    .plate-card-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
        border-radius: 10px;
    }

    .plate-card-title {
        font-size: 14px;
    }

    .plate-card-subtitle {
        font-size: 12px;
    }

    .plate-card-preview {
        gap: 6px;
        padding: 8px;
    }

    .plate-preview-img {
        max-height: 80px;
    }

    .plate-card-actions {
        flex-direction: column;
    }

    .plate-btn-apply,
    .plate-btn-dismiss {
        width: 100%;
        justify-content: center;
        text-align: center;
    }
}
