/**
 * Subscription Tab Styles
 * Plan display, usage meters, upgrade options, history
 * Version: 2.5 - Qty wrapper and label styles
 * Created: December 2025
 */

/* ============================================
   Subscription Tab Layout
   ============================================ */

.subscription-tab {
    max-width: 900px;
    margin: 0 auto;
}

.subscription-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}

.subscription-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-border);
}

.subscription-section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   Current Plan Card
   ============================================ */

.current-plan-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.current-plan-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.current-plan-badge {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 700;
}

.current-plan-badge.badge-gray {
    background: #f1f5f9;
    color: #64748b;
}

.current-plan-badge.badge-blue {
    background: #dbeafe;
    color: #1d4ed8;
}

.current-plan-badge.badge-gold {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
}

.current-plan-badge.badge-purple {
    background: linear-gradient(135deg, #ede9fe, #ddd6fe);
    color: #7c3aed;
}

.current-plan-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.current-plan-price {
    font-size: 14px;
    color: var(--color-text-light);
}

.current-plan-renewal {
    font-size: 13px;
    color: var(--color-text-light);
}

.current-plan-renewal.warning {
    color: var(--color-warning);
    font-weight: 500;
}

.current-plan-renewal.urgent {
    color: var(--color-error);
    font-weight: 600;
}

.manage-billing-btn {
    padding: 8px 16px;
    font-size: 13px;
    color: var(--color-text-light);
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.manage-billing-btn:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

/* Annual Stacking Display */
.annual-stacking {
    margin-top: 12px;
    padding: 12px 16px;
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 8px;
}

.annual-stacking-text {
    font-size: 14px;
    color: #166534;
}

.annual-stacking-date {
    font-weight: 600;
}

.add-year-btn {
    margin-top: 8px;
    padding: 6px 12px;
    font-size: 12px;
    color: #166534;
    background: white;
    border: 1px solid #86efac;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.add-year-btn:hover {
    background: #dcfce7;
}

/* ============================================
   Usage Meters
   ============================================ */

.usage-meters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.usage-meter {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.usage-meter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.usage-meter-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
}

.usage-meter-icon {
    font-size: 16px;
}

.usage-meter-values {
    font-size: 14px;
    color: var(--color-text-light);
}

.grandfathered-note {
    font-size: 11px;
    color: var(--color-text-lighter, #999);
    font-style: italic;
}

.usage-meter-bar {
    height: 8px;
    background: var(--color-border);
    border-radius: 4px;
    overflow: hidden;
}

.usage-meter-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease, background 0.3s;
}

.usage-meter-fill.green { background: #10b981; }
.usage-meter-fill.yellow { background: #f59e0b; }
.usage-meter-fill.orange { background: #f97316; }
.usage-meter-fill.red { background: #ef4444; }

.usage-meter-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.usage-meter-message {
    font-size: 12px;
}

.usage-meter-message.warning { color: #f59e0b; }
.usage-meter-message.critical { color: #f97316; }
.usage-meter-message.maxed { color: #ef4444; font-weight: 600; }

.usage-meter-upgrade {
    font-size: 12px;
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
}

.usage-meter-upgrade:hover {
    text-decoration: underline;
}

.usage-reset-date {
    margin-top: 12px;
    font-size: 13px;
    color: var(--color-text-light);
    text-align: center;
}

/* ============================================
   Upgrade Options
   ============================================ */

.upgrade-options-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.compare-plans-btn {
    font-size: 13px;
    color: var(--color-primary);
    background: transparent;
    border: none;
    cursor: pointer;
    text-decoration: underline;
}

.upgrade-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    align-items: stretch; /* All cards same height in row */
}

.upgrade-card {
    display: flex;
    flex-direction: column;
    padding: 20px;
    background: var(--color-bg);
    border: 2px solid var(--color-border);
    border-radius: 12px;
    transition: all 0.2s;
}

.upgrade-card:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
}

.upgrade-card.highlighted {
    border-color: #f59e0b;
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
}

.upgrade-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.upgrade-card-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text);
}

.upgrade-card-badge {
    padding: 4px 8px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    background: #f59e0b;
    color: white;
    border-radius: 4px;
}

.upgrade-card-price {
    margin-bottom: 16px;
}

.upgrade-card-price-row {
    display: flex;
    align-items: baseline;
    gap: 2px;
}

.upgrade-card-amount {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-text);
}

.upgrade-card-period {
    font-size: 14px;
    color: var(--color-text-light);
}

.upgrade-card-savings-row {
    height: 24px; /* Fixed height - always reserve space */
    display: flex;
    align-items: center;
    margin-top: 6px;
}

.upgrade-card-savings {
    display: inline-block;
    padding: 3px 8px;
    font-size: 12px;
    font-weight: 600;
    color: #166534;
    background: #dcfce7;
    border-radius: 4px;
}

.upgrade-card-savings:empty {
    display: none;
}

.upgrade-card-features {
    flex: 1;
    margin-bottom: 16px;
    min-height: 120px; /* Fixed height to align cards with different feature counts */
}

.upgrade-card-feature {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--color-text);
    margin-bottom: 8px;
}

.upgrade-card-feature svg {
    width: 16px;
    height: 16px;
    color: #10b981;
}

.upgrade-card-btn {
    width: 100%;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #0D4F2B, #1AACB8);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.upgrade-card-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(13, 79, 43, 0.3);
}

/* Billing Toggle */
.billing-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
}

.billing-toggle-label {
    font-size: 14px;
    color: var(--color-text-light);
    cursor: pointer;
}

.billing-toggle-label.active {
    color: var(--color-text);
    font-weight: 600;
}

.billing-toggle-switch {
    position: relative;
    width: 48px;
    height: 24px;
    background: var(--color-border);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.billing-toggle-switch.annual {
    background: #10b981;
}

.billing-toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s;
}

.billing-toggle-switch.annual::after {
    transform: translateX(24px);
}

/* ============================================
   Plan History
   ============================================ */

.plan-history-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.plan-history-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--color-border);
}

