/* RESET & FONTS */
.sam-app-container, .sam-fe-dashboard {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #1a1a1a;
    box-sizing: border-box;
}

.sam-app-container * { box-sizing: border-box; }

/* 1. ADMIN HEADER */
.sam-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 30px 0 20px 0;
    margin-bottom: 20px;
}

.sam-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin: 0;
    color: #111;
}

.subtitle {
    font-size: 14px;
    color: #666;
    margin: 5px 0 0 0;
}

/* SEARCH FORM */
.sam-search-form {
    display: flex;
    gap: 8px;
}
.sam-search-form input {
    padding: 6px 12px;
    border: 1px solid #7e8993;
    border-radius: 4px;
    width: 250px;
}

/* 2. CARD GRID */
.sam-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.sam-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    border: 1px solid #edf2f7;
    padding: 24px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.sam-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.sam-card-top {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.sam-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.sam-identity h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
}

.sam-company {
    font-size: 13px;
    color: #718096;
}

.sam-card-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    background: #f7fafc;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.stat-box {
    display: flex;
    flex-direction: column;
}

.stat-box .label {
    font-size: 10px;
    text-transform: uppercase;
    color: #a0aec0;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.stat-box .value {
    font-size: 16px;
    font-weight: 700;
    color: #2d3748;
}

.sam-card-footer {
    border-top: 1px solid #edf2f7;
    padding-top: 15px;
    text-align: right;
}

.edit-link {
    font-size: 12px;
    font-weight: 600;
    color: #007cba; /* WP standard blue */
}

/* NEW TABLE STYLES */
.sam-table-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    border: 1px solid #e2e4e7;
    overflow: hidden;
}
.sam-admin-table {
    width: 100%;
    border-collapse: collapse;
}
.sam-admin-table th {
    background: #f8f9fa;
    text-align: left;
    padding: 15px;
    font-weight: 600;
    border-bottom: 1px solid #e2e4e7;
}
.sam-admin-table td {
    padding: 15px;
    border-bottom: 1px solid #f0f0f1;
    color: #3c434a;
}
.sam-admin-table tr:hover { background: #fafafa; }

/* 3. MODAL OVERLAY */
.sam-modal-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.sam-modal-panel {
    background: #fff;
    width: 600px;
    max-width: 90%;
    border-radius: 8px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    overflow: hidden;
    animation: samPop 0.3s ease-out;
}

@keyframes samPop {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.sam-modal-header {
    padding: 20px 30px;
    border-bottom: 1px solid #edf2f7;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sam-modal-header h2 { margin: 0; font-size: 20px; }
.sam-close-icon { font-size: 24px; cursor: pointer; color: #aaa; }
.sam-close-icon:hover { color: #333; }

.sam-form-body {
    padding: 30px;
    display: flex;
    gap: 30px;
}

/* Order Details Styles */
.sam-detail-row {
    margin-bottom: 15px;
    font-size: 14px;
}
.sam-detail-row label {
    font-weight: 600;
    width: 100px;
    display: inline-block;
    color: #555;
}

.sam-upload-section {
    width: 120px;
    text-align: center;
    flex-shrink: 0;
}

.sam-image-placeholder {
    width: 100px; height: 100px;
    background: #f0f2f5;
    border-radius: 50%;
    margin: 0 auto 15px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 12px;
    overflow: hidden;
    border: 2px dashed #ddd;
}

.sam-image-placeholder.has-image { border: none; }
.sam-image-placeholder img { width: 100%; height: 100%; object-fit: cover; }

.sam-fields-section { flex-grow: 1; }

.sam-input-group { margin-bottom: 15px; }
.sam-row { display: flex; gap: 15px; }
.sam-row .sam-input-group { flex: 1; }

.sam-fields-section label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #4a5568;
}

.sam-fields-section input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #7e8993; /* WP standard border */
    border-radius: 4px;
    font-size: 14px;
}

.sam-helper { font-size: 11px; color: #d63638; display:block; margin-top:4px; }

.sam-modal-footer {
    padding: 20px 30px;
    background: #f8fafc;
    border-top: 1px solid #edf2f7;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* 4. FRONTEND DASHBOARD (My Account) */
.sam-fe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.sam-fe-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 25px;
    text-align: center;
}

.sam-fe-card.highlight {
    background: #fff;
    border: 2px solid #00adef; /* Fallback */
    border-color: var(--wc-primary, #00adef);
    color: #333;
}

.sam-fe-card h5 { margin: 0 0 10px 0; font-size: 14px; font-weight: 500; color:#666; }

.fe-number { font-size: 28px; font-weight: 700; }

.sam-fe-promo {
    background: #f7fafc;
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 40px;
    text-align: center;
    border: 1px dashed #cbd5e0;
}

.fe-promo-label {
    margin-bottom: 15px;
    font-weight: 600;
    color: #4a5568;
}

.fe-copy-wrapper {
    display: flex;
    max-width: 500px;
    margin: 0 auto;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.fe-copy-wrapper input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #e2e8f0;
    border-right: none;
    border-radius: 6px 0 0 6px;
    background: #fff;
    color: #4a5568;
}

/* WooCommerce Button inherits theme styles automatically */
.fe-copy-wrapper button {
    border-radius: 0 6px 6px 0 !important;
    margin: 0 !important;
}

.sam-fe-list h3 { font-size: 18px; margin-bottom: 20px; }

.sam-table-responsive {
    overflow-x: auto;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
}

.sam-table-responsive table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    background: white;
}

.sam-table-responsive th, .sam-table-responsive td {
    padding: 15px 20px;
    border-bottom: 1px solid #f0f2f5;
    text-align: left;
}

.sam-table-responsive th {
    background: #f8fafc;
    font-weight: 600;
    color: #4a5568;
    font-size: 13px;
    text-transform: uppercase;
}

.text-right { text-align: right !important; }
.success-text { color: #38a169; font-weight: 600; }

.sam-payout-notice {
    margin-top: 30px;
    font-size: 14px;
    color: #718096;
    background: #fffaf0;
    border-left: 4px solid #ed8936;
    padding: 15px;
}
/* Added: Delete affiliate button */
.button.button-link-delete {
    color: #d63638 !important;
    text-decoration: none;
    padding: 0;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    font-weight: 600;
    cursor: pointer;
}
.button.button-link-delete:hover {
    color: #a30000 !important;
    text-decoration: underline;
}
/* Reference field styling */
#sam_reference_field {
    margin-top: 1em;
}
#sam_reference_field .woocommerce-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}
#sam_reference_field input[type="text"] {
    background: #f8f9fa !important;
    color: #2d3748 !important;
    border: 1px solid #e2e8f0 !important;
    cursor: not-allowed;
}
#sam_reference_field label {
    font-weight: 600;
    color: #2d3748;
}
/* Reference field styling */
#sam_reference_field {
    margin-top: 1em;
}
#sam_reference_field .woocommerce-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}
#sam_reference_field input[type="text"] {
    background: #f8f9fa !important;
    color: #2d3748 !important;
    border: 1px solid #e2e8f0 !important;
    cursor: not-allowed;
}
#sam_reference_field label {
    font-weight: 600;
    color: #2d3748;
}

/* Delete button */
.button.button-link-delete {
    color: #d63638 !important;
    text-decoration: none;
    padding: 0;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    font-weight: 600;
    cursor: pointer;
}
.button.button-link-delete:hover {
    color: #a30000 !important;
    text-decoration: underline;
}