@use '../globals' as *;

/**
 * Licensing Page Styles
 *
 * Styles for the license activation and management interface.
 *
 * @package MultilingualPressZone
 * @since 1.0.0
 */

/* ==========================================================================
   Variables (Design System Aliases)
   ========================================================================== */

// Keep legacy variable names but map them to the Press.Zone design tokens.
$primary-color: $presszone-international-primary;
$success-color: $presszone-international-success;
$warning-color: $presszone-international-warning;
$error-color: $presszone-international-error;

$text-primary: $presszone-international-text;
$text-secondary: $presszone-international-text-muted;
$border-color: $presszone-international-border;
$background-white: $presszone-international-surface;
$background-light: $presszone-international-surface-2;

$spacing-sm: 8px;
$spacing-md: 16px;
$spacing-lg: 24px;
$spacing-xl: 32px;

$border-radius-md: $presszone-international-radius;
$border-radius-lg: $presszone-international-radius-lg;

/* ==========================================================================
   Page Layout
   ========================================================================== */

.ipz-licensing-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: $spacing-lg;
}

.ipz-page-header {
    margin-bottom: $spacing-xl;

    h1 {
        margin: 0 0 $spacing-sm 0;
        font-size: 28px;
        font-weight: 600;
        color: $text-primary;
    }
}

.ipz-page-description {
    margin: 0;
    font-size: 14px;
    color: $text-secondary;
    line-height: 1.6;
}

.ipz-licensing-content {
    display: grid;
    gap: $spacing-lg;
}

/* ==========================================================================
   Card Component
   ========================================================================== */

.ipz-card {
    background: $background-white;
    border: 1px solid $border-color;
    border-radius: $border-radius-lg;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.ipz-card__header {
    padding: $spacing-lg;
    border-bottom: 1px solid $border-color;
}

.ipz-card__title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: $text-primary;
}

.ipz-card__description {
    margin: $spacing-sm 0 0 0;
    font-size: 13px;
    color: $text-secondary;
    line-height: 1.6;
}

.ipz-card__body {
    padding: $spacing-lg;
}

/* ==========================================================================
   License Status Card
   ========================================================================== */

.ipz-license-status {
    display: flex;
    flex-direction: column;
    gap: $spacing-lg;
}

.ipz-license-status__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: $spacing-md;
    border-bottom: 1px solid $border-color;
}

.ipz-license-status__plan {
    margin: 0 0 $spacing-sm 0;
    font-size: 20px;
    font-weight: 600;
    color: $text-primary;
}

.ipz-license-status__price {
    margin: 0;
    font-size: 14px;
    color: $text-secondary;
}

.ipz-license-status__key {
    display: flex;
    flex-direction: column;
    gap: $spacing-sm;

    label {
        font-size: 13px;
        font-weight: 600;
        color: $text-primary;
    }

    code {
        display: inline-block;
        padding: $spacing-sm $spacing-md;
        font-family: 'Courier New', monospace;
        font-size: 14px;
        color: $text-primary;
        background: $background-light;
        border: 1px solid $border-color;
        border-radius: $border-radius-md;
    }
}

.ipz-license-status__details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: $spacing-md;
}

.ipz-license-status__detail {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ipz-license-status__detail-label {
    font-size: 12px;
    font-weight: 600;
    color: $text-secondary;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ipz-license-status__detail-value {
    font-size: 16px;
    font-weight: 600;
    color: $text-primary;
}

.ipz-license-status__actions {
    display: flex;
    gap: $spacing-sm;
    padding-top: $spacing-md;
    border-top: 1px solid $border-color;
}

/* ==========================================================================
   Usage Statistics
   ========================================================================== */

.ipz-usage-progress {
    margin-bottom: $spacing-lg;
}

.ipz-usage-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: $spacing-md;
    margin-bottom: $spacing-lg;
    padding: $spacing-md;
    background: $background-light;
    border-radius: $border-radius-md;
}

.ipz-usage-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ipz-usage-stat__label {
    font-size: 12px;
    font-weight: 600;
    color: $text-secondary;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ipz-usage-stat__value {
    font-size: 18px;
    font-weight: 700;
    color: $text-primary;
}

/* ==========================================================================
   Usage Chart
   ========================================================================== */

.ipz-usage-chart {
    h4 {
        margin: 0 0 $spacing-md 0;
        font-size: 14px;
        font-weight: 600;
        color: $text-primary;
    }
}

.ipz-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 4px;
    height: 180px;
    padding: $spacing-md;
    background: $background-light;
    border-radius: $border-radius-md;
}

.ipz-chart-bar-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: $spacing-sm;
    height: 100%;
}

.ipz-chart-bar {
    width: 100%;
    min-height: 4px;
    background: $primary-color;
    border-radius: 2px 2px 0 0;
    transition: background-color 0.3s ease, height 0.3s ease;
    cursor: help;

    &:hover {
        background: darken($primary-color, 10%);
    }

    &--over-limit {
        background: $error-color;

        &:hover {
            background: darken($error-color, 10%);
        }
    }
}

.ipz-chart-label {
    font-size: 10px;
    font-weight: 500;
    color: $text-secondary;
    text-align: center;
    white-space: nowrap;
}

/* ==========================================================================
   Activation Form
   ========================================================================== */

