/**
 * Subscriptions & Billing Styles
 *
 * Styles for the subscription management UI in the Parent Portal
 */

/* Sub-Tabs */
.plan-subtabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0.5rem;
}

.plan-subtab {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: #6b7280;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.plan-subtab:hover {
    color: #374151;
    background: #f3f4f6;
    border-radius: 4px 4px 0 0;
}

.plan-subtab.active {
    color: var(--mts-primary, #FF7F50);
    border-bottom-color: var(--mts-primary, #FF7F50);
}

/* Plan Overview */
.plan-overview {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.current-plan-card {
    padding: 1.5rem;
}

.current-plan-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.plan-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
}

.plan-badge.starter {
    background: #dbeafe;
    color: #1e40af;
}

.plan-badge.professional {
    background: #dcfce7;
    color: #15803d;
}

.plan-badge.enterprise {
    background: #f3e8ff;
    color: #7c3aed;
}

.plan-price {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.price-amount {
    font-size: 2rem;
    font-weight: 700;
    color: var(--mts-primary, #FF7F50);
}

.price-period {
    color: #6b7280;
}

.price-custom {
    font-size: 1.5rem;
    font-weight: 600;
    color: #374151;
}

.plan-status {
    color: #6b7280;
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-badge.active {
    background: #dcfce7;
    color: #15803d;
}

.status-badge.pending {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.paid {
    background: #dcfce7;
    color: #15803d;
}

.status-badge.overdue {
    background: #fee2e2;
    color: #991b1b;
}

.status-badge.void {
    background: #f3f4f6;
    color: #6b7280;
}

/* Usage Summary Grid */
.usage-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.usage-card {
    display: flex;
    gap: 1rem;
    padding: 1.5rem;
}

.usage-icon {
    font-size: 2rem;
}

.usage-stats {
    flex: 1;
}

.usage-label {
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 0.25rem;
}

.usage-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: #111827;
    margin-bottom: 0.5rem;
}

.usage-bar {
    height: 6px;
    background: #e5e7eb;
    border-radius: 9999px;
    overflow: hidden;
}

.usage-bar-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.3s ease;
}

/* Plans Grid */
.plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.plan-card {
    display: flex;
    flex-direction: column;
    border: 2px solid #e5e7eb;
    transition: all 0.2s;
}

.plan-card:hover {
    border-color: var(--mts-primary, #FF7F50);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.plan-card.current {
    border-color: var(--mts-primary, #FF7F50);
    box-shadow: 0 0 0 3px rgba(255, 127, 80, 0.1);
}

.plan-card-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.plan-name {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.current-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--mts-primary, #FF7F50);
    color: white;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

.plan-card-body {
    padding: 1.5rem;
    flex: 1;
}

.price-monthly {
    margin-bottom: 0.5rem;
}

.price-yearly {
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.plan-description {
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.plan-limits {
    margin-bottom: 1.5rem;
}

.limit-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f3f4f6;
}

.limit-label {
    color: #6b7280;
}

.limit-value {
    font-weight: 500;
    color: #111827;
}

.plan-features-list {
    font-size: 0.875rem;
}

.plan-features-list strong {
    display: block;
    margin-bottom: 0.5rem;
    color: #374151;
}

.plan-features-list ul {
    margin: 0;
    padding-left: 1.25rem;
}

.plan-features-list li {
    margin-bottom: 0.25rem;
    color: #6b7280;
}

.plan-card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.plan-card-footer .btn {
    width: 100%;
}

/* Usage Metrics */
.usage-metrics-section {
    padding: 1.5rem;
}

.usage-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--mts-primary, #FF7F50);
    margin: 1rem 0;
}

/* Payment Methods */
.payment-methods-section {
    padding: 1.5rem;
}

.section-header {
    margin-bottom: 1.5rem;
}

.payment-methods-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.payment-method-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
}

.payment-method-card.default {
    border: 2px solid var(--mts-primary, #FF7F50);
}

.payment-method-icon {
    font-size: 1.5rem;
}

.payment-method-details {
    flex: 1;
}

.payment-method-brand {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.payment-method-number {
    font-size: 0.875rem;
}

.payment-method-expiry {
    font-size: 0.875rem;
}

.payment-method-actions {
    display: flex;
    gap: 0.5rem;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}

.badge.success {
    background: #dcfce7;
    color: #15803d;
}

/* Invoices */
.invoices-section {
    padding: 1.5rem;
}

.invoices-table-container {
    overflow-x: auto;
}

.mts-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.mts-table th,
.mts-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.mts-table th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
}

.mts-table tbody tr:hover {
    background: #f9fafb;
}

.mts-table tfoot tr {
    border-top: 2px solid #e5e7eb;
}

.mts-table tfoot .total-row {
    background: #f9fafb;
}

/* Plan Features Management */
.plan-features-section {
    padding: 1.5rem;
}

.plans-features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
}

.plan-features-card {
    padding: 1.5rem;
}

.plan-features-card .plan-name {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--mts-primary, #FF7F50);
}

.features-list {
    margin: 1rem 0;
}

.feature-toggle-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.feature-name {
    flex: 1;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--mts-primary, #FF7F50);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

.toggle-switch.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-content {
    background: white;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-content.large {
    max-width: 800px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #9ca3af;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.modal-close:hover {
    background: #f3f4f6;
    color: #374151;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #e5e7eb;
}

/* Form Styles */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
}

.mts-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 1rem;
}

.mts-input:focus {
    outline: none;
    border-color: var(--mts-primary, #FF7F50);
    box-shadow: 0 0 0 3px rgba(255, 127, 80, 0.1);
}

.mts-input.small {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--mts-primary, #FF7F50);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #ff6a32;
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
}

.btn-secondary:hover:not(:disabled) {
    background: #e5e7eb;
}

.btn-danger {
    background: #fee2e2;
    color: #991b1b;
}

.btn-danger:hover:not(:disabled) {
    background: #fecaca;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

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

/* Utility Classes */
.mts-card {
    background: white;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.mts-text-secondary {
    color: #6b7280;
}

.mts-text-sm {
    font-size: 0.875rem;
}

.mts-text-center {
    text-align: center;
}

.mts-text-error {
    color: #dc2626;
}

.mts-font-semibold {
    font-weight: 600;
}

.mts-mb-sm {
    margin-bottom: 0.5rem;
}

.mts-mb-md {
    margin-bottom: 1rem;
}

.mts-mt-sm {
    margin-bottom: 0.5rem;
}

.mts-mt-md {
    margin-top: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .plans-grid {
        grid-template-columns: 1fr;
    }

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

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

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

    .plan-subtabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .payment-method-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .payment-method-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .invoices-table-container {
        overflow-x: scroll;
    }

    .mts-table {
        min-width: 600px;
    }
}

/* ===== TEST MODE STYLES ===== */

/* Test Mode Banner */
.test-mode-banner {
    animation: pulse-warning 2s ease-in-out infinite;
}

@keyframes pulse-warning {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.9; }
}

/* Test Invoice Row */
.invoices-table-container tr[style*="background-color: #fef3c7"] {
    border-left: 3px solid #f59e0b;
}

/* Test Badge */
.badge {
    display: inline-block;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Status Badge Colors */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: capitalize;
}

.status-badge.pending {
    background-color: #fef3c7;
    color: #92400e;
}

.status-badge.paid {
    background-color: #d1fae5;
    color: #065f46;
}

.status-badge.overdue {
    background-color: #fee2e2;
    color: #991b1b;
}

.status-badge.draft {
    background-color: #e5e7eb;
    color: #374151;
}

.status-badge.void {
    background-color: #f3f4f6;
    color: #6b7280;
    text-decoration: line-through;
}

/* Test Mode Hint */
.test-mode-hint {
    font-size: 0.875rem;
}

.test-mode-hint small {
    display: block;
    margin-top: 0.25rem;
}

/* Simulate Payment Button */
button[onclick*="simulatePayment"] {
    background: #f59e0b !important;
    border-color: #f59e0b !important;
}

button[onclick*="simulatePayment"]:hover {
    background: #d97706 !important;
    border-color: #d97706 !important;
}
