/* ============================================================
   WeoInvoice Admin — Responsive Design
   ============================================================ */

:root {
    --weo-primary:    #1a56a0;
    --weo-primary-h:  #134080;
    --weo-green:      #0a7c42;
    --weo-green-bg:   #eaf7f0;
    --weo-grey:       #6b7280;
    --weo-grey-light: #f3f4f6;
    --weo-border:     #e5e7eb;
    --weo-white:      #ffffff;
    --weo-red:        #dc2626;
    --weo-radius:     8px;
    --weo-shadow:     0 1px 4px rgba(0,0,0,.08);
}

/* ---- Wrap ---- */
.weoinvoice-wrap {
    max-width: 100%;
    padding: 0 4px;
}

.weoinvoice-logo-center {
    display: block;
    margin: 16px auto 12px;
}

.weoinvoice-header-center {
    justify-content: center;
    text-align: center;
    border-bottom: 2px solid var(--weo-border);
    padding: 16px 0 16px;
    margin-bottom: 20px;
}

.weoinvoice-header-center .weoinvoice-header-actions {
    margin-left: 0;
}

/* ---- Header ---- */
.weoinvoice-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    padding: 12px 0;
    border-bottom: 2px solid var(--weo-border);
}

.weoinvoice-logo-full {
    height: 36px;
    width: auto;
    object-fit: contain;
}

.weoinvoice-logo-small {
    width: 30px;
    height: 30px;
    object-fit: contain;
    border-radius: 6px;
}

.weoinvoice-logo {
    width: 160px;
    height: auto;
    display: block;
    margin: 0 auto 16px;
}

.weoinvoice-header h1 {
    font-size: 18px !important;
    font-weight: 700 !important;
    margin: 0 !important;
    color: #111827;
}

.weoinvoice-store-badge {
    font-size: 11px;
    color: var(--weo-grey);
    background: var(--weo-grey-light);
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid var(--weo-border);
    word-break: break-all;
}

.weoinvoice-header-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---- Orders Table — Desktop ---- */
.weoinvoice-orders-table {
    width: 100% !important;
    border-radius: var(--weo-radius);
    overflow: hidden;
    border: 1px solid var(--weo-border) !important;
    box-shadow: var(--weo-shadow);
}

.weoinvoice-orders-table thead th {
    background: #f9fafb !important;
    color: #374151 !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: .6px;
    padding: 10px 12px !important;
    border-bottom: 2px solid var(--weo-border) !important;
    white-space: nowrap;
}

.weoinvoice-orders-table tbody td {
    padding: 10px 12px !important;
    vertical-align: middle !important;
    font-size: 13px;
    border-bottom: 1px solid var(--weo-border) !important;
}

.weoinvoice-orders-table tbody tr:last-child td {
    border-bottom: none !important;
}

.weoinvoice-orders-table tbody tr:hover {
    background: #f0f7ff !important;
}

/* Order status badges */
.weoinvoice-orders-table .order-status {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
}

