/**
 * Rokky Hub Frontend Styles
 * Activation keys display and copy functionality
 */

/* Product title copy button */
.rokky-copy-title-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-right: 3px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    vertical-align: middle;
    color: #666;
    top: -1px;
    position: relative;
}

.rokky-copy-title-btn:hover {
    background: #f0f0f0;
    color: #0073aa;
}

.rokky-copy-title-btn:active {
    transform: scale(0.95);
}

.rokky-copy-title-btn.copied {
    background: #46b450;
    color: #fff;
}

.rokky-copy-title-btn svg {
    flex-shrink: 0;
}

/* Activation keys container */
.rokky-activation-keys {
    margin-top: 12px;
    padding: 12px 16px;
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
}

/* Header with title and copy-all button */
.rokky-keys-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 12px;
}

.rokky-keys-header strong {
    font-size: 13px;
    color: #333;
    flex-shrink: 0;
}

/* Copy all button */
.rokky-copy-all-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.rokky-copy-all-btn:hover {
    background: #005a87;
}

.rokky-copy-all-btn:active {
    transform: scale(0.98);
}

.rokky-copy-all-btn.copied {
    background: #46b450;
}

.rokky-copy-all-btn svg {
    flex-shrink: 0;
}

/* Hidden textarea for copy functionality */
.rokky-keys-hidden-textarea {
    position: absolute;
    left: -9999px;
    opacity: 0;
    pointer-events: none;
}

/* Keys table */
.rokky-keys-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #ddd;
}

.rokky-keys-table thead {
    background: #f0f0f0;
}

.rokky-keys-table th {
    padding: 8px 12px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    border-bottom: 1px solid #ddd;
}

.rokky-keys-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.rokky-keys-table tbody tr:last-child td {
    border-bottom: none;
}

.rokky-keys-table tbody tr:hover {
    background: #f9f9f9;
}

/* New keys highlight - received after last order view */
.rokky-keys-table tbody tr.rokky-new-key {
    background: #fff5f5;
    font-weight: bold;
}

.rokky-keys-table tbody tr.rokky-new-key td {
    color: #c53030;
}

.rokky-keys-table tbody tr.rokky-new-key:hover {
    background: #fed7d7;
}

