/* ============================================================
   EasyPost — Order Meta Box Panel  (v2 compact redesign)
   ============================================================ */
:root {
    --ep-purple:  #1d6ff3;
    --ep-purple-l:#eff5ff;
    --ep-green:   #2ecc71;
    --ep-red:     #e74c3c;
    --ep-orange:  #e67e22;
    --ep-border:  #e5e5e5;
    --ep-bg:      #f9f9f9;
    --ep-r:       5px;
    --ep-text:    #333;
    --ep-muted:   #888;
}

#tfsep-order-panel {
    font-size: 12px;
    position: relative;
    padding: 0;
    color: var(--ep-text);
}

/* ── Header bar: status + carrier summary ─────────────── */
.tfsep-header-bar {
    padding: 10px 0 10px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.tfsep-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: 3px 9px;
    border-radius: 20px;
    background: #f0f0f0;
    width: fit-content;
}
.tfsep-dot { width: 6px; height: 6px; border-radius: 50%; background: #ccc; display: inline-block; flex-shrink: 0; }
.tfsep-status-purchased .tfsep-dot,
.tfsep-status-delivered  .tfsep-dot { background: var(--ep-green); }
.tfsep-status-purchased { background: #edfaf3; color: #1a7a4a; }
.tfsep-status-delivered  { background: #edfaf3; color: #1a7a4a; }
.tfsep-status-refunded  .tfsep-dot  { background: var(--ep-red); }
.tfsep-status-refunded              { background: #fdf0ee; color: #a82020; }
.tfsep-status-pending   .tfsep-dot  { background: var(--ep-orange); }
.tfsep-status-pending               { background: #fef8ed; color: #8a5500; }
.tfsep-box-pill {
    background: rgba(0,0,0,.1);
    padding: 0 5px;
    border-radius: 10px;
    font-size: 9px;
    margin-left: 2px;
}

/* Compact single-row: carrier badge + service + cost */
.tfsep-shipment-line {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}
.tfsep-carrier-badge {
    background: var(--ep-purple);
    color: #fff;
    padding: 2px 7px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}
.tfsep-service-txt {
    font-size: 12px;
    font-weight: 600;
    color: var(--ep-text);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tfsep-cost-txt {
    font-size: 13px;
    font-weight: 700;
    color: var(--ep-purple);
    white-space: nowrap;
    margin-left: auto;
}

/* ── Section dividers ─────────────────────────────────── */
.tfsep-section {
    padding: 9px 0;
    border-top: 1px solid var(--ep-border);
}
.tfsep-section-danger { border-top-color: #fce8e8; }

.tfsep-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--ep-muted);
    margin-bottom: 7px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.tfsep-section-label .tfsep-packing-method-badge {
    margin-left: 4px;
}
.tfsep-section-label .tfsep-packing-count {
    margin-left: auto;
    font-size: 9px;
    font-weight: 600;
    color: #aaa;
}

/* ── Buttons ──────────────────────────────────────────── */
.tfsep-btn-row {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}
.tfsep-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    padding: 5px 9px !important;
    font-size: 11px !important;
    border-radius: var(--ep-r) !important;
    border: 1px solid var(--ep-border) !important;
    background: #fff !important;
    color: #444 !important;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
    font-weight: 500 !important;
    height: auto !important;
    line-height: 1.4 !important;
    white-space: nowrap;
}
.tfsep-btn:hover { border-color: var(--ep-purple) !important; color: var(--ep-purple) !important; background: var(--ep-purple-l) !important; }
.tfsep-btn .dashicons { font-size: 13px; width: 13px; height: 13px; flex-shrink: 0; }
.tfsep-btn-primary {
    background: var(--ep-purple) !important;
    color: #fff !important;
    border-color: var(--ep-purple) !important;
}
.tfsep-btn-primary:hover { background: #6a44a0 !important; border-color: #6a44a0 !important; color: #fff !important; }
.tfsep-btn-danger-lnk {
    background: none !important;
    border-color: #fcc !important;
    color: var(--ep-red) !important;
    font-size: 11px !important;
}
.tfsep-btn-danger-lnk:hover { background: #fdf0ee !important; border-color: var(--ep-red) !important; }

/* ── Box cards ────────────────────────────────────────── */
.tfsep-box-card {
    border: 1px solid var(--ep-border);
    border-radius: var(--ep-r);
    overflow: hidden;
    margin-bottom: 4px;
    background: #fff;
}
.tfsep-box-card:last-of-type { margin-bottom: 0; }
.tfsep-box-card-hdr {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 8px;
    background: var(--ep-bg);
    cursor: pointer;
    font-size: 11px;
    overflow: hidden;
    user-select: none;
}
.tfsep-box-card-hdr:hover { background: #ede8f5; }
.tfsep-box-toggle {
    font-size: 9px;
    color: #bbb;
    flex-shrink: 0;
    transition: transform .18s;
    line-height: 1;
}
.tfsep-box-card.open .tfsep-box-toggle { transform: rotate(90deg); }
.tfsep-box-num  { font-weight: 700; color: var(--ep-purple); flex-shrink: 0; font-size: 10px; }
.tfsep-box-name { font-weight: 600; color: #333; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 80px; }
.tfsep-box-dims { font-family: monospace; font-size: 9px; color: #aaa; flex-shrink: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tfsep-tracking-mini {
    margin-left: auto;
    font-family: monospace;
    font-size: 10px;
    color: var(--ep-purple);
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}
.tfsep-tracking-mini:hover { text-decoration: underline; }
.tfsep-box-body {
    padding: 7px 9px 8px;
    background: #fff;
    border-top: 1px solid var(--ep-border);
}
.tfsep-packing-items {
    margin: 0 0 7px;
    padding: 0 0 0 16px;
    list-style: disc;
}
.tfsep-packing-items li { font-size: 11px; color: #555; padding: 1px 0; margin: 0; }
.tfsep-tracking-full { font-family: monospace; font-size: 10px; color: #aaa; margin-bottom: 6px; word-break: break-all; }

/* ── Return row ───────────────────────────────────────── */
.tfsep-return-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.tfsep-return-tracking {
    font-family: monospace;
    font-size: 10px;
    color: var(--ep-muted);
    flex: 1;
    word-break: break-all;
    line-height: 1.4;
}

/* ── Pickup row ───────────────────────────────────────── */
.tfsep-pickup-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.tfsep-pickup-row input[type="date"] {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--ep-border);
    border-radius: var(--ep-r);
    padding: 4px 7px;
    font-size: 11px;
    color: var(--ep-text);
    background: #fff;
}

/* ── Cancel warning banner ────────────────────────────── */
.tfsep-cancel-warning {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: #fff8e5;
    border: 1px solid #f0c040;
    border-left: 3px solid #e6a817;
    border-radius: var(--ep-r);
    padding: 8px 10px;
    font-size: 11px;
    color: #6b4c00;
    line-height: 1.5;
    margin-bottom: 10px;
}
.tfsep-cancel-warning .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    color: #e6a817;
    flex-shrink: 0;
    margin-top: 1px;
}
.tfsep-cancel-warning strong { color: #5a3d00; display: block; margin-bottom: 2px; }

/* ── No-label state ───────────────────────────────────── */
.tfsep-no-label-notice {
    background: #f0f6fc;
    border: 1px solid #c3d9ef;
    border-radius: var(--ep-r);
    padding: 7px 9px;
    color: #2c5f8a;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 10px;
}
.tfsep-no-label-notice .dashicons { font-size: 14px; width: 14px; height: 14px; }

/* ── Rate picker ──────────────────────────────────────── */
#tfsep-rates-list { max-height: 200px; overflow-y: auto; margin-bottom: 8px; }
.tfsep-rate-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 9px;
    border: 1px solid var(--ep-border);
    border-radius: var(--ep-r);
    margin-bottom: 3px;
    cursor: pointer;
    transition: all .15s;
    gap: 6px;
}
.tfsep-rate-row:hover  { border-color: var(--ep-purple); background: var(--ep-purple-l); }
.tfsep-rate-row.selected { border-color: var(--ep-purple); background: var(--ep-purple-l); }
.tfsep-rate-carrier { font-weight: 700; font-size: 10px; min-width: 50px; color: var(--ep-purple); }
.tfsep-rate-service { flex: 1; font-size: 11px; color: #555; }
.tfsep-rate-days    { font-size: 10px; color: #aaa; }
.tfsep-rate-price   { font-weight: 700; font-size: 12px; color: var(--ep-text); white-space: nowrap; }
.tfsep-cust-badge {
    background: #e8f0fe;
    color: #2c5f9a;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .3px;
    padding: 1px 5px;
    border-radius: 10px;
    margin-left: 4px;
    white-space: nowrap;
}

/* ── Packing preview (rate-picker) ───────────────────── */
.tfsep-packing-method-badge {
    background: #e8f0fe;
    color: #3b6ec7;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    padding: 1px 6px;
    border-radius: 20px;
}
.tfsep-packing-count { color: #aaa; font-size: 10px; font-weight: 600; margin-left: auto; }
.tfsep-packing-boxes { display: flex; flex-direction: column; gap: 5px; }
.tfsep-packing-box {
    background: var(--ep-bg);
    border: 1px solid var(--ep-border);
    border-radius: var(--ep-r);
    overflow: hidden;
}
.tfsep-packing-box-hdr {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    background: #f0f0f0;
    border-bottom: 1px solid var(--ep-border);
    font-size: 11px;
}
.tfsep-packing-dims { font-size: 10px; color: #999; font-family: monospace; white-space: nowrap; }
.tfsep-packing-preview { margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px dashed var(--ep-border); }

/* ── Tracking live ────────────────────────────────────── */
.tfsep-tracking-live {
    background: var(--ep-bg);
    border: 1px solid var(--ep-border);
    border-radius: var(--ep-r);
    padding: 7px 9px;
    font-size: 11px;
    margin-bottom: 8px;
}
.tfsep-tracking-event { padding: 3px 0; border-bottom: 1px solid var(--ep-border); }
.tfsep-tracking-event:last-child { border-bottom: none; }

/* ── Overlay ──────────────────────────────────────────── */
#tfsep-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.88);
    border-radius: var(--ep-r);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 200;
    font-size: 12px;
    color: #555;
    font-weight: 600;
}
.tfsep-spinner {
    width: 24px; height: 24px;
    border: 3px solid var(--ep-border);
    border-top-color: var(--ep-purple);
    border-radius: 50%;
    animation: tfsep-spin .7s linear infinite;
}
@keyframes tfsep-spin { to { transform: rotate(360deg); } }

/* ── Message ──────────────────────────────────────────── */
#tfsep-msg { border-radius: var(--ep-r); font-size: 11px; font-weight: 600; }
#tfsep-msg.success { background: #edfaf3; color: #1a7a4a; border: 1px solid #a8dfbe; }
#tfsep-msg.error   { background: #fdf0ee; color: #a82020; border: 1px solid #f5c6cb; }
