/* --- Main Container & Controls --- */
.mspa-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}
.mspa-controls { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 15px 20px; 
    align-items: flex-end; 
    padding: 15px; 
    background-color: #f9f9f9; 
    border: 1px solid #ddd; 
    margin-bottom: 20px; 
    border-radius: 4px; 
}
.mspa-control-group { 
    display: flex; 
    flex-direction: column; 
    flex-grow: 1;
    min-width: 160px;
}
#mspa-per-page-select {
    min-width: 80px;
    flex-grow: 0;
}
.mspa-control-group label { 
    font-weight: bold; 
    margin-bottom: 5px; 
    font-size: 14px; 
    color: #444;
}
.mspa-control-group input[type="text"], 
.mspa-control-group select { 
    padding: 8px; 
    border: 1px solid #ccc; 
    border-radius: 4px; 
    width: 100%;
}
.mspa-control-group-button {
    flex-grow: 0;
}
.mspa-control-group-button .button {
    padding: 6px 16px;
    height: 37px; /* Align with other inputs */
}

/* --- Table Header (Results Count & Loader) --- */
.mspa-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 0 5px;
    min-height: 30px;
}
#mspa-results-count {
    color: #555;
    font-size: 14px;
    flex-grow: 1;
}

/* --- View Switcher --- */
.mspa-view-switcher {
    display: flex;
    gap: 5px;
    margin: 0 15px;
}
.mspa-view-button {
    background: #f9f9f9;
    border: 1px solid #ccc;
    padding: 4px;
    cursor: pointer;
    border-radius: 3px;
    color: #555;
    line-height: 1;
}
.mspa-view-button:hover {
    background: #fff;
    border-color: #999;
}
.mspa-view-button.active {
    background: #e0e0e0;
    border-color: #999;
    color: #000;
    cursor: default;
}
.mspa-view-button .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

/* --- Loader Spinner --- */
.mspa-loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: mspa-spin 1s linear infinite;
}
@keyframes mspa-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- Results Area --- */
#mspa-results-area {
    margin-top: 10px;
}
.mspa-no-results {
    background-color: #fff8e1;
    padding: 20px;
    text-align: center;
    border: 1px solid #ffecb3;
    border-radius: 4px;
}

/* --- Product Table --- */
.mspa-product-table { 
    width: 100%; 
    border-collapse: collapse; 
}
.mspa-product-table th, 
.mspa-product-table td { 
    border: 1px solid #ddd; 
    padding: 12px; 
    text-align: left; 
    vertical-align: top;
}
.mspa-product-table th { 
    background-color: #f2f2f2; 
    font-weight: 600;
}
.mspa-product-table td a {
    font-weight: 500;
}
.mspa-product-table td div {
    margin-bottom: 5px;
}
.mspa-product-table td div:last-child {
    margin-bottom: 0;
}
.mspa-product-table .mspa-excerpt-cell {
    max-width: 350px;
    font-size: 13px;
    color: #555;
    font-style: italic;
    line-height: 1.4;
}

/* --- Card View --- */
.mspa-card-grid {
    display: grid;
    /* Adjusted min-width for wider cards with images */
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    gap: 20px;
}
.mspa-product-card {
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    display: flex; /* Key change: enables side-by-side layout */
    padding: 15px; /* Add padding to the card itself */
    gap: 15px;     /* Creates space between image and content */
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s;
}
.mspa-product-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* NEW: Image container styles */
.mspa-card-image-container {
    flex: 0 0 100px; /* Fixed width of 100px */
    height: 100px;
}
.mspa-card-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Ensures image fills the container */
    border-radius: 4px;
}
.mspa-card-image-placeholder {
    width: 100%;
    height: 100%;
    background-color: #f0f0f1;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #a0a5aa;
}
.mspa-card-image-placeholder .dashicons {
    font-size: 40px;
    width: 40px;
    height: 40px;
}

/* NEW: Content wrapper to hold text details */
.mspa-card-content {
    flex: 1; /* Takes up remaining space */
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevents content overflow from breaking layout */
}

/* MODIFIED: Child elements of the card */
.mspa-card-header {
    padding: 0 0 10px 0;
    border-bottom: 1px solid #eee;
}
.mspa-card-header h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
}
.mspa-card-header h3 a {
    text-decoration: none;
    color: #1d2327;
}
.mspa-card-price {
    font-size: 14px;
    font-weight: bold;
    color: #444;
}
.mspa-card-body {
    padding: 10px 0;
    flex-grow: 1; /* Pushes footer down */
    font-size: 14px;
    color: #555;
}
.mspa-card-body div {
    margin-bottom: 8px;
}
.mspa-card-excerpt {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #e0e0e0;
    font-size: 13px;
    color: #555;
    font-style: italic;
    line-height: 1.4;
}
.mspa-card-footer {
    padding: 10px 0 0 0;
    border-top: 1px solid #eee;
    background-color: transparent;
    font-size: 13px;
    margin-top: auto; /* Aligns to bottom of flex container */
}
.mspa-card-footer div {
    margin-bottom: 5px;
}
.mspa-card-footer div:last-child {
    margin-bottom: 0;
}


/* --- Pagination --- */
.mspa-pagination-wrapper { 
    margin-top: 20px; 
    text-align: center; 
}
.mspa-pagination-wrapper button { 
    background: #fff; 
    border: 1px solid #ccc; 
    padding: 8px 12px; 
    margin: 0 2px; 
    cursor: pointer; 
    border-radius: 4px; 
    transition: background-color 0.2s;
}
.mspa-pagination-wrapper button:hover:not(:disabled) { 
    background-color: #e9e9e9; 
    border-color: #999;
}
.mspa-pagination-wrapper button.current { 
    background-color: #f2f2f2; 
    font-weight: bold; 
    cursor: default;
    border-color: #999;
}
.mspa-pagination-wrapper button:disabled { 
    background-color: #fafafa; 
    color: #ccc; 
    cursor: not-allowed; 
}

/* --- Notices --- */
.mspa-notice {
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    border-radius: 4px;
}
.mspa-notice-warning {
    color: #8a6d3b;
    background-color: #fcf8e3;
    border-color: #faebcc;
}