.ipz-activation-form {
    display: flex;
    flex-direction: column;
    gap: $spacing-lg;
    max-width: 600px;
    margin: 0 auto;
}

.ipz-activation-intro {
    margin: 0;
    font-size: 14px;
    color: $text-secondary;
    line-height: 1.6;
    text-align: center;
}

.ipz-form-group {
    display: flex;
    flex-direction: column;
    gap: $spacing-sm;

    label {
        font-size: 13px;
        font-weight: 600;
        color: $text-primary;
    }
}

.ipz-input {
    padding: $spacing-sm $spacing-md;
    font-size: 14px;
    color: $text-primary;
    background: $background-white;
    border: 1px solid $border-color;
    border-radius: $border-radius-md;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;

    &:focus {
        outline: none;
        border-color: $primary-color;
        box-shadow: 0 0 0 1px $primary-color;
    }

    &::placeholder {
        color: $text-secondary;
        opacity: 0.6;
    }
}

.ipz-license-key-input {
    font-family: 'Courier New', monospace;
    font-size: 16px;
    text-align: center;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.ipz-form-help {
    margin: 0;
    font-size: 12px;
    color: $text-secondary;
    line-height: 1.5;
}

.ipz-activation-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: $spacing-md;
}

.ipz-link {
    font-size: 13px;
    color: $primary-color;
    text-decoration: none;
    transition: color 0.15s ease;

    &:hover {
        color: darken($primary-color, 10%);
        text-decoration: underline;
    }
}

/* ==========================================================================
   Plans Grid
   ========================================================================== */

.ipz-plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: $spacing-lg;
}

.ipz-plans-grid--comparison {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.ipz-plan-option {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: $spacing-lg;
    background: $background-white;
    border: 2px solid $border-color;
    border-radius: $border-radius-lg;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;

    &:hover {
        border-color: $primary-color;
        box-shadow: 0 4px 12px rgba(0, 115, 170, 0.1);
    }

    &--popular {
        border-color: $primary-color;
        box-shadow: 0 4px 12px rgba(0, 115, 170, 0.15);
    }
}

.ipz-plan-badge {
    position: absolute;
    top: -12px;
    right: $spacing-lg;
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 600;
    color: $background-white;
    background: $primary-color;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ipz-plan-name {
    margin: 0 0 $spacing-sm 0;
    font-size: 20px;
    font-weight: 700;
    color: $text-primary;
}

.ipz-plan-price {
    margin-bottom: $spacing-lg;
    padding-bottom: $spacing-md;
    border-bottom: 1px solid $border-color;
}

.ipz-plan-price__amount {
    font-size: 32px;
    font-weight: 700;
    color: $text-primary;
}

.ipz-plan-price__interval {
    font-size: 14px;
    color: $text-secondary;
}

.ipz-plan-features {
    flex: 1;
    margin: 0 0 $spacing-lg 0;
    padding: 0;
    list-style: none;

    li {
        display: flex;
        align-items: flex-start;
        gap: $spacing-sm;
        margin-bottom: $spacing-sm;
        font-size: 13px;
        color: $text-primary;
        line-height: 1.5;

        &:last-child {
            margin-bottom: 0;
        }

        .dashicons {
            flex-shrink: 0;
            width: 16px;
            height: 16px;
            margin-top: 2px;
            font-size: 16px;
            color: $success-color;
        }
    }
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.ipz-empty-state {
    padding: $spacing-xl;
    font-size: 14px;
    color: $text-secondary;
    text-align: center;
    background: $background-light;
    border-radius: $border-radius-md;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media screen and (max-width: 782px) {
    .ipz-licensing-page {
        padding: $spacing-md;
    }

    .ipz-license-status__actions {
        flex-direction: column;

        button {
            width: 100%;
        }
    }

    .ipz-plans-grid {
        grid-template-columns: 1fr;
    }

    .ipz-chart {
        height: 150px;
        padding: $spacing-sm;
    }

    .ipz-chart-label {
        font-size: 9px;
    }
}

@media screen and (max-width: 600px) {
    .ipz-page-header h1 {
        font-size: 24px;
    }

    .ipz-card__title {
        font-size: 16px;
    }

    .ipz-license-status__header {
        flex-direction: column;
        gap: $spacing-md;
    }

    .ipz-usage-stats {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .ipz-input,
    .ipz-plan-option,
    .ipz-chart-bar,
    .ipz-link {
        transition: none;
    }
}

@media (prefers-contrast: high) {
    .ipz-card,
    .ipz-input,
    .ipz-plan-option {
        border-width: 2px;
    }

    .ipz-plan-badge {
        font-weight: 700;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .ipz-licensing-page {
        .ipz-license-status__actions,
        .ipz-activation-actions,
        .ipz-plan-option button {
            display: none;
        }

        .ipz-card {
            break-inside: avoid;
            box-shadow: none;
        }

        .ipz-chart-bar {
            print-color-adjust: exact;
            -webkit-print-color-adjust: exact;
        }
    }
}

.ipz-licensing-region,
.ipz-usage-region {
    display: block;
    width: 100%;
}

.ipz-licensing-region .international-data-region[data-revalidating='true'] {
    opacity: 0.72;
}

.ipz-licensing-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px 0;
    text-align: center;
}