.plan-history-item:last-child {
    border-bottom: none;
}

.plan-history-date {
    min-width: 100px;
    font-size: 13px;
    color: var(--color-text-light);
}

.plan-history-event {
    flex: 1;
    font-size: 14px;
    color: var(--color-text);
}

.plan-history-amount {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
}

.view-invoices-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 16px;
    font-size: 13px;
    color: var(--color-primary);
    background: transparent;
    border: none;
    cursor: pointer;
    text-decoration: underline;
}

/* ============================================
   Domain Management
   ============================================ */

.domains-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--color-border);
}

.domains-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.domains-count {
    font-size: 13px;
    color: var(--color-text-light);
}

.add-domain-btn {
    padding: 6px 12px;
    font-size: 13px;
    color: var(--color-primary);
    background: transparent;
    border: 1px solid var(--color-primary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.add-domain-btn:hover {
    background: rgba(37, 99, 235, 0.1);
}

.add-domain-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.domains-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.domain-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--color-bg);
    border-radius: 8px;
}

.domain-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.domain-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
}

.domain-type-badge {
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    border-radius: 3px;
}

.domain-type-badge.funnel {
    background: #dbeafe;
    color: #1d4ed8;
}

.domain-type-badge.embed {
    background: #fef3c7;
    color: #92400e;
}

.domain-type-badge.both {
    background: #dcfce7;
    color: #166534;
}

.domain-actions {
    display: flex;
    gap: 8px;
}

.domain-action-btn {
    padding: 4px 8px;
    font-size: 12px;
    color: var(--color-text-light);
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.domain-action-btn:hover {
    background: var(--color-surface);
}

.domain-action-btn.danger:hover {
    color: var(--color-error);
    border-color: var(--color-error);
}

.no-domains-message {
    padding: 24px;
    text-align: center;
    color: var(--color-text-light);
    font-size: 14px;
}

/* ============================================
   Mobile Responsive
   ============================================ */

@media (max-width: 768px) {
    .subscription-section {
        padding: 16px;
    }

    .current-plan-card {
        flex-direction: column;
        align-items: flex-start;
    }

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

    .upgrade-cards-grid {
        grid-template-columns: 1fr;
    }

    .plan-history-item {
        flex-wrap: wrap;
    }

    .plan-history-date {
        width: 100%;
        margin-bottom: 4px;
    }

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

/* ============================================
   Stacked Plans (Multiple Purchases)
   ============================================ */

.plan-count {
    font-size: 0.875rem;
    color: var(--color-text-light);
    background: var(--color-bg, #f8fafc);
    padding: 4px 10px;
    border-radius: 12px;
}

.stacked-plans-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.stacked-plan-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--color-surface, #ffffff);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    transition: border-color 0.2s ease;
}

.stacked-plan-card:hover {
    border-color: var(--color-primary-light);
}

.stacked-plan-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.stacked-plan-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--color-text);
}

.purchase-status {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.purchase-status.completed {
    background: var(--color-success-light, rgba(34, 197, 94, 0.1));
    color: var(--color-success, #22c55e);
}

.purchase-status.pending {
    background: var(--color-warning-light, rgba(245, 158, 11, 0.1));
    color: var(--color-warning, #f59e0b);
}

.stacked-plan-details {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.stacked-plan-price {
    font-weight: 600;
    color: var(--color-text);
}

.stacked-plan-date {
    font-size: 0.8rem;
    color: var(--color-text-light);
}

/* ============================================
   Plan Quantity Badge / Circle
   ============================================ */

.plan-qty-badge {
    display: inline-block;
    background: linear-gradient(135deg, #0D4F2B, #1AACB8);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
    vertical-align: middle;
}

/* Quantity wrapper with circle and label */
.plan-qty-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* Prominent circle for quantity on plan cards */
.plan-qty-circle {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0D4F2B, #1AACB8);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(13, 79, 43, 0.25);
}

.plan-qty-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   Plan History Table
   ============================================ */

.plan-history-table-wrapper {
    overflow-x: auto;
    margin-bottom: 16px;
}

.plan-history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.plan-history-table th {
    text-align: left;
    font-weight: 600;
    color: var(--color-text-light);
    padding: 12px 16px;
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
}

.plan-history-table th.center,
.plan-history-table td.center {
    text-align: center;
}

.plan-history-row {
    transition: background-color 0.15s ease;
}

.plan-history-row:hover {
    background-color: var(--color-bg, #f8fafc);
}

.plan-history-cell {
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
}

.plan-history-cell:first-child {
    font-weight: 500;
}
