/**
 * TDE Billing CFDI Styles
 */

/* === Info Note === */
.tde-cfdi-info-note {
    background: #f0f7ff;
    border: 1px solid #b8daff;
    border-left: 4px solid #2e86c1;
    border-radius: 6px;
    padding: 20px 24px;
    margin-bottom: 30px;
}

.tde-cfdi-info-note h3 {
    margin: 0 0 10px 0;
    color: #1a5276;
    font-size: 1.1em;
}

.tde-cfdi-info-note > p {
    margin: 0 0 15px 0;
    color: #555;
}

.tde-cfdi-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tde-cfdi-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #fff;
    padding: 12px 16px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.tde-cfdi-option-icon {
    font-size: 24px;
    flex-shrink: 0;
    line-height: 1;
}

.tde-cfdi-option strong {
    display: block;
    color: #333;
    margin-bottom: 2px;
}

.tde-cfdi-option p {
    margin: 0;
    color: #666;
    font-size: 13px;
}

/* === Orders Table === */
.tde-cfdi-orders-table {
    margin-top: 15px !important;
}

.tde-cfdi-orders-table th {
    background: #f8f9fa;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tde-cfdi-btn {
    font-size: 13px !important;
    padding: 6px 14px !important;
    background: #2e86c1 !important;
    color: #fff !important;
    border: none !important;
    border-radius: 4px !important;
    text-decoration: none !important;
}

.tde-cfdi-btn:hover {
    background: #1a5276 !important;
    color: #fff !important;
}

