/*
 * Frontend-specific stylesheet for RR License Manager.
 *
 * @package RR_License_Manager
 */

/* =========================================
   1. General Layout & Containers
   ========================================= */
.rr-license-manager-container {
    max-width: 100%;
}

.rr-cards-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2em;
}

/* Grid Layout for My Account (overrides flex if needed) */
.rr-cards-container.rr-grid-view {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 30px;
    margin-top: 20px;
}

/* =========================================
   2. Card Component
   ========================================= */
.rr-card {
    background-color: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px; /* Consistent radius */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.2s ease;
    position: relative;
}

.rr-card:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

/* Center Alignment Modifier */
.rr-card.rr-text-center {
    text-align: center;
}

/* --- Card Header --- */
.rr-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center; /* Default alignment */
    padding: 1rem 1.5rem;
    background-color: #f8f8f8; /* or #fafafa */
    border-bottom: 1px solid #e5e5e5; /* or #f0f0f0 */
    flex-wrap: wrap;
    gap: 1rem;
}

/* My Account Specific Header Layout */
.rr-card__header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    width: 100%;
}

.rr-card__title {
    margin: 0;
    font-size: 1.15em;
    font-weight: 600;
    line-height: 1.4;
}

.rr-card__title a {
    text-decoration: none;
    color: #222;
}

.rr-card__order-info {
    font-size: 0.85em;
    color: #777;
    display: flex;
    align-items: center;
    width: 100%;
}

.rr-sep {
    margin: 0 8px;
    color: #ccc;
}

