/**
 * WC Licensed Product - Frontend Styles
 *
 * @package Jeremias\WcLicensedProduct
 */

/* License Status Badges */
.license-status {
    display: inline-block;
    padding: 0.25em 0.6em;
    font-size: 0.85em;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.25rem;
}

.license-status-active {
    background-color: #d4edda;
    color: #155724;
}

.license-status-inactive {
    background-color: #fff3cd;
    color: #856404;
}

.license-status-expired {
    background-color: #f8d7da;
    color: #721c24;
}

.license-status-revoked {
    background-color: #d6d8db;
    color: #383d41;
}

/* License Packages */
.woocommerce-licenses {
    display: flex;
    flex-direction: column;
    gap: 1.5em;
}

.license-package {
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.package-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1em 1.5em;
    background: #f8f9fa;
    border-bottom: 1px solid #e5e5e5;
}

.package-title {
    display: flex;
    flex-direction: column;
    gap: 0.25em;
}

.package-title h3 {
    margin: 0;
    font-size: 1.1em;
}

.package-title h3 a {
    color: inherit;
    text-decoration: none;
}

.package-title h3 a:hover {
    text-decoration: underline;
}

.package-order {
    font-size: 0.85em;
    color: #666;
}

.package-order a {
    color: #2271b1;
    text-decoration: none;
}

.package-order a:hover {
    text-decoration: underline;
}

.package-license-count {
    font-size: 0.9em;
    color: #666;
    background: #e9ecef;
    padding: 0.3em 0.8em;
    border-radius: 12px;
}

/* Package Licenses - Two Row Layout */
.package-licenses {
    padding: 0;
}

.license-entry {
    padding: 1em 1.5em;
    border-bottom: 1px solid #e5e5e5;
}

.license-entry:last-child {
    border-bottom: none;
}

.license-entry:hover {
    background-color: #fafafa;
}

.license-row-primary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1em;
    margin-bottom: 0.5em;
}

.license-key-group {
    display: flex;
    align-items: center;
    gap: 0.75em;
    flex-shrink: 1;
    min-width: 0;
}

.license-entry code.license-key {
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    background-color: #f5f5f5;
    padding: 0.4em 0.75em;
    border-radius: 4px;
    font-size: 0.95em;
    letter-spacing: 0.03em;
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.license-key-group .license-status {
    flex-shrink: 0;
}

.license-actions {
    display: flex;
    align-items: center;
    gap: 0.5em;
    flex-shrink: 0;
}

.license-row-secondary {
    display: flex;
    align-items: center;
    gap: 1.5em;
    font-size: 0.9em;
    color: #666;
    flex-wrap: wrap;
}

.license-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
}

.license-meta-item .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    color: #999;
}

.license-domain {
    color: #333;
}

.license-expiry .lifetime {
    color: #28a745;
    font-weight: 500;
}

/* Legacy table styles (kept for backwards compatibility) */
.licenses-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
}

.licenses-table th,
.licenses-table td {
    padding: 0.75em 1em;
    text-align: left;
    border-bottom: 1px solid #e5e5e5;
}

.licenses-table th {
    font-weight: 600;
    background-color: #fafafa;
    font-size: 0.9em;
    color: #555;
}

.licenses-table code.license-key {
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    background-color: #f5f5f5;
    padding: 0.3em 0.6em;
    border-radius: 4px;
    font-size: 0.9em;
    letter-spacing: 0.03em;
}

.licenses-table .lifetime {
    color: #28a745;
    font-weight: 500;
}

/* Legacy single card styles (kept for backwards compatibility) */
.license-card {
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.license-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1em 1.5em;
    background: #f8f9fa;
    border-bottom: 1px solid #e5e5e5;
}

.license-header h3 {
    margin: 0;
    font-size: 1.1em;
}

.license-header h3 a {
    color: inherit;
    text-decoration: none;
}

.license-header h3 a:hover {
    text-decoration: underline;
}

.license-details {
    padding: 1.5em;
}

.license-key-row {
    display: flex;
    align-items: center;
    gap: 0.75em;
    margin-bottom: 1em;
    flex-wrap: wrap;
}

.license-key-row label {
    font-weight: 600;
}

.license-key-row code {
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    background-color: #f5f5f5;
    padding: 0.4em 0.8em;
    border-radius: 4px;
    font-size: 1em;
    letter-spacing: 0.05em;
}

.copy-license-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-license-btn:hover {
    background: #e5e5e5;
    border-color: #ccc;
}

.copy-license-btn .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.copy-feedback {
    display: inline-block;
    margin-left: 0.5em;
    padding: 0.25em 0.5em;
    font-size: 0.85em;
    border-radius: 3px;
}

.copy-feedback.success {
    background: #d4edda;
    color: #155724;
}

