/* CSS Variables for consistent theming */
:root {
    --loyalty-primary: #0095ff;
    --loyalty-primary-foreground: #ffffff;
    --loyalty-background: #ffffff;
    --loyalty-foreground: #09090b;
    --loyalty-muted: #f4f4f5;
    --loyalty-muted-foreground: #71717a;
    --loyalty-border: #e4e4e7;
    --loyalty-input: #e4e4e7;
    --loyalty-ring: #0095ff;
    --radius: 0.5rem;
}

/* Floating Button */
#loyalty-widget-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 10px 16px;
    background: #006eff;
    color: #ffffff;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 600;
    font-size: 14px;
    z-index: 9999;
    min-width: 120px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#loyalty-widget-btn:hover {
    opacity: 0.9;
}

/* Modal Overlay */
.loyalty-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.loyalty-modal.is-open {
    display: flex;
}

/* Modal Content */
.loyalty-modal-content {
    background-color: var(--loyalty-background);
    color: var(--loyalty-foreground);
    padding: 32px;
    border: 1px solid var(--loyalty-border);
    border-radius: 12px;
    width: 90%;
    max-width: 380px;
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    animation: fadeIn 0.2s ease-out;
    max-height: 90vh;
    overflow-y: auto;
}

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

/* Close Button */
.loyalty-close {
    color: var(--loyalty-muted-foreground);
    float: right;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    background: transparent;
    border: none;
    font-family: inherit;
}

.loyalty-close:hover {
    color: var(--loyalty-foreground);
}

/* Typography */
.loyalty-modal-content h2 {
    margin: 0 0 4px 0;
    color: var(--loyalty-foreground);
    font-size: 18px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
}

.loyalty-modal-content p {
    color: var(--loyalty-muted-foreground);
    font-size: 14px;
    text-align: center;
    margin: 0 0 16px 0;
}

/* Header Section */
.loyalty-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.loyalty-header-text {
    text-align: center;
}

.loyalty-header-text h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--loyalty-foreground);
}

.loyalty-header-text p {
    margin: 0;
    font-size: 13px;
    color: var(--loyalty-muted-foreground);
}

/* Balance Card */
.loyalty-balance-card {
    background: #0095ff;
    border-radius: 16px;
    padding: 32px 24px;
    margin: 0 0 24px 0;
    color: white;
    text-align: center;
}

.loyalty-points {
    display: block;
    font-size: 48px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.02em;
}

.loyalty-points-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-top: 8px;
    opacity: 0.9;
}

/* Rewards List */
.loyalty-reward-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--loyalty-border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    background: #ffffff;
    transition: all 0.2s ease;
}

.loyalty-reward-item:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.loyalty-reward-details {
    flex: 1;
    margin-right: 16px;
    text-align: left;
}

.loyalty-reward-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--loyalty-foreground);
    margin-bottom: 4px;
    line-height: 1.4;
}

.loyalty-reward-cost {
    font-size: 13px;
    color: var(--loyalty-muted-foreground);
    display: flex;
    align-items: center;
    gap: 4px;
}

.loyalty-reward-apply {
    background: var(--loyalty-primary);
    color: var(--loyalty-primary-foreground);
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    min-width: 80px;
    text-align: center;
    display: inline-block;
}

.loyalty-reward-apply:hover {
    opacity: 0.85;
    background: var(--loyalty-primary); /* Keep background consistent, just opacity */
}

.loyalty-reward-apply:disabled,
.loyalty-reward-apply.is-processing {
    background: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
    transform: none;
    pointer-events: none;
}

/* Rewards Section */
.loyalty-rewards-section {
    margin-bottom: 20px;
}

.loyalty-rewards-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--loyalty-foreground);
    margin: 0 0 12px 0;
}

.loyalty-rewards-empty {
    background: var(--loyalty-muted);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
}

.loyalty-rewards-empty p {
    margin: 0;
    color: var(--loyalty-muted-foreground);
    font-size: 14px;
}

/* Form Styles */
.loyalty-form-group {
    margin-bottom: 16px !important;
    text-align: left !important;
}

.loyalty-form-group label {
    display: block !important;
    margin-bottom: 6px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    color: var(--loyalty-foreground) !important;
}

.loyalty-form-group .required {
    color: #ef4444 !important;
}

.loyalty-form-group input {
    width: 100% !important;
    padding: 10px 12px !important;
    border-radius: 8px !important;
    border: 1px solid var(--loyalty-input) !important;
    background-color: transparent !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    color: var(--loyalty-foreground) !important;
    transition: border-color 0.2s, box-shadow 0.2s !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    height: 42px !important; /* Fixed height for consistency */
    max-width: 100% !important;
    box-shadow: none !important;
}

.loyalty-form-group input:focus {
    border-color: var(--loyalty-ring);
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05); /* very subtle ring */
}

.loyalty-form-group input.error {
    border-color: #ef4444;
}

.loyalty-input-hint {
    display: block;
    font-size: 11px;
    color: var(--loyalty-muted-foreground);
    margin-top: 4px;
}

/* Buttons */
.loyalty-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    margin-bottom: 8px;
}

.loyalty-btn-primary {
    background: var(--loyalty-primary);
    color: var(--loyalty-primary-foreground);
}

.loyalty-btn-primary:hover {
    opacity: 0.85;
}

.loyalty-btn-outline {
    background: transparent;
    border: 1px solid var(--loyalty-border);
    color: var(--loyalty-foreground);
}

.loyalty-btn-outline:hover {
    background: var(--loyalty-muted);
}

/* Disabled State */
.loyalty-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Action Items (clickable divs) */
.loyalty-action-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 14px 20px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: opacity 0.15s ease;
    text-align: center;
    box-sizing: border-box;
    margin-top: 12px;
    gap: 8px;
    user-select: none;
    border: none;
    font-family: inherit;
}

.loyalty-action-item:hover {
    opacity: 0.85;
}

.loyalty-action-install {
    background: #0095ff;
    color: white;
}

.loyalty-action-danger {
    background: #dc2626;
    color: white;
    font-size: 12px;
    margin-top: 15px;
}

.loyalty-action-icon {
    font-size: 16px;
}

/* Loading State */
.loyalty-loading {
    padding: 32px 16px;
    text-align: center;
}

.loyalty-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--loyalty-muted);
    border-top-color: var(--loyalty-primary);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Message Helpers */
.loyalty-message {
    margin-top: 12px;
    font-size: 13px;
    text-align: center;
}

.loyalty-message.success {
    color: #10b981;
}

.loyalty-message.error {
    color: #ef4444;
}

/* Views */
.loyalty-signup-view .loyalty-icon,
.loyalty-error-view .loyalty-icon {
    font-size: 32px;
    margin-bottom: 16px;
    display: block;
    text-align: center;
    width: 100%;
}

/* Coupon Card Styles */
.loyalty-coupon-card {
    background-color: var(--loyalty-success-bg);
    border: 1px dashed var(--loyalty-success-border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    text-align: center;
}

.loyalty-coupon-header {
    color: var(--loyalty-success-text);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.loyalty-coupon-code-box {
    background: #ffffff;
    border: 1px solid var(--loyalty-success-border);
    border-radius: 6px;
    padding: 10px 16px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 18px;
    font-weight: 700;
    color: var(--loyalty-success-text);
    letter-spacing: 1px;
    margin-bottom: 6px;
    display: inline-block;
    user-select: all; /* Make easy to copy */
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.loyalty-coupon-hint {
    color: var(--loyalty-success-text);
    font-size: 12px;
    opacity: 0.8;
}
