/**
 * WooCommerce Multi-Address Shipping Styles
 * Version: 1.0.0
 */

.woocommerce-multiship-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.woocommerce-multiship-wrapper .multiship-tabs ul {
    list-style: none;
    padding: 0;
    margin: 20px 0;
    border-bottom: 2px solid #ddd;
    display: flex;
    flex-wrap: wrap;
}

.woocommerce-multiship-wrapper .multiship-tabs li {
    margin-right: 20px;
    margin-bottom: 10px;
}

.woocommerce-multiship-wrapper .multiship-tabs li a {
    display: block;
    padding: 10px 15px;
    text-decoration: none;
    color: #333;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.3s ease;
}

.woocommerce-multiship-wrapper .multiship-tabs li.active a {
    border-bottom-color: #be1f2d;
    font-weight: bold;
    color: #be1f2d;
}

.woocommerce-multiship-wrapper .multiship-tabs li a:hover {
    color: #be1f2d;
    background-color: #f9f9f9;
}

.woocommerce-multiship-wrapper .multiship-recipient-form {
    margin: 20px 0;
    padding: 0;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.woocommerce-multiship-wrapper .multiship-form-header {
    padding: 15px 20px;
    background: #fff;
    border-bottom: 1px solid #ddd;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.3s ease;
}

.woocommerce-multiship-wrapper .multiship-form-header:hover {
    background: #f5f5f5;
}

.woocommerce-multiship-wrapper .multiship-form-toggle {
    font-size: 20px;
    font-weight: bold;
    color: #be1f2d;
    transition: transform 0.3s ease;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.woocommerce-multiship-wrapper .multiship-form-header.active .multiship-form-toggle {
    transform: rotate(45deg);
}

.woocommerce-multiship-wrapper .multiship-form-content {
    padding: 20px;
    display: none;
    background: #fff;
}

.woocommerce-multiship-wrapper .multiship-form-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.woocommerce-multiship-wrapper .multiship-recipients-list {
    margin: 20px 0;
    padding: 20px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.woocommerce-multiship-wrapper .multiship-recipient-form input[type="text"],
.woocommerce-multiship-wrapper .multiship-recipient-form input[type="email"],
.woocommerce-multiship-wrapper .multiship-recipient-form select {
    width: 100%;
    margin-bottom: 10px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.woocommerce-multiship-wrapper .multiship-recipient-form input[type="text"]:focus,
.woocommerce-multiship-wrapper .multiship-recipient-form input[type="email"]:focus,
.woocommerce-multiship-wrapper .multiship-recipient-form select:focus {
    outline: none;
    border-color: #be1f2d;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
}

.woocommerce-multiship-wrapper .multiship-recipient-form label {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
    display: block;
}

.woocommerce-multiship-wrapper .form-row {
    margin-bottom: 15px;
}

.woocommerce-multiship-wrapper .form-row-first {
    float: left;
    width: 48%!important;
    margin-right: 2%!important;
}

.woocommerce-multiship-wrapper .form-row-last {
    float: right;
    width: 48%!important;
    margin-left: 2%;
}

.woocommerce-multiship-wrapper .form-row-wide {
    clear: both;
    width: 100%;
}

.woocommerce-multiship-wrapper .form-row::after {
    content: "";
    display: table;
    clear: both;
}

.woocommerce-multiship-wrapper table.multiship-recipients-table {
    width: 100%;
    margin-top: 20px;
    border-collapse: collapse;
    background: #fff;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.woocommerce-multiship-wrapper .multiship-recipients-table th {
    background: #f8f9fa;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #dee2e6;
}

.woocommerce-multiship-wrapper .multiship-recipients-table td {
    padding: 12px;
    border-bottom: 1px solid #dee2e6;
    vertical-align: top;
}

.woocommerce-multiship-wrapper .multiship-recipients-table tr:hover {
    background-color: #f8f9fa;
}

.woocommerce-multiship-wrapper .multiship-order-form {
    margin: 20px 0;
}

.woocommerce-multiship-wrapper .recipient-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.woocommerce-multiship-wrapper .button-edit {
    background: #f0ad4e;
    border-color: #eea236;
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 12px;
    transition: all 0.3s ease;
}

.woocommerce-multiship-wrapper .button-edit:hover {
    background: #ec971f;
    border-color: #d58512;
    color: #fff;
}

.woocommerce-multiship-wrapper .edit-form-row {
    display: none;
    background: #fff;
}

.woocommerce-multiship-wrapper .edit-form-row.editing {
    display: table-row;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; max-height: 0; }
    to { opacity: 1; max-height: 500px; }
}

.woocommerce-multiship-wrapper .edit-form-row td {
    padding: 20px;
    background: #fff;
    border: 2px solid #be1f2d;
    border-radius: 4px;
}

.woocommerce-multiship-wrapper .view-row.editing {
    display: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .woocommerce-multiship-wrapper .multiship-tabs ul {
        flex-direction: column;
    }
    
    .woocommerce-multiship-wrapper .multiship-tabs li {
        margin-right: 0;
        margin-bottom: 5px;
    }
    
    .woocommerce-multiship-wrapper .form-row-first,
    .woocommerce-multiship-wrapper .form-row-last {
        float: none;
        width: 100%;
        margin-right: 0;
        margin-left: 0;
    }
    
    .woocommerce-multiship-wrapper .multiship-recipients-table {
        font-size: 14px;
    }
    
    .woocommerce-multiship-wrapper .multiship-recipients-table th,
    .woocommerce-multiship-wrapper .multiship-recipients-table td {
        padding: 8px;
    }
    
    .woocommerce-multiship-wrapper .recipient-actions {
        flex-direction: column;
        gap: 5px;
    }
    
    .woocommerce-multiship-wrapper .recipient-actions .button {
        width: 100%;
        text-align: center;
    }
}

/* WooCommerce Integration */
.woocommerce-multiship-wrapper .button {
    background: #be1f2d;
    border-color: #be1f2d;
    color: #fff;
    padding: 10px 20px;
    border-radius: 4px;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-size: 14px;
}

.woocommerce-multiship-wrapper .button:hover {
    background: #005a87;
    border-color: #005a87;
    color: #fff;
}

.woocommerce-multiship-wrapper .button-primary {
    background: #be1f2d;
    border-color: #be1f2d;
}

.woocommerce-multiship-wrapper .button-secondary {
    background: #6c757d;
    border-color: #6c757d;
}

.woocommerce-multiship-wrapper .button-secondary:hover {
    background: #5a6268;
    border-color: #5a6268;
}

/* Success/Error Messages */
.woocommerce-multiship-wrapper .woocommerce-message,
.woocommerce-multiship-wrapper .woocommerce-error {
    padding: 15px;
    margin: 20px 0;
    border-radius: 4px;
    border-left: 4px solid;
}

.woocommerce-multiship-wrapper .woocommerce-message {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
}

.woocommerce-multiship-wrapper .woocommerce-error {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

/* File Upload Styling */
.woocommerce-multiship-wrapper input[type="file"] {
    border: 2px dashed #ccc;
    border-radius: 4px;
    padding: 20px;
    text-align: center;
    transition: border-color 0.3s ease;
}

.woocommerce-multiship-wrapper input[type="file"]:hover {
    border-color: #be1f2d;
}

.woocommerce-multiship-wrapper input[type="file"]:focus {
    border-color: #be1f2d;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
}

/* Checkbox Styling */
.woocommerce-multiship-wrapper input[type="checkbox"] {
    width: auto;
    margin: 0;
}

/* Table Responsive */
@media (max-width: 600px) {
    .woocommerce-multiship-wrapper .multiship-recipients-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .woocommerce-multiship-wrapper .multiship-recipients-table th,
    .woocommerce-multiship-wrapper .multiship-recipients-table td {
        min-width: 120px;
    }
}

/* Delete order button styles */
.multiship-delete-order-btn {
    background: #dc3545 !important;
    border-color: #dc3545 !important;
    color: #fff !important;
    padding: 4px 8px !important;
    min-width: 32px !important;
    height: 32px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 3px !important;
    transition: all 0.2s ease !important;
}

.multiship-delete-order-btn:hover {
    background: #c82333 !important;
    border-color: #bd2130 !important;
    color: #fff !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
}

.multiship-delete-order-btn:disabled {
    background: #6c757d !important;
    border-color: #6c757d !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
}

.multiship-delete-order-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    line-height: 1;
}

/* Loading animation for delete button */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.multiship-delete-order-btn .dashicons-update {
    animation: spin 1s linear infinite;
}

/* Table actions column */
.woocommerce-multiship-wrapper .shop_table th:last-child,
.woocommerce-multiship-wrapper .shop_table td:last-child {
    text-align: center;
    width: 250px;
}

/* Bulk toolbar inline layout */
.woocommerce-multiship-wrapper #ms-bulk-form {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.woocommerce-multiship-wrapper #ms-bulk-form select { min-width: 160px; }
.woocommerce-multiship-wrapper #ms-bulk-form .button { padding: 8px 14px; }

/* List headers with inline actions */
.woocommerce-multiship-wrapper .ms-list-header {
    margin-top: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.woocommerce-multiship-wrapper .ms-list-header h4 { margin: 0; }
.woocommerce-multiship-wrapper .ms-list-actions { display: inline-flex; align-items: center; gap: 10px; }
.woocommerce-multiship-wrapper .ms-rename-form input[type="text"] { width: auto; max-width: 300px; }

.ms-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 6px;
    border-radius: 10px;
    background: #e6f4ea;
    color: #1e7e34;
    font-size: 12px;
    border: 1px solid #c3e6cb;
}

/* Orders table tweaks */
.woocommerce-multiship-wrapper .ms-orders-table th { font-size: 13px; }
.woocommerce-multiship-wrapper .ms-orders-table td { font-size: 14px; vertical-align: middle; }
.woocommerce-multiship-wrapper .ms-orders-table .ms-col-id { width: 60px; }
.woocommerce-multiship-wrapper .ms-orders-table .ms-order-name { font-weight: 600; }
.woocommerce-multiship-wrapper .ms-orders-table .ms-order-sub { color: #666; font-size: 12px; margin-top: 2px; }
.woocommerce-multiship-wrapper .ms-orders-table .ms-order-actions .button { padding: 6px 10px; font-size: 12px; margin-right: 6px; }
.woocommerce-multiship-wrapper .ms-orders-table .multiship-delete-order-btn { padding: 6px 8px !important; height: auto !important; }
.woocommerce-multiship-wrapper .ms-orders-table .dashicons { vertical-align: middle; }

/* Mobile delete button adjustments */
@media (max-width: 768px) {
    .multiship-delete-order-btn {
        min-width: 28px !important;
        height: 28px !important;
        padding: 2px 6px !important;
    }
    
    .multiship-delete-order-btn .dashicons {
        font-size: 14px;
        width: 14px;
        height: 14px;
    }
}

/* Manage Order Layout */
.multiship-manage-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 15px;
}

.multiship-products-panel, .multiship-recipients-panel {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
}

.multiship-product-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.multiship-product-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.ms-product-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px;
    cursor: pointer;
    transition: box-shadow .2s ease, border-color .2s ease;
}

.woocommerce-multiship-wrapper .ms-product-card:hover { box-shadow: 0 2px 6px rgba(0,0,0,0.1); }
.woocommerce-multiship-wrapper .ms-product-card.selected { border-color: #be1f2d; box-shadow: 0 0 0 2px rgba(0,115,170,.15); }
.woocommerce-multiship-wrapper .ms-product-card img { width: 100%; height: auto; border-radius: 3px; margin-bottom: 8px; }
.woocommerce-multiship-wrapper .ms-product-meta .name { font-weight: 600; margin-bottom: 4px; }
.woocommerce-multiship-wrapper .ms-product-meta .price { color: #be1f2d; }
.woocommerce-multiship-wrapper .ms-pagination { margin-top: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.woocommerce-multiship-wrapper .ms-pagination a { padding: 6px 10px; border: 1px solid #ddd; border-radius: 3px; background: #fff; color: #333; text-decoration: none; }
.woocommerce-multiship-wrapper .ms-pagination a.current { background: #be1f2d; color: #fff; border-color: #be1f2d; }

/* In-card variation selector */
.woocommerce-multiship-wrapper .ms-product-variations { margin-top: 8px; }
.woocommerce-multiship-wrapper .ms-product-variations .ms-variation-label { display: block; font-size: 12px; color: #555; margin-bottom: 4px; }
.woocommerce-multiship-wrapper .ms-product-variations .ms-variation-select { width: 100%; padding: 6px 8px; border: 1px solid #ddd; border-radius: 3px; background: #fff; }

.woocommerce-multiship-wrapper .multiship-recipient-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 12px;
}
.woocommerce-multiship-wrapper .multiship-recipient-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.woocommerce-multiship-wrapper .multiship-recipient-items .ms-item-row { padding: 6px 8px; background: #f1f3f5; border-radius: 3px; margin-bottom: 6px; }
.woocommerce-multiship-wrapper .ms-item-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.woocommerce-multiship-wrapper .ms-item-title { flex: 1; font-weight: 500; }
.woocommerce-multiship-wrapper .ms-item-controls { display: inline-flex; align-items: center; gap: 6px; }
.woocommerce-multiship-wrapper .ms-qty-input { width: 60px; padding: 4px 6px; text-align: center; }

@media (max-width: 900px) {
    .multiship-manage-grid { grid-template-columns: 1fr; }
}

/* Global loading overlay */
.ms-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.65);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.ms-loading-overlay.visible { display: flex; }
.ms-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(0, 115, 170, 0.25);
    border-top-color: #be1f2d;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

/* Order summary bar */
.multiship-summary {
    display: flex;
    gap: 20px;
    align-items: center;
    background: #f8f9fa;
    border: 1px solid #e1e5ea;
    border-radius: 4px;
    padding: 10px 12px;
    margin: 10px 0 15px 0;
}
.multiship-summary .ms-summary-line { color: #333; }
.multiship-summary strong { margin-right: 6px; }

/* Order summary table */
.ms-order-summary-table {
    width: 100%;
    margin-top: 10px;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #e1e5ea;
}
.ms-order-summary-table th,
.ms-order-summary-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #eef1f4;
}
.ms-order-summary-table thead th {
    background: #f8f9fa;
    font-weight: 600;
}
.ms-order-summary-table tfoot th {
    background: #f8f9fa;
}
.ms-order-summary-table .muted { color: #6c757d; }

/* Keep summary select compact */
.ms-ship-method-select {
    width: 130px;
}

/* Ensure prices align right consistently */
.ms-col-subtotal, .ms-col-shipping, .ms-col-tax, .ms-col-total {
    text-align: right;
}

/* Gift note section */
.ms-gift-all { margin: 12px 0 16px 0; padding: 12px; background: #f9fbfd; border: 1px solid #e1e5ea; border-radius: 4px; }
.ms-gift-all h4 { margin: 0 0 8px 0; }
.ms-gift-note-wrap { margin-top: 8px; }
.ms-gift-note { width: 100%; box-sizing: border-box; }