.copy-feedback.error {
    background: #f8d7da;
    color: #721c24;
}

.license-info-row {
    display: flex;
    gap: 2em;
    color: #666;
    font-size: 0.95em;
    flex-wrap: wrap;
}

.license-domain-display {
    display: flex;
    align-items: center;
    gap: 0.5em;
}

/* Transfer Button */
.wclp-transfer-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25em;
    padding: 0.2em 0.6em;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 0.85em;
    color: #555;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wclp-transfer-btn:hover {
    background: #e5e5e5;
    border-color: #ccc;
    color: #333;
}

.wclp-transfer-btn .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

/* Download Section */
.package-downloads,
.license-downloads {
    padding: 1em 1.5em;
    background: #f8f9fa;
    border-top: 1px solid #e5e5e5;
}

.package-downloads h4,
.license-downloads h4 {
    margin: 0 0 0.75em 0;
    font-size: 0.95em;
    color: #333;
}

.download-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.download-list li.download-item {
    display: flex;
    flex-direction: column;
    gap: 0.35em;
    padding: 0.75em 0;
    border-bottom: 1px solid #eee;
}

.download-list li.download-item:last-child {
    border-bottom: none;
}

.download-row-file {
    display: flex;
    align-items: center;
}

.download-row-meta {
    display: flex;
    align-items: center;
    gap: 1em;
    padding-left: 1.5em;
}

.download-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    color: #2271b1;
    text-decoration: none;
    font-weight: 500;
}

.download-link:hover {
    text-decoration: underline;
}

.download-link .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.download-version {
    background: #e7f3ff;
    padding: 0.2em 0.5em;
    border-radius: 3px;
    font-size: 0.85em;
    color: #2271b1;
}

.download-date {
    color: #999;
    font-size: 0.85em;
}

.download-hash {
    display: inline-flex;
    align-items: center;
    gap: 0.25em;
    font-size: 0.8em;
    color: #666;
}

.download-hash .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    color: #28a745;
}

.download-hash code {
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    background: #f5f5f5;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 0.9em;
    color: #666;
}

/* Latest version badge */
.download-version-badge {
    display: inline-block;
    padding: 0.15em 0.5em;
    margin-left: 0.5em;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    background: #d4edda;
    color: #155724;
    border-radius: 3px;
    vertical-align: middle;
}

/* Older versions collapsible */
.older-versions-section {
    margin-top: 0.75em;
    padding-top: 0.75em;
    border-top: 1px dashed #ddd;
}

.older-versions-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    padding: 0.4em 0.75em;
    background: transparent;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85em;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
}

.older-versions-toggle:hover {
    background: #f5f5f5;
    border-color: #ccc;
    color: #333;
}

.older-versions-toggle .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}

.older-versions-toggle[aria-expanded="true"] .dashicons {
    transform: rotate(180deg);
}

.older-versions-list {
    margin-top: 0.75em;
    padding-left: 0;
}

.older-versions-list .download-item {
    opacity: 0.85;
}

.older-versions-list .download-item:hover {
    opacity: 1;
}

/* Domain Field */
#licensed-product-domain-field {
    margin-top: 2em;
    padding: 1.5em;
    background-color: #f8f9fa;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
}

#licensed-product-domain-field h3 {
    margin-top: 0;
    margin-bottom: 1em;
    font-size: 1.1em;
}

#licensed-product-domain-field .description {
    display: block;
    margin-top: 0.5em;
    font-size: 0.9em;
    color: #666;
}

/* Legacy License Table (kept for backwards compatibility) */
.woocommerce-licenses-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1em;
}

.woocommerce-licenses-table th,
.woocommerce-licenses-table td {
    padding: 0.75em;
    text-align: left;
    border-bottom: 1px solid #e5e5e5;
}

.woocommerce-licenses-table th {
    font-weight: 600;
    background-color: #f8f8f8;
}

.woocommerce-licenses-table code {
    font-family: monospace;
    background-color: #f5f5f5;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 0.9em;
}

