/*
 * MSPA v4 - Modern Dark Theme
 * A flat, modern dark-mode experience with accent glows.
 * Enhanced with a full color palette, transitions, and dark-mode native components.
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg-main: #23272a;
    --bg-controls: #2c2f33;
    --bg-card: #36393f;
    --bg-input: #40444b;
    --bg-hover: #40444b;
    --bg-disabled: #2c2f33;
    
    --text-primary: #ffffff;
    --text-secondary: #b9bbbe;
    --text-subtle: #8e9297;
    --text-accent: #7289da;
    --text-success: #43b581;
    --text-on-accent: #ffffff;
    
    --border-primary: #40444b;
    --border-secondary: #555;
    --border-accent: #7289da;

    --shadow-accent-glow: 0 0 8px 0px rgba(114, 137, 218, 0.4);
}

/* --- Main Container & Controls --- */
.mspa-container {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-secondary);
    padding: 20px;
    border-radius: 8px;
}
.rich-header.page-header { display: none !important; }

.mspa-controls { 
    display: flex; flex-wrap: wrap; gap: 15px 20px; align-items: flex-end; 
    padding: 20px; background-color: var(--bg-controls); border: 1px solid var(--border-primary); 
    margin-bottom: 20px; border-radius: 6px; 
}
.mspa-control-group { display: flex; flex-direction: column; flex-grow: 1; min-width: 160px; }
.mspa-control-group label { font-weight: 500; margin-bottom: 6px; font-size: 14px; color: var(--text-secondary); }
.mspa-control-group input, .mspa-control-group select { 
    padding: 8px 12px; border: 1px solid var(--border-secondary); border-radius: 4px; 
    width: 100%; background: var(--bg-input); color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.mspa-control-group input:focus, .mspa-control-group select:focus {
    outline: none; border-color: var(--border-accent); box-shadow: var(--shadow-accent-glow);
}
.mspa-control-group-button { flex-grow: 0; }
.mspa-control-group-button .button { padding: 6px 16px; height: 37px; }


/* --- Header Area (Count, Switches, Loader) --- */
.mspa-table-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; padding: 0 5px; min-height: 30px; }
#mspa-results-count { color: var(--text-subtle); font-size: 14px; flex-grow: 1; }
.mspa-view-switcher, .mspa-theme-switcher { display: flex; gap: 5px; margin-left: 15px; }
.mspa-view-button, .mspa-theme-button {
    background: var(--bg-input); border: 1px solid var(--border-secondary); padding: 5px 10px;
    cursor: pointer; border-radius: 4px; color: var(--text-primary); line-height: 1; font-size: 13px;
    transition: all 0.2s ease;
}
.mspa-view-button:hover, .mspa-theme-button:hover { background: var(--bg-hover); border-color: #666; }
.mspa-view-button.active, .mspa-theme-button.active {
    background: var(--text-accent); border-color: var(--text-accent); color: var(--text-on-accent);
    font-weight: 600; cursor: default;
}
.mspa-view-button .dashicons { font-size: 20px; width: 20px; height: 20px; vertical-align: middle; }
.mspa-loader {
    border: 4px solid var(--bg-input); border-top: 4px solid var(--text-accent); border-radius: 50%;
    width: 24px; height: 24px; animation: mspa-spin-dark 1s linear infinite; margin-left: 15px;
}
@keyframes mspa-spin-dark { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* --- Table View --- */
.mspa-product-table { width: 100%; border-collapse: collapse; }
.mspa-product-table th, .mspa-product-table td { border: 1px solid var(--border-primary); padding: 12px; text-align: left; vertical-align: top; }
.mspa-product-table th { background-color: var(--bg-controls); font-weight: 600; color: var(--text-primary); }
.mspa-product-table tr { background-color: var(--bg-card); transition: background-color 0.2s; }
.mspa-product-table tr:hover { background-color: var(--bg-hover); }
.mspa-product-table td a { font-weight: 500; text-decoration: none; color: var(--text-accent); }
.mspa-product-table td a:hover { text-decoration: underline; }

/* --- Card View --- */
.mspa-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.mspa-card-grid.gridtwo { grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
.mspa-product-card {
    display: flex; flex-direction: column; gap: 15px; background: var(--bg-card);
    border: 1px solid var(--border-primary); border-radius: 6px; padding: 15px;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.mspa-product-card.gridtwo { flex-direction: row; }
.mspa-product-card:hover { transform: translateY(-3px); border-color: var(--border-accent); box-shadow: var(--shadow-accent-glow); }
.mspa-card-image-container { flex-shrink: 0; border-radius: 4px; overflow: hidden; background-color: var(--bg-controls); }
.mspa-card-image-container { height: 180px; width: auto; }
.mspa-card-image-container.gridtwo { width: 120px; height: 120px; }
.mspa-card-image-container img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s ease; }
.mspa-product-card:hover .mspa-card-image-container img { transform: scale(1.08); }
.mspa-card-content { flex-grow: 1; display: flex; flex-direction: column; }
.mspa-card-header h3 { margin: 0 0 5px 0; font-size: 1.1rem; line-height: 1.3; }
.mspa-card-header h3 a { text-decoration: none; color: var(--text-primary); font-weight: 600; transition: color 0.2s; }
.mspa-card-header h3 a:hover { color: var(--text-accent); }
.mspa-card-excerpt { font-size: 14px; color: var(--text-secondary); line-height: 1.5; margin-top: 5px; }
.mspa-card-body { flex-grow: 1; padding-top: 10px; font-size: 14px; color: var(--text-secondary); }
.mspa-card-body > div { margin-bottom: 5px; }
.mspa-card-footer a { color: var(--text-accent); font-size: 13px; text-decoration: none; font-weight: 500; }
.mspa-card-footer a:hover { text-decoration: underline; }

/* --- SKU & QR Code Buttons --- */
.referral-code { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.referral-code kbd { background: var(--bg-controls); padding: 4px 8px; border-radius: 4px; font-size: 13px; color: var(--text-secondary); border: 1px solid var(--border-secondary); }
.referral-code button {
    cursor: pointer; background: 0; border: 0; padding: 0; color: var(--text-subtle); display: flex;
    transition: transform 0.2s, color 0.2s;
}
.referral-code button:hover:not(:disabled) { color: var(--text-primary); transform: scale(1.1); }
.referral-code button svg { width: 22px; height: 22px; fill: currentColor; }
.referral-code button.copied { transform: scale(1.1); color: var(--text-success); }

/* --- QR Code Modal --- */
.mspa-qr-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    display: flex; justify-content: center; align-items: center; z-index: 10000;
}
.mspa-qr-modal-content {
    background-color: var(--bg-card); padding: 25px; border-radius: 8px; position: relative;
    border: 1px solid var(--border-primary); box-shadow: 0 5px 25px rgba(0,0,0,0.3); text-align: center;
}
.mspa-qr-modal-content img { background-color: white; padding: 10px; border-radius: 4px; display: block; max-width: 100%; height: auto; }
#mspa-qr-modal-title { font-size: 18px; font-weight: 600; color: var(--text-primary); margin: 0 0 15px 0; }
.mspa-qr-modal-close {
    position: absolute; top: 5px; right: 10px; font-size: 28px;
    font-weight: bold; color: var(--text-subtle); cursor: pointer; transition: color 0.2s;
}
.mspa-qr-modal-close:hover { color: var(--text-primary); }

/* --- Pagination --- */
.mspa-pagination-wrapper { margin-top: 25px; text-align: center; }
.mspa-pagination-wrapper button { 
    color: var(--text-primary); background: var(--bg-input); border: 1px solid var(--border-secondary);
    padding: 8px 14px; margin: 0 3px; cursor: pointer; border-radius: 4px;
    transition: all 0.2s ease; vertical-align: middle; font-weight: 500;
}
.mspa-pagination-wrapper button:hover:not(:disabled) { background-color: var(--bg-hover); border-color: #666; }
.mspa-pagination-wrapper button.current { 
    background-color: var(--text-accent); border-color: var(--text-accent); cursor: default;
    font-weight: 600; color: var(--text-on-accent);
}
.mspa-pagination-wrapper button:disabled { background-color: var(--bg-disabled); color: var(--text-subtle); cursor: not-allowed; border-color: var(--border-primary); }
.mspa-pagination-ellipsis { display: inline-block; padding: 8px 6px; color: var(--text-subtle); vertical-align: middle; }

/* --- Notices --- */
.mspa-no-results, .mspa-notice {
    padding: 20px; text-align: center; background-color: #2c2f33;
    border: 1px solid #40444b; border-radius: 4px; color: #b9bbbe;
}