/**
 * Frontend-stilar för SV Lojalitet
 */

/* Allmänna stilar */
.sv-loyalty-dashboard,
.sv-loyalty-account-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.sv-loyalty-notice {
    background: #f0f0f0;
    border-left: 4px solid #0073aa;
    padding: 15px 20px;
    margin: 20px 0;
    border-radius: 4px;
}

/* Dashboard-header */
.dashboard-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
}

.dashboard-header h2 {
    margin: 0 0 10px 0;
    font-size: 2em;
}

.dashboard-header p {
    margin: 0;
    opacity: 0.9;
}

/* Poängöversikt */
.sv-loyalty-points-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.points-card {
    background: white;
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.points-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15);
}

.points-card.current {
    border-top: 4px solid #667eea;
}

.points-card.earned {
    border-top: 4px solid #28a745;
}

.points-card.redeemed {
    border-top: 4px solid #ffc107;
}

.points-icon {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.points-value {
    font-size: 2.5em;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.points-label {
    color: #666;
    font-size: 0.95em;
}

/* Sektioner */
.sv-loyalty-section {
    margin-bottom: 40px;
}

.sv-loyalty-section h3 {
    font-size: 1.5em;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
    color: #333;
}

/* Belöningskort */
.rewards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.reward-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.reward-card.can-redeem {
    border-color: #28a745;
}

.reward-card.cannot-redeem {
    opacity: 0.8;
}

.reward-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.reward-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.reward-header h4 {
    margin: 0;
    font-size: 1.2em;
    color: #333;
}

.points-required {
    background: #667eea;
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
}

.reward-description {
    color: #666;
    margin-bottom: 15px;
    line-height: 1.5;
}

.reward-value {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-weight: 600;
    color: #28a745;
    text-align: center;
}

/* Progress bar */
.reward-progress {
    margin-bottom: 15px;
}

.progress-bar {
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.progress-text {
    font-size: 0.85em;
    color: #666;
}

/* Knappar */
.redeem-reward-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.redeem-reward-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.redeem-reward-btn:disabled,
.button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Användarbelöningar */
.user-rewards-list {
    display: grid;
    gap: 15px;
}

.user-reward-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.user-reward-card.active {
    border-left: 4px solid #28a745;
}

.user-reward-card.expired {
    border-left: 4px solid #dc3545;
    opacity: 0.7;
}

.reward-info {
    flex: 1;
}

.reward-info h4 {
    margin: 0 0 5px 0;
    color: #333;
}

.reward-info p {
    margin: 0 0 10px 0;
    color: #666;
    font-size: 0.9em;
}

.coupon-code {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.coupon-code label {
    font-weight: 600;
    color: #666;
}

.coupon-code code {
    background: #f8f9fa;
    padding: 8px 15px;
    border-radius: 6px;
    font-size: 1.1em;
    color: #667eea;
    font-weight: bold;
    border: 2px dashed #667eea;
}

.copy-coupon {
    padding: 8px 15px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.3s ease;
}

.copy-coupon:hover {
    background: #5a6fd6;
}

.expiry-date {
    font-size: 0.85em;
    color: #666;
}

.expired-badge {
    background: #dc3545;
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
}

/* Poänghistorik-tabell */
.sv-loyalty-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.points-history-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.points-history-table th,
.points-history-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.points-history-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
}

.points-history-table tr:last-child td {
    border-bottom: none;
}

.points-history-table .positive {
    color: #28a745;
    font-weight: 600;
}

.points-history-table .negative {
    color: #dc3545;
    font-weight: 600;
}

/* Kassa-notis */
.sv-loyalty-checkout-notice {
    background: #e7f3ff;
    border: 1px solid #b3d9ff;
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 20px;
}

.sv-loyalty-checkout-notice p {
    margin: 0;
    color: #004085;
}

.sv-loyalty-checkout-notice a {
    color: #667eea;
    font-weight: 600;
}

/* Produktpoäng (teman döljer ofta extra innehåll i summary på mobil — håll synlig) */
.sv-loyalty-product-points {
    background: #f8f9fa;
    padding: 12px 15px;
    border-radius: 8px;
    margin: 15px 0;
    display: flex !important;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    clear: both;
    position: relative;
    z-index: 2;
    visibility: visible !important;
    opacity: 1 !important;
}

.sv-loyalty-product-points .points-icon {
    font-size: 1.5em;
    flex-shrink: 0;
}

.sv-loyalty-product-points__text {
    flex: 1;
    min-width: 0;
    line-height: 1.4;
}

.woocommerce div.product .sv-loyalty-product-points {
    float: none;
}

/* Tack-sida */
.sv-loyalty-thankyou {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.sv-loyalty-thankyou h3 {
    margin: 0 0 15px 0;
    color: #155724;
}

.sv-loyalty-thankyou p {
    margin: 0 0 10px 0;
    color: #155724;
}

.sv-loyalty-thankyou ul {
    margin: 0;
    padding-left: 20px;
    color: #155724;
}

/* Orderdetaljer */
.sv-loyalty-order-details {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
}

.sv-loyalty-order-details h4 {
    margin: 0 0 10px 0;
    color: #333;
}

/* Poäng-display shortcode */
.sv-loyalty-points-display {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #667eea;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
}

/* Responsiv design */
@media (max-width: 768px) {
    .sv-loyalty-points-overview {
        grid-template-columns: 1fr;
    }
    
    .rewards-grid {
        grid-template-columns: 1fr;
    }
    
    .user-reward-card {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .points-history-table {
        font-size: 0.9em;
    }
    
    .points-history-table th,
    .points-history-table td {
        padding: 10px;
    }
    
    .dashboard-header {
        padding: 20px;
    }
    
    .dashboard-header h2 {
        font-size: 1.5em;
    }

    .sv-loyalty-product-points {
        margin: 12px 0;
        padding: 12px;
        font-size: 0.95rem;
    }

    .sv-loyalty-product-points .points-icon {
        font-size: 1.35em;
    }
}

/* Animationer */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sv-loyalty-dashboard > * {
    animation: fadeIn 0.5s ease forwards;
}

/* Laddningsindikator */
.sv-loyalty-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Success/Error meddelanden */
.sv-loyalty-message {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}

.sv-loyalty-message.success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.sv-loyalty-message.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* Varukorg - Poängvisning */
.sv-loyalty-cart-points {
    background: #f8f9fa;
}

.sv-loyalty-cart-points th {
    color: #667eea;
}

.sv-loyalty-cart-points .points-earned {
    color: #28a745;
    font-weight: 600;
    font-size: 1.1em;
}

.sv-loyalty-cart-item-points {
    margin: 5px 0 0 0;
    color: #28a745;
}

.sv-loyalty-cart-item-points small {
    font-size: 0.85em;
}

/* Kassa-notis förbättringar */
.sv-loyalty-checkout-notice .loyalty-link {
    margin-top: 10px;
    font-size: 0.95em;
}

.sv-loyalty-checkout-notice .loyalty-link a {
    text-decoration: none;
}

.sv-loyalty-checkout-notice .loyalty-link a:hover {
    text-decoration: underline;
}