/* Responsive */
@media screen and (max-width: 768px) {
    /* Package header responsive */
    .package-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75em;
    }

    .package-license-count {
        align-self: flex-start;
    }

    /* License entry responsive */
    .license-entry {
        padding: 1em;
    }

    .license-row-primary {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75em;
    }

    .license-key-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5em;
        width: 100%;
    }

    .license-entry code.license-key {
        font-size: 0.85em;
        word-break: break-all;
        white-space: normal;
    }

    .license-actions {
        align-self: flex-start;
    }

    .license-row-secondary {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5em;
    }

    /* Legacy card layout responsive */
    .license-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5em;
    }

    .license-key-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .license-info-row {
        flex-direction: column;
        gap: 0.5em;
    }

    .download-row-meta {
        padding-left: 0;
        flex-wrap: wrap;
    }

    /* Legacy table responsive */
    .woocommerce-licenses-table,
    .woocommerce-licenses-table thead,
    .woocommerce-licenses-table tbody,
    .woocommerce-licenses-table th,
    .woocommerce-licenses-table td,
    .woocommerce-licenses-table tr,
    .licenses-table,
    .licenses-table thead,
    .licenses-table tbody,
    .licenses-table th,
    .licenses-table td,
    .licenses-table tr {
        display: block;
    }

    .woocommerce-licenses-table thead tr,
    .licenses-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .woocommerce-licenses-table tr,
    .licenses-table tr {
        border: 1px solid #e5e5e5;
        margin-bottom: 1em;
    }

    .woocommerce-licenses-table td,
    .licenses-table td {
        border: none;
        position: relative;
        padding-left: 50%;
    }

    .woocommerce-licenses-table td:before,
    .licenses-table td:before {
        content: attr(data-title);
        position: absolute;
        left: 0.75em;
        width: 45%;
        font-weight: 600;
    }

    .license-domain-display {
        flex-wrap: wrap;
    }

    .wclp-transfer-btn {
        margin-top: 0.5em;
    }
}

/* Transfer Modal */
.wclp-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wclp-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.wclp-modal-content {
    position: relative;
    background: #fff;
    padding: 2em;
    border-radius: 8px;
    max-width: 450px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.wclp-modal-close {
    position: absolute;
    top: 0.5em;
    right: 0.5em;
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: #666;
    line-height: 1;
    padding: 0.25em;
}

.wclp-modal-close:hover {
    color: #333;
}

.wclp-modal-content h3 {
    margin: 0 0 1.5em 0;
    font-size: 1.25em;
}

.wclp-form-row {
    margin-bottom: 1.5em;
}

.wclp-form-row label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5em;
    color: #333;
}

.wclp-form-row input[type="text"] {
    width: 100%;
    padding: 0.75em;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1em;
}

.wclp-form-row input[type="text"]:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

.wclp-current-domain {
    margin: 0;
}

.wclp-current-domain code {
    background: #f5f5f5;
    padding: 0.4em 0.8em;
    border-radius: 4px;
    font-size: 1em;
}

.wclp-field-description {
    margin: 0.5em 0 0 0;
    font-size: 0.85em;
    color: #666;
}

.wclp-form-actions {
    display: flex;
    gap: 1em;
    margin-top: 2em;
}

.wclp-btn-primary {
    background: #2271b1 !important;
    border-color: #2271b1 !important;
    color: #fff !important;
}

.wclp-btn-primary:hover {
    background: #135e96 !important;
    border-color: #135e96 !important;
}

.wclp-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.wclp-message {
    margin-top: 1em;
    padding: 0.75em 1em;
    border-radius: 4px;
    font-size: 0.95em;
}

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

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

/* Product Version Display (Single Product Page) */
.wclp-product-version {
    margin: 0.5em 0 1em 0;
    font-size: 0.95em;
    color: #666;
}

.wclp-product-version .version-label {
    font-weight: 500;
    color: #555;
}

.wclp-product-version .version-number {
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    background: #e7f3ff;
    padding: 0.15em 0.5em;
    border-radius: 3px;
    color: #2271b1;
    font-weight: 500;
}

/* Customer Secret Section */
.license-row-secret {
    margin-top: 0.75em;
    padding-top: 0.75em;
    border-top: 1px dashed #e5e5e5;
}

.secret-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    padding: 0.4em 0.75em;
    background: transparent;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85em;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
}

.secret-toggle:hover {
    background: #f5f5f5;
    border-color: #ccc;
    color: #333;
}

.secret-toggle .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

.secret-toggle .toggle-arrow {
    transition: transform 0.2s ease;
}

.secret-toggle[aria-expanded="true"] .toggle-arrow {
    transform: rotate(180deg);
}

.secret-content {
    margin-top: 0.75em;
    padding: 1em;
    background: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #e5e5e5;
}

.secret-description {
    margin: 0 0 0.75em 0;
    font-size: 0.85em;
    color: #666;
}

.secret-value-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5em;
}

.secret-value {
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 0.75em;
    background: #fff;
    padding: 0.5em 0.75em;
    border: 1px solid #ddd;
    border-radius: 4px;
    word-break: break-all;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
}

.copy-secret-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.copy-secret-btn:hover {
    background: #e5e5e5;
    border-color: #ccc;
}

.copy-secret-btn .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

@media screen and (max-width: 768px) {
    .secret-value-wrapper {
        flex-direction: column;
        align-items: stretch;
    }

    .secret-value {
        font-size: 0.7em;
    }

    .copy-secret-btn {
        align-self: flex-start;
    }
}