.tde-cfdi-badge-sent {
    display: inline-block;
    background: #d4edda;
    color: #155724;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

/* === Form === */
.tde-cfdi-form-wrapper {
    margin-top: 20px;
}

.tde-cfdi-form-wrapper h3 {
    color: #1a5276;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #2e86c1;
}

.tde-cfdi-autofill-section,
.tde-cfdi-fiscal-section {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 20px;
}

.tde-cfdi-autofill-section h4,
.tde-cfdi-fiscal-section h4 {
    margin: 0 0 15px 0;
    color: #1a5276;
    font-size: 0.95em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tde-cfdi-form .form-row {
    margin-bottom: 15px;
}

.tde-cfdi-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.tde-cfdi-form .input-text,
.tde-cfdi-form .select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.tde-cfdi-form .input-text:focus,
.tde-cfdi-form .select:focus {
    border-color: #2e86c1;
    box-shadow: 0 0 0 2px rgba(46, 134, 193, 0.15);
    outline: none;
}

.tde-cfdi-readonly {
    background: #e9ecef !important;
    color: #495057 !important;
    cursor: not-allowed;
    font-weight: 600;
}

.tde-cfdi-submit-btn {
    background: #2e86c1 !important;
    color: #fff !important;
    border: none !important;
    padding: 14px 30px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
    cursor: pointer;
    width: 100%;
    transition: background 0.2s;
}

.tde-cfdi-submit-btn:hover {
    background: #1a5276 !important;
}

/* === Success === */
.tde-cfdi-success {
    text-align: center;
    padding: 40px 20px;
    background: #f0fff0;
    border: 2px solid #28a745;
    border-radius: 8px;
    margin: 20px 0;
}

.tde-cfdi-success-icon {
    width: 60px;
    height: 60px;
    background: #28a745;
    color: #fff;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    font-weight: bold;
    margin-bottom: 15px;
}

.tde-cfdi-success h3 {
    color: #155724;
    margin: 0 0 10px 0;
}

.tde-cfdi-success p {
    color: #555;
    margin: 0 0 20px 0;
}

/* === "Factura solicitada" disabled button in orders === */
.woocommerce-orders-table .woocommerce-button.button.factura-solicitada {
    background: #d4edda !important;
    color: #155724 !important;
    border: 1px solid #c3e6cb !important;
    cursor: default;
    pointer-events: none;
    opacity: 0.8;
}

/* === Responsive === */
@media (max-width: 768px) {
    .tde-cfdi-info-note {
        padding: 15px;
    }

    .tde-cfdi-option {
        padding: 10px 12px;
    }

    .tde-cfdi-autofill-section,
    .tde-cfdi-fiscal-section {
        padding: 15px;
    }

    .tde-cfdi-orders-table th:nth-child(4),
    .tde-cfdi-orders-table td:nth-child(4) {
        display: none;
    }

    .tde-cfdi-submit-btn {
        padding: 12px 20px !important;
        font-size: 14px !important;
    }
}

/* === Orders action buttons: single horizontal line === */
.woocommerce-orders-table td.woocommerce-orders-table__cell-order-actions {
    white-space: nowrap;
}

.woocommerce-orders-table td.woocommerce-orders-table__cell-order-actions a.woocommerce-button {
    display: inline-block !important;
    margin: 2px 3px !important;
    padding: 6px 12px !important;
    font-size: 13px !important;
    white-space: nowrap !important;
}

@media (max-width: 768px) {
    .woocommerce-orders-table td.woocommerce-orders-table__cell-order-actions {
        white-space: normal;
    }
    .woocommerce-orders-table td.woocommerce-orders-table__cell-order-actions a.woocommerce-button {
        display: inline-block !important;
        margin: 2px !important;
        padding: 5px 10px !important;
        font-size: 12px !important;
    }
}


/* ================================================================== */
/* === Interactive Method Selector (Table Layout)                  === */
/* ================================================================== */

.tde-method-selector {
    background: #f0f7ff;
    border: 1px solid #b8daff;
    border-left: 4px solid #2e86c1;
    border-radius: 8px;
    padding: 24px 24px 20px;
    margin-bottom: 30px;
}

.tde-method-title {
    margin: 0 0 4px 0;
    color: #1a5276;
    font-size: 1.1em;
    font-weight: 700;
}

.tde-method-subtitle {
    margin: 0 0 18px 0;
    color: #888;
    font-size: 13px;
}

/* --- Table --- */
.tde-method-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #d8e8f5;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.tde-method-table thead tr {
    background: #1a5276;
}

.tde-method-table thead th {
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 11px 18px;
    text-align: left;
}

.tde-method-col-tipo { width: 85%; }
.tde-method-col-sel  { width: 15%; text-align: center !important; }

/* --- Rows --- */
.tde-method-row {
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid #eaf1f8;
}

.tde-method-row:last-child { border-bottom: none; }

.tde-method-row:hover {
    background: #eaf4ff;
}

.tde-method-row td {
    padding: 14px 18px;
    vertical-align: middle;
}

.tde-method-col-tipo {
    display: flex;
    align-items: center;
    gap: 14px;
}

/* Selected row */
.tde-row-selected {
    background: #ddefff !important;
}

.tde-row-selected .tde-method-content strong {
    color: #1a5276;
}

/* Dimmed (non-selected) rows */
.tde-row-dimmed {
    opacity: 0.45;
    background: #f9f9f9 !important;
    pointer-events: none;
}

/* --- Icons & text inside cells --- */
.tde-method-icon {
    font-size: 26px;
    flex-shrink: 0;
    line-height: 1;
}

.tde-method-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tde-method-content strong {
    color: #1a3a5c;
    font-size: 14px;
    font-weight: 700;
}

.tde-method-content span {
    color: #666;
    font-size: 12px;
}

/* --- Custom radio (checkmark style) --- */
.tde-method-check-label {
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    margin: 0;
}

.tde-method-radio {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.tde-method-checkmark {
    display: inline-block;
    width: 22px;
    height: 22px;
    border: 2px solid #b0c8e0;
    border-radius: 50%;
    background: #fff;
    transition: border-color 0.18s, background 0.18s;
    position: relative;
    flex-shrink: 0;
}

.tde-method-checkmark::after {
    content: '';
    position: absolute;
    display: none;
    top: 4px;
    left: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #2e86c1;
}

.tde-method-radio:checked + .tde-method-checkmark,
.tde-row-selected .tde-method-checkmark {
    border-color: #2e86c1;
    background: #e8f4ff;
}

.tde-method-radio:checked + .tde-method-checkmark::after,
.tde-row-selected .tde-method-checkmark::after {
    display: block;
}

/* --- Confirm button --- */
.tde-method-confirm-wrap {
    margin-top: 16px;
    text-align: right;
}

.tde-method-confirm-btn {
    background: #1a5276;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 11px 28px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}

.tde-method-confirm-btn:hover {
    background: #2e86c1;
}

.tde-method-confirm-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* ================================================================== */
/* === Method Confirmation Screen                                  === */
/* ================================================================== */

.tde-method-confirmed {
    text-align: center;
    padding: 40px 24px;
    background: #f0fff4;
    border: 2px solid #28a745;
    border-radius: 10px;
    margin: 20px 0;
}

.tde-method-confirmed-icon {
    font-size: 48px;
    margin-bottom: 12px;
    display: block;
}

.tde-method-confirmed h3 {
    color: #155724;
    margin: 0 0 10px 0;
    font-size: 1.2em;
}

.tde-method-confirmed p {
    color: #555;
    margin: 0 0 10px 0;
}

.tde-method-confirmed-note {
    font-size: 13px;
    color: #777 !important;
    margin-bottom: 24px !important;
}

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

@media (max-width: 600px) {
    .tde-method-selector {
        padding: 16px 12px;
    }

    .tde-method-table thead th {
        font-size: 11px;
        padding: 9px 12px;
    }

    .tde-method-row td {
        padding: 12px 12px;
    }

    .tde-method-icon {
        font-size: 20px;
    }

    .tde-method-content strong {
        font-size: 13px;
    }

    .tde-method-content span {
        display: none;
    }

    .tde-method-confirm-wrap {
        text-align: center;
    }

    .tde-method-confirm-btn {
        width: 100%;
    }
}
/* ================================================================== */
/* === Billing Profiles Section                                    === */
/* ================================================================== */

.tde-profiles-section {
    margin: 0 0 30px 0;
    padding: 20px 24px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-left: 4px solid #2e86c1;
    border-radius: 6px;
}

.tde-profiles-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.tde-profiles-header h3 {
    margin: 0;
    color: #1a5276;
    font-size: 1em;
}

.tde-profiles-empty {
    color: #777;
    font-size: 13px;
    margin: 0;
    font-style: italic;
}

/* ── Profile Cards Grid ── */
.tde-profiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 4px;
}

.tde-profile-card {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.15s;
}

.tde-profile-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.tde-profile-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1a5276;
    padding: 8px 12px;
}

.tde-profile-card-name {
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.tde-profile-card-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.tde-profile-edit,
.tde-profile-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 4px;
    line-height: 1;
    transition: background 0.15s;
}

.tde-profile-edit:hover  { background: rgba(255,255,255,0.2); }
.tde-profile-delete:hover { background: rgba(255,80,80,0.3); }

.tde-profile-card-body {
    padding: 10px 12px;
}

.tde-profile-card-body p {
    margin: 0 0 4px 0;
    font-size: 13px;
    color: #333;
}

.tde-profile-rfc {
    font-family: monospace;
    font-size: 12px !important;
    color: #2e86c1 !important;
    font-weight: 600;
}

.tde-profile-detail {
    color: #666 !important;
    font-size: 11px !important;
}

/* ── Add Profile Button ── */
.tde-btn-add-profile {
    background: #2e86c1;
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.tde-btn-add-profile:hover {
    background: #1a5276;
}

/* ── Profile Selector in Form ── */
.tde-profile-selector-wrap {
    background: #eaf4fb;
    border: 1px solid #b8daff;
    border-radius: 6px;
    padding: 14px 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.tde-profile-select-label {
    font-weight: 600;
    color: #1a5276;
    font-size: 14px;
    white-space: nowrap;
}

.tde-profile-select {
    flex: 1;
    min-width: 200px;
    padding: 8px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

/* ── Save Profile Section ── */
.tde-save-profile-section {
    background: #f0fff4;
    border: 1px solid #c3e6cb;
    border-radius: 6px;
    padding: 14px 16px;
    margin-bottom: 20px;
}

.tde-save-profile-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 600;
    color: #155724;
    font-size: 14px;
    margin: 0;
}

.tde-save-profile-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

.tde-save-profile-name {
    margin-top: 10px;
}

.tde-save-profile-name .input-text {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

/* ================================================================== */
/* === Profile Modal                                               === */
/* ================================================================== */

.tde-profile-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
}

.tde-profile-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.tde-profile-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #1a5276;
    border-radius: 10px 10px 0 0;
}

.tde-profile-modal-header h4 {
    margin: 0;
    color: #fff;
    font-size: 1em;
}

.tde-modal-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    opacity: 0.8;
}

.tde-modal-close:hover { opacity: 1; }

.tde-profile-modal-body {
    padding: 20px;
}

.tde-profile-modal-body .form-row {
    margin-bottom: 14px;
}

.tde-profile-modal-body label {
    display: block;
    font-weight: 600;
    color: #333;
    font-size: 13px;
    margin-bottom: 5px;
}

.tde-profile-modal-body .input-text,
.tde-profile-modal-body .select {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

.tde-profile-modal-body .input-text:focus,
.tde-profile-modal-body .select:focus {
    border-color: #2e86c1;
    outline: none;
    box-shadow: 0 0 0 2px rgba(46,134,193,0.15);
}

.tde-modal-error {
    background: #fff3f3;
    border: 1px solid #f5c6cb;
    color: #721c24;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 13px;
    margin-top: 8px;
}

.tde-profile-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
    border-radius: 0 0 10px 10px;
}

.tde-btn-primary {
    background: #2e86c1;
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 9px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.tde-btn-primary:hover  { background: #1a5276; }
.tde-btn-primary:disabled { opacity: 0.6; cursor: wait; }

.tde-btn-secondary {
    background: #fff;
    color: #555;
    border: 1px solid #ced4da;
    border-radius: 5px;
    padding: 9px 18px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
}

.tde-btn-secondary:hover { background: #f1f3f5; }

/* ── Responsive ── */
@media (max-width: 600px) {
    .tde-profiles-grid {
        grid-template-columns: 1fr;
    }

    .tde-profile-selector-wrap {
        flex-direction: column;
        align-items: flex-start;
    }

    .tde-profile-select {
        width: 100%;
    }

    .tde-profile-modal {
        width: 95%;
        max-height: 95vh;
    }
}