/* --- Card Body --- */
.rr-card__body {
    padding: 1.5rem; /* 20px in some contexts */
    display: grid;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .rr-card__body {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

.rr-card__detail {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.rr-card__detail-label {
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #999;
    margin-bottom: 6px;
    font-weight: 600;
}

.rr-card__detail-value {
    font-size: 1em;
}

/* License Key Display Areas */
.rr-card__detail--license-key .rr-card__detail-value {
    word-break: break-all;
    background-color: #f9f9f9;
    padding: 0.5rem;
    border-radius: 4px;
    font-family: monospace;
}

.rr-key-text-wrapper {
    display: flex;
    align-items: center;
    background: #f5f5f5;
    padding: 12px;
    border-radius: 4px;
    border: 1px solid #eee;
    position: relative;
}

.rr-key-text-wrapper code {
    background: none;
    border: none;
    font-size: 1.1em;
    color: #333;
    word-break: break-all;
    flex-grow: 1;
    font-family: monospace;
}

.rr-copy-btn {
    background: none !important;
    border: none !important;
    padding: 5px !important;
    color: #aaa !important;
    cursor: pointer;
    transition: color 0.2s;
}

.rr-copy-btn:hover {
    color: #333 !important;
}

.rr-key-image-wrapper {
    margin-top: 10px;
    border: 1px solid #eee;
    padding: 5px;
    background: #fff;
    display: inline-block;
}

.rr-key-image-wrapper img {
    max-width: 200px;
    height: auto;
    display: block;
}

/* Preview Image in Thank You Table */
.rr-license-img-preview {
    max-width: 150px;
    height: auto;
    display: block;
    margin-top: 5px;
}

/* --- Card Footer --- */
.rr-card__footer {
    display: flex;
    justify-content: space-between; /* Default spread */
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background-color: #f8f8f8;
    border-top: 1px solid #e5e5e5;
    flex-wrap: wrap;
}

.rr-card__footer.rr-footer-column {
    flex-direction: column;
    align-items: stretch;
    gap: 15px;
}

.rr-actions-left,
.rr-actions-right {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.rr-card__export-links {
    width: 100%;
    border-top: 1px solid #f9f9f9;
    margin-top: 10px;
    padding-top: 10px;
    font-size: 0.8em;
    color: #999;
    text-align: right;
}

.rr-card__export-links a {
    color: #777;
    text-decoration: none;
    font-weight: 600;
    margin: 0 3px;
}

.rr-card__export-links a:hover {
    color: #007cba;
    text-decoration: underline;
}

/* =========================================
   3. Status Badges & Indicators
   ========================================= */
/* Common Badge Base */
.rr-lm-status-badge,
.rr-status-badge,
.rr-badge {
    display: inline-block;
    padding: 0.3em 0.8em;
    font-size: 0.75em;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 20px; /* or 4px for some variants */
    text-transform: capitalize; /* or uppercase */
}

/* Border Indicators on Cards (My Account) */
.rr-card.status-expired { border-left: 4px solid #d63638; }
.rr-card.status-active, .rr-card.status-sold { border-left: 4px solid #4ab866; }
.rr-card.status-revoked { border-left: 4px solid #333; opacity: 0.8; }

/* Status Colors - Green (Active/Sold) */
.rr-lm-status-active,
.rr-lm-status-available,
.rr-status-badge.status-available,
.rr-status-badge.status-active,
.rr-badge--active,
.rr-badge--sold {
    background-color: #e6fffa; /* Light Green Bg */
    color: #2c7a7b; /* Dark Green Text */
    border: 1px solid #b2f5ea;
}

/* Also support solid backgrounds for legacy classes */
.rr-lm-status-active, .rr-lm-status-available {
    background-color: #28a745;
    color: #fff;
    border: none;
}

/* Status Colors - Yellow/Orange (Inactive/Hold/Warning) */
.rr-lm-status-inactive,
.rr-lm-status-on-hold,
.rr-status-badge.status-sold,
.rr-badge--warning {
    background-color: #fffaf0;
    color: #c05621;
    border: 1px solid #fbd38d;
}

/* Legacy Yellow override */
.rr-lm-status-inactive, .rr-lm-status-on-hold {
    background-color: #ffc107;
    color: #212529;
    border: none;
}

/* Status Colors - Red (Expired/Cancelled) */
.rr-lm-status-expired,
.rr-lm-status-cancelled,
.rr-status-badge.status-expired,
.rr-badge--expired {
    background-color: #fff5f5;
    color: #c53030;
    border: 1px solid #feb2b2;
}

/* Legacy Red override */
.rr-lm-status-expired, .rr-lm-status-cancelled {
    background-color: #dc3545;
    color: #fff;
    border: none;
}

/* Status Colors - Gray (Revoked/Blocked) */
.rr-lm-status-revoked,
.rr-status-badge.status-revoked,
.rr-status-badge.status-blocked,
.rr-badge--revoked {
    background-color: #f7f7f7;
    color: #666;
    border: 1px solid #ddd;
}

/* Legacy Gray override */
.rr-lm-status-revoked {
    background-color: #6c757d;
    color: #fff;
    border: none;
}

/* Status Colors - Blue (Sold/Returned/Redeemed) */
.rr-lm-status-sold,
.rr-lm-status-returned,
.rr-lm-status-redeemed {
    background-color: #17a2b8;
    color: #fff;
}

/* Text Utilities */
.rr-text-danger {
    color: #c53030;
    font-weight: 600;
}

.rr-status-pending-text {
    color: #e2401c;
    font-weight: bold;
}

/* =========================================
   4. Buttons & Actions
   ========================================= */
.rr-button-secondary {
    font-size: 0.9em !important;
    padding: 8px 14px !important;
    display: inline-flex !important;
    align-items: center;
    background-color: #eee;
    color: #333;
    border: 1px solid #ddd;
}

.rr-button-secondary .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    margin-right: 4px;
}

.rr-button-primary,
.rr-renew-btn {
    background-color: #d63638 !important;
    color: #fff !important;
    border-color: #d63638 !important;
}

.rr-button-primary:hover {
    background-color: #b32d2e !important;
    color: #fff !important;
}

/* Danger Button (for cancellations) */
.rr-button-danger {
    background-color: #d63638 !important;
    color: #fff !important;
    border: 1px solid #d63638 !important;
}
.rr-button-danger:hover {
    background-color: #b32d2e !important;
}

/* Download Button Specifics */
.rr-btn-download {
    background-color: #007cba !important;
    color: white !important;
    border-color: #007cba !important;
    text-align: center;
    min-width: 200px;
    display: inline-flex !important;
    justify-content: center;
    align-items: center;
}

.rr-icon-middle {
    line-height: inherit;
    font-size: 18px;
    margin-right: 5px;
    vertical-align: middle;
}

/* =========================================
   5. Thank You Page / Order Details
   ========================================= */
.woocommerce-order-licenses {
    margin-top: 2em;
    border: 1px solid #e5e5e5;
    padding: 2em;
    background-color: #fff;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
    border-radius: 8px;
}

.woocommerce-order-licenses__title {
    font-size: 1.5em;
    margin-top: 0;
    margin-bottom: 1em;
    padding-bottom: 0.5em;
    border-bottom: 1px solid #eee;
}

.rr-thankyou-title-renew {
    border-bottom: none;
    margin-bottom: 0.5em;
}

.rr-thankyou-text {
    font-size: 1.1em;
    color: #555;
}

.rr-subscription-details-block {
    margin: 1.5em 0;
    border-top: 1px solid #eee;
    padding-top: 1.5em;
}

.rr-detail-mb {
    margin-bottom: 1em;
}

/* Pending Delivery Notice */
.rr-license-manager-pending-notice {
    margin: 20px 0;
    padding: 15px;
    background-color: #fff8e5;
    border-left: 5px solid #ffba00;
    color: #555;
}

.rr-license-manager-pending-notice h3 {
    margin-top: 0;
    color: #ffba00;
}

.rr-license-manager-pending-notice ul {
    margin-bottom: 0;
}

/* Single Product Page - Delivered Quantity */
.rr-license-manager-delivered-quantity {
    margin-top: 10px;
    clear: both;
}

/* =========================================
   6. Modals (Activations & Details)
   ========================================= */
.rr-lic-modal-overlay,
.rr-modal,
#rr-lic-activations-modal,
#rr-lic-cancel-modal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 99999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    align-items: center;
    justify-content: center;
}

/* Flex display when active */
.rr-lic-modal-overlay.active {
    display: flex;
}

.rr-lic-modal-content,
.rr-modal-content {
    background-color: #fff;
    margin: auto;
    width: 95%;
    max-width: 600px;
    max-height: 80vh;
    border-radius: 8px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    animation: rrFadeIn 0.3s;
}

/* Small Modal Variant */
.rr-modal-small {
    max-width: 420px;
}

@keyframes rrFadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Modal Header */
.rr-modal-header {
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rr-modal-header h3 {
    margin: 0;
    font-size: 1.2em;
    color: #333;
}

/* Modal Body */
.rr-modal-body {
    padding: 25px 20px;
    overflow-y: auto;
    flex-grow: 1;
}

.rr-license-ref {
    margin-bottom: 15px;
    font-size: 0.9em;
    color: #555;
    background: #eef2f7;
    padding: 8px 12px;
    border-radius: 4px;
    border-left: 3px solid #007cba;
}

/* Alert Icon Wrapper (For cancel modal) */
.rr-alert-icon-wrapper {
    text-align: center;
    margin-bottom: 15px;
}

.rr-alert-icon-wrapper .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    color: #e53e3e; /* Red warning */
}

/* Text Center Utility */
.rr-text-center {
    text-align: center;
}

/* Modal Footer */
.rr-modal-footer {
    padding: 15px 20px;
    background: #f8f9fa;
    border-top: 1px solid #eee;
    text-align: right;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Close Buttons */
.rr-close-modal {
    color: #999;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.rr-close-modal:hover {
    color: #333;
    text-decoration: none;
}

/* Activations Table inside Modal */
.rr-activations-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
    margin-top: 10px;
    border: 1px solid #eee;
}

.rr-activations-table th {
    text-align: left;
    background: #f9f9f9;
    color: #555;
    font-weight: 600;
    border-bottom: 2px solid #eee;
    padding: 10px;
}

.rr-activations-table td {
    border-bottom: 1px solid #eee;
    padding: 12px 10px;
    vertical-align: middle;
}

.rr-activations-table tr:last-child td {
    border-bottom: none;
}

/* Environment Badges */
.rr-env-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.7em;
    text-transform: uppercase;
    font-weight: bold;
    margin-left: 5px;
    vertical-align: middle;
}

.rr-env-production {
    background-color: #c6f6d5;
    color: #22543d;
    border: 1px solid #9ae6b4;
}

.rr-env-staging {
    background-color: #feebc8;
    color: #7b341e;
    border: 1px solid #fbd38d;
}

.rr-lic-loading {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 20px;
    display: block;
}

/* =========================================
   7. WooCommerce Specifics
   ========================================= */
.woocommerce-error {
    background-color: #f8d7da !important;
    color: #721c24 !important;
    border-left: 5px solid #f5c6cb !important;
    padding: 1em 1.5em !important;
    border-radius: 5px;
    margin-bottom: 2em !important;
}

.woocommerce-error a.button {
    background-color: #721c24 !important;
    color: #fff !important;
    margin-left: 1em;
    border-radius: 3px;
    padding: 0.5em 1em;
    text-decoration: none;
}

.woocommerce-error a.button:hover {
    background-color: #5a161b !important;
}

/* =========================================
   8. Responsive Adjustments
   ========================================= */
@media (max-width: 600px) {
    .rr-card__footer {
        flex-direction: column;
        align-items: stretch;
    }

    .rr-actions-left,
    .rr-actions-right {
        flex-direction: column;
        width: 100%;
    }

    .rr-actions-left .button,
    .rr-actions-right .button {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
    
    .rr-modal-footer {
        flex-direction: column;
        gap: 10px;
    }
    .rr-modal-footer .button {
        width: 100%;
        text-align: center;
    }
}


/* Enhanced Pending Card Styling */
.rr-pending-licenses-section {
    margin-top: 30px;
}

.rr-card--pending {
    border-left: 4px solid #ffba00; /* Warning Yellow */
    background-color: #fffdf9;
}

.rr-card--pending .rr-card__header {
    background-color: #fff9eb;
}

.rr-pending-items-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.rr-card--pending .rr-card__footer {
    background-color: #fff9eb;
    font-size: 0.9em;
    color: #856404;
}

/* Ensure the dashicons align in the footer */
.rr-card--pending .rr-actions-left {
    display: flex;
    align-items: center;
    gap: 8px;
}