/**
 * NSP Referral System - Frontend Styles
 */

/* ========================================
   Referral Button - Single Product (Woodmart style)
   ======================================== */

/* Make Woodmart action button wrappers inline */
.wd-single-action-btn {
    display: inline-block !important;
    margin-right: 15px !important;
}

/* Woodmart action button style - share icon */
span.nsp-referral-btn.wd-action-btn.wd-referral-icon,
.nsp-referral-btn.wd-action-btn.wd-referral-icon {
    display: inline-block !important;
    vertical-align: middle !important;
    white-space: nowrap;
}

.nsp-referral-btn.wd-action-btn.wd-referral-icon > a {
    display: inline-flex;
    align-items: center;
    font-weight: 600;
    line-height: 1;
}

.nsp-referral-btn.wd-action-btn.wd-referral-icon > a:before {
    content: "\f117"; /* Woodmart share icon */
    font-family: 'woodmart-font';
    margin-right: 0.3em;
    font-weight: 400;
}

/* Copy link functionality */
.nsp-referral-btn .nsp-copy-link {
    cursor: pointer;
}

.nsp-referral-btn .nsp-copy-link:hover {
    color: var(--wd-primary-color, #83b735);
}

/* Success state after copy */
.nsp-referral-btn.copied > a {
    color: #4caf50 !important;
}

.nsp-referral-btn.copied > a:before {
    content: "\f107"; /* Woodmart check icon */
}

/* Legacy button style (for shortcodes) */
.nsp-referral-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.nsp-referral-button:hover {
    background-color: #e8e8e8;
    border-color: #ccc;
    color: #000;
}

.nsp-referral-button:active {
    background-color: #ddd;
    transform: translateY(1px);
}

.nsp-referral-button.copied {
    background-color: #4caf50;
    border-color: #4caf50;
    color: #fff;
}

.nsp-referral-button .nsp-referral-icon-svg {
    flex-shrink: 0;
}

/* ========================================
   Referral Icon - Archive/Loop
   ======================================== */

.nsp-referral-icon-wrapper {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 10;
}

/* Position variants */
.nsp-referral-icon-wrapper.top-right {
    left: auto;
    right: 10px;
}

.nsp-referral-icon-wrapper.bottom-left {
    top: auto;
    bottom: 10px;
}

.nsp-referral-icon-wrapper.bottom-right {
    top: auto;
    bottom: 10px;
    left: auto;
    right: 10px;
}

.nsp-referral-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: all 0.2s ease;
}

.nsp-referral-icon:hover {
    background-color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transform: scale(1.1);
}

.nsp-referral-icon:active {
    transform: scale(0.95);
}

.nsp-referral-icon.copied {
    background-color: #4caf50;
    color: #fff;
}

.nsp-referral-icon.copied svg {
    stroke: #fff;
}

.nsp-referral-icon svg {
    width: 18px;
    height: 18px;
    stroke: #666;
    transition: stroke 0.2s ease;
}

.nsp-referral-icon:hover svg {
    stroke: #333;
}

/* Woodmart theme compatibility */
.nsp-referral-icon-wrapper.woodmart-position {
    position: absolute;
    top: 10px;
    left: 10px;
}

/* ========================================
   Tooltip
   ======================================== */

.nsp-tooltip {
    position: fixed;
    padding: 8px 12px;
    background-color: #333;
    color: #fff;
    font-size: 12px;
    border-radius: 4px;
    z-index: 99999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.nsp-tooltip.visible {
    opacity: 1;
}

.nsp-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #333;
}

/* Success tooltip */
.nsp-tooltip.success {
    background-color: #4caf50;
}

.nsp-tooltip.success::after {
    border-top-color: #4caf50;
}

/* ========================================
   My Account - Referral Section
   ======================================== */

.nsp-referral-account-section {
    max-width: 800px;
}

.nsp-referral-account-section h2 {
    margin-bottom: 20px;
    font-size: 1.5em;
}

.nsp-referral-account-section h3 {
    margin: 25px 0 15px;
    font-size: 1.2em;
}

.nsp-referral-info {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 4px;
}