/* Number column header - unselectable */
.rokky-num-th {
    width: 32px;
    text-align: center;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Number cell - display via ::before to prevent copying */
.rokky-num-cell {
    width: 32px;
    text-align: center;
    font-size: 12px;
    color: #999;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.rokky-num-cell::before {
    content: attr(data-row-num);
}

/* Key column header - unselectable */
.rokky-date-th {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Key cell */
.rokky-key-cell {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 13px;
    color: #333;
    word-break: break-all;
}

/* Date cell - unselectable so only keys can be selected */
.rokky-date-cell {
    width: 120px;
    font-size: 12px;
    color: #666;
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Pending row styles */
.rokky-pending-row {
    opacity: 0.6;
}

.rokky-pending {
    color: #999 !important;
}

/* Pending key cell - display placeholder via ::before to prevent copying */
.rokky-key-cell.rokky-pending[data-placeholder] {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.rokky-key-cell.rokky-pending[data-placeholder]::before {
    content: attr(data-placeholder);
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .rokky-keys-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .rokky-copy-all-btn {
        width: 100%;
        justify-content: center;
    }
    
    .rokky-keys-table th,
    .rokky-keys-table td {
        padding: 6px 8px;
    }
    
    .rokky-num-th,
    .rokky-num-cell {
        width: 24px;
        padding: 6px 4px;
    }
    
    .rokky-key-cell {
        font-size: 11px;
    }
    
    .rokky-date-cell {
        font-size: 11px;
        width: 90px;
    }
}

/* ========================================
   Supplier Price Display in WooCommerce Blocks
   ======================================== */

/* Supplier price shown next to regular price */
.rokky-supplier-price-display {
    display: block;
    font-size: 1em !important;
    color: #666;
    margin-top: 4px;
    font-weight: 400;
    letter-spacing: 0.01em;
    margin-left: 10px;
    line-height: 1.2;
}

.rokky-supplier-price-display::before {
    content: 'Ã¢Å¡â„¢ ';
    opacity: 0.5;
    font-size: 0.85em;
}

/* Inside individual prices container */
.wc-block-components-order-summary-item__individual-prices .rokky-supplier-price-display {
    text-align: left;
    margin-top: 2px;
}

.wc-block-components-order-summary-item__individual-prices .rokky-supplier-price-display:before {
    display: none;
}

/* Price container layout */
.wc-block-components-order-summary-item__individual-prices {
    display: flex !important;
    flex-direction: row;
}

/* Alternative placement */
.wc-block-components-product-price + .rokky-supplier-price-display {
    margin-top: 0px;
}

/* Cart page supplier price */
.rokky-supplier-price-display--cart {
    display: block;
    margin-top: 4px;
}

/* Mini cart supplier price */
.rokky-supplier-price-display--mini-cart {
    display: block;
    font-size: 0.9em !important;
    margin-top: 2px;
    margin-left: 0;
}

.rokky-supplier-price-display::before {
    display: none;
}

/* Cart items price container layout */
.wc-block-cart-item__prices {
    display: flex !important;
    flex-direction: row;
    gap: 5px;
}

.wc-block-cart-item__prices .rokky-supplier-price-display {
    margin-left: 0;
}

/* Mini cart items */
.wc-block-mini-cart-item .rokky-supplier-price-display,
.wc-block-cart-items__row .rokky-supplier-price-display {
    margin-left: 0;
    font-size: 1em !important;
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    .rokky-supplier-price-display {
        color: #999;
    }
}

/* ========================================
   Keys Column in My Account Orders Table
   ======================================== */

/* Base keys display */
.rk-keys {
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
    position: relative;
}

/* Complete - simple black */
.rk-keys--done {
    color: #333;
}

/* Partial - with date */
.rk-keys--wait {
    display: inline-flex;
    flex-direction: column;
    position: relative;
    gap: 1px;
}

.rk-keys--wait .rk-keys__num {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #d63638;
    font-weight: bold;
}

.rk-keys--wait .rk-keys__date {
    font-size: 10px;
    color: #888;
    letter-spacing: -0.02em;
}

/* Red dot for new unseen keys */
.rk-keys__dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #d63638;
    border-radius: 50%;
    flex-shrink: 0;
    animation: rk-pulse 2s ease-in-out infinite;
    position: absolute;
    left: -11px;
    top: 4px;
}

@keyframes rk-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Hide on mobile */
@media (max-width: 768px) {
    .woocommerce-orders-table th.woocommerce-orders-table__header-rokky_keys,
    .woocommerce-orders-table td.woocommerce-orders-table__cell-rokky_keys {
        display: none;
    }
}

/* ========================================
   Download Keys Button
   ======================================== */

/* Keys buttons container */
.rokky-keys-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Download all keys button - round style */
.rokky-download-keys-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 11.5px 16px;
    background: transparent;
    color: #333;
    border: 1.5px solid #333;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.rokky-download-keys-btn:hover {
    background: #333;
    color: #fff;
}

.rokky-download-keys-btn:active {
    transform: scale(0.98);
}

.rokky-download-keys-btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}

.rokky-download-keys-btn.is-loading {
    opacity: 0.7;
    pointer-events: none;
}

.rokky-download-keys-btn svg {
    flex-shrink: 0;
}

/* Go to order link button - round style */
.rokky-goto-order-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: transparent;
    color: #333;
    border: 2px solid #333;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-decoration: none;
}

.rokky-goto-order-btn:hover {
    background: #333;
    color: #fff;
    text-decoration: none;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .rokky-keys-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    
    .rokky-download-keys-btn,
    .rokky-goto-order-btn {
        justify-content: center;
        text-align: center;
    }
}

/* ========================================
   Repeat Order Button in Orders Table
   ======================================== */

/* Repeat button in orders table */
.woocommerce-orders-table .button.repeat {
    margin-right: 10px;
}

/* Loading state for repeat button */
.woocommerce-orders-table .button.repeat.is-loading {
    opacity: 0.7;
    pointer-events: none;
    cursor: wait;
}

/* Button group in actions cell */
.woocommerce-orders-table__cell-order-actions {
    white-space: nowrap;
}

.woocommerce-orders-table__cell-order-actions .button {
    margin-bottom: 4px;
}

/* Mobile: stack buttons vertically */
@media (max-width: 768px) {
    .woocommerce-orders-table__cell-order-actions .button {
        display: block;
        width: 100%;
        margin-left: 0;
        margin-bottom: 8px;
        text-align: center;
    }
    
    .woocommerce-orders-table__cell-order-actions .button:last-child {
        margin-bottom: 0;
    }
}