.weoinvoice-orders-table .status-processing { background: #dcfce7; color: #166534; }
.weoinvoice-orders-table .status-completed  { background: #dbeafe; color: #1e40af; }
.weoinvoice-orders-table .status-pending    { background: #fef9c3; color: #854d0e; }
.weoinvoice-orders-table .status-cancelled  { background: #fee2e2; color: #991b1b; }
.weoinvoice-orders-table .status-refunded   { background: #f3f4f6; color: #4b5563; }
.weoinvoice-orders-table .status-failed     { background: #fee2e2; color: #991b1b; }
.weoinvoice-orders-table .status-on-hold    { background: #ffedd5; color: #9a3412; }

.weoinvoice-orders-table .description {
    display: block;
    color: #9ca3af;
    font-size: 11px;
    margin-top: 2px;
}

/* Preview button */
.weoinvoice-preview-btn {
    background: none;
    border: none;
    padding: 2px 4px;
    margin-left: 4px;
    color: #9ca3af;
    cursor: pointer;
    vertical-align: middle;
    border-radius: 4px;
    transition: color .15s, background .15s;
}

.weoinvoice-preview-btn:hover {
    color: var(--weo-primary);
    background: var(--weo-grey-light);
}

/* Invoice buttons */
.button-invoice {
    font-size: 11px !important;
    padding: 3px 10px !important;
    height: auto !important;
    line-height: 1.8 !important;
    border-radius: 4px !important;
}

/* Invoice status */
.weo-invoice-issued {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--weo-green);
    font-size: 12px;
    font-weight: 600;
    background: var(--weo-green-bg);
    padding: 2px 8px;
    border-radius: 20px;
}

.weo-invoice-not-issued {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #9ca3af;
    font-size: 12px;
}

.weoinvoice-loading-status {
    color: #d1d5db;
    font-size: 16px;
}

/* ---- MOBILE — Card Layout ---- */
@media screen and (max-width: 782px) {

    .weoinvoice-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .weoinvoice-header-actions {
        margin-left: 0;
        width: 100%;
    }

    .weoinvoice-header-actions .button {
        flex: 1;
        text-align: center;
    }

    .weoinvoice-store-badge {
        font-size: 10px;
    }

    /* Esconder colunas menos importantes no mobile */
    .weoinvoice-orders-table thead,
    .weoinvoice-orders-table .check-column {
        display: none;
    }

    .weoinvoice-orders-table tbody tr {
        display: block;
        margin-bottom: 10px;
        border: 1px solid var(--weo-border) !important;
        border-radius: var(--weo-radius);
        background: var(--weo-white);
        box-shadow: var(--weo-shadow);
        padding: 12px;
    }

    .weoinvoice-orders-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 6px 0 !important;
        border-bottom: 1px solid var(--weo-grey-light) !important;
        font-size: 13px;
    }

    .weoinvoice-orders-table tbody td:last-child {
        border-bottom: none !important;
    }

    .weoinvoice-orders-table tbody td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: .4px;
        color: #9ca3af;
        min-width: 90px;
    }

    /* Esconder células vazias no mobile */
    .weoinvoice-orders-table tbody td:empty {
        display: none;
    }

    /* Order number ocupa linha toda */
    .order-number-col {
        display: block !important;
        padding: 0 0 10px !important;
        border-bottom: 2px solid var(--weo-border) !important;
        margin-bottom: 4px;
        font-size: 14px !important;
        font-weight: 600;
    }

    .order-number-col::before {
        display: none !important;
    }
}

/* ---- Settings Cards ---- */
.weoinvoice-card {
    background: var(--weo-white);
    border: 1px solid var(--weo-border);
    border-radius: var(--weo-radius);
    padding: 20px 24px;
    margin-bottom: 16px;
    box-shadow: var(--weo-shadow);
}

.weoinvoice-card h2 {
    margin-top: 0;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--weo-border);
    font-size: 13px !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: #374151;
}

.weoinvoice-card-info {
    background: #f9fafb;
}

.weoinvoice-connected-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: var(--weo-green);
    font-size: 14px;
}

.weoinvoice-disconnected-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: var(--weo-red);
    font-size: 14px;
}

@media screen and (max-width: 600px) {
    .weoinvoice-card {
        padding: 16px;
    }

    .form-table th,
    .form-table td {
        display: block !important;
        width: 100% !important;
        padding: 4px 0 !important;
    }

    .form-table th {
        padding-top: 12px !important;
    }

    .form-table input[type="text"],
    .form-table select {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* ---- Modal ---- */
.weoinvoice-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.weoinvoice-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(2px);
}

.weoinvoice-modal-content {
    position: relative;
    z-index: 1;
    background: var(--weo-white);
    border-radius: var(--weo-radius);
    width: 92%;
    max-width: 640px;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 8px 40px rgba(0,0,0,.25);
}

.weoinvoice-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--weo-border);
    background: #f9fafb;
    position: sticky;
    top: 0;
    z-index: 1;
}

.weoinvoice-modal-header h1 {
    margin: 0 !important;
    font-size: 16px !important;
    flex: 1;
}

.weoinvoice-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    padding: 4px;
    border-radius: 4px;
    transition: color .15s, background .15s;
    line-height: 1;
}

.weoinvoice-modal-close:hover {
    color: var(--weo-red);
    background: #fee2e2;
}

.weoinvoice-modal-content article {
    padding: 20px;
}

.weo-modal-details {
    margin-bottom: 20px;
}

.weo-modal-details h2 {
    font-size: 11px !important;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: #9ca3af;
    border-bottom: 1px solid var(--weo-border);
    padding-bottom: 8px;
    margin-bottom: 12px;
}

.weo-modal-details p {
    margin: 6px 0;
    font-size: 13px;
    line-height: 1.5;
}

/* Preview table */
.wc-order-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--weo-border);
}

.wc-order-preview-table th,
.wc-order-preview-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--weo-border);
}

.wc-order-preview-table th {
    background: #f9fafb;
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #6b7280;
}

.wc-order-preview-table tr:last-child td {
    border-bottom: none;
}

.wc-order-preview-table small {
    color: #9ca3af;
    display: block;
    font-size: 11px;
}

@media screen and (max-width: 600px) {
    .weoinvoice-modal-content {
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
        align-self: flex-end;
    }

    .weoinvoice-modal-overlay {
        align-items: flex-end;
    }
}

/* ---- Pagination ---- */
.tablenav.bottom {
    margin-top: 12px;
}

/* ---- Connect Screen ---- */
.weoinvoice-connect-box {
    max-width: 440px;
    margin: 40px auto;
    background: var(--weo-white);
    border: 1px solid var(--weo-border);
    border-radius: var(--weo-radius);
    padding: 40px 32px;
    text-align: center;
    box-shadow: var(--weo-shadow);
}

.weoinvoice-connect-box h1 {
    font-size: 20px;
    margin: 16px 0 8px;
    color: #111827;
}

.weoinvoice-connect-box p {
    color: var(--weo-grey);
    margin-bottom: 8px;
    font-size: 14px;
}

.weoinvoice-store-url {
    font-size: 11px;
    background: var(--weo-grey-light);
    padding: 6px 12px;
    border-radius: 4px;
    display: inline-block;
    margin: 8px 0 20px;
    word-break: break-all;
    border: 1px solid var(--weo-border);
    color: var(--weo-grey);
}

.weoinvoice-hint {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 16px;
}

/* ---- Spinner ---- */
.weo-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #d1d5db;
    border-top-color: var(--weo-primary);
    border-radius: 50%;
    animation: weo-spin 0.65s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

@keyframes weo-spin {
    to { transform: rotate(360deg); }
}