.nsp-referral-link-container {
    margin: 20px 0;
}

.nsp-referral-link-container label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.nsp-referral-link-input-wrapper {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.nsp-referral-link-input {
    flex: 1;
    min-width: 250px;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background-color: #f9f9f9;
}

.nsp-referral-link-input:focus {
    outline: none;
    border-color: #007bff;
    background-color: #fff;
}

.nsp-copy-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    white-space: nowrap;
}

.nsp-copy-button.copied {
    background-color: #4caf50;
    border-color: #4caf50;
    color: #fff;
}

.nsp-referral-link-container .description {
    margin-top: 10px;
    color: #666;
    font-size: 13px;
}

/* How to use section */
.nsp-referral-how-to {
    margin: 25px 0;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 4px;
    border-left: 4px solid #007bff;
}

.nsp-referral-how-to ol {
    margin: 0 0 15px 20px;
    padding: 0;
}

.nsp-referral-how-to li {
    margin-bottom: 8px;
}

.nsp-referral-how-to .tip {
    margin: 15px 0 0;
    padding: 10px 15px;
    background-color: #fff3cd;
    border-radius: 4px;
    font-size: 13px;
}

/* Statistics section */
.nsp-referral-stats {
    margin-top: 30px;
}

.nsp-referral-stats .stats-grid {
    display: flex;
    gap: 20px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.nsp-referral-stats .stat-item {
    flex: 1;
    min-width: 150px;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    text-align: center;
}

.nsp-referral-stats .stat-value {
    display: block;
    font-size: 2em;
    font-weight: 700;
    color: #333;
    margin-bottom: 5px;
}

.nsp-referral-stats .stat-label {
    display: block;
    font-size: 14px;
    color: #666;
}

.nsp-referral-stats h4 {
    margin: 25px 0 15px;
    font-size: 1.1em;
}

.nsp-referral-stats .woocommerce-orders-table {
    margin-top: 15px;
}

/* ========================================
   Checkout - Auto-filled Field
   ======================================== */

.nsp-autofilled input {
    background-color: #f0fff0 !important;
    border-color: #90ee90 !important;
}

.nsp-autofilled label::after {
    content: ' ✓';
    color: #4caf50;
}

/* ========================================
   Admin - Order Column
   ======================================== */

.nsp-referral-indicator {
    cursor: help;
}

.nsp-referral-badge {
    display: inline-block;
    padding: 2px 8px;
    background-color: #4caf50;
    color: #fff;
    border-radius: 3px;
    font-size: 12px;
}

/* Admin order details */
.nsp-referral-admin-info {
    margin-top: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-left: 4px solid #007bff;
}

.nsp-referral-admin-info h3 {
    margin: 0 0 10px;
    font-size: 14px;
}

.nsp-referral-admin-info p {
    margin: 5px 0;
}

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

@media (max-width: 768px) {
    .nsp-referral-button-wrapper.single-product {
        margin-left: 0;
        margin-top: 10px;
        display: block;
    }

    /* Mobile: Keep wrappers inline */
    .wd-single-action-btn {
        display: inline-block !important;
        margin-right: 10px !important;
    }

    .nsp-referral-link-input-wrapper {
        flex-direction: column;
    }

    .nsp-referral-link-input {
        min-width: 100%;
    }

    .nsp-referral-stats .stats-grid {
        flex-direction: column;
    }

    .nsp-referral-stats .stat-item {
        min-width: 100%;
    }
}

/* ========================================
   RTL Support
   ======================================== */

[dir="rtl"] .nsp-referral-button-wrapper.single-product {
    margin-left: 0;
    margin-right: 10px;
}

[dir="rtl"] .nsp-referral-icon-wrapper {
    left: auto;
    right: 10px;
}

[dir="rtl"] .nsp-referral-icon-wrapper.top-right {
    right: auto;
    left: 10px;
}

[dir="rtl"] .nsp-referral-how-to {
    border-left: none;
    border-right: 4px solid #007bff;
}

[dir="rtl"] .nsp-referral-admin-info {
    border-left: none;
    border-right: 4px solid #007bff;
}
