/* ============================================
   Admin Dashboard Styles
   ============================================ */

/* Layout */
.admin-dashboard,
.admin-users,
.admin-subscriptions,
.admin-events {
    max-width: 1200px;
    margin: 0 auto;
}

.admin-subscriptions {
    max-width: 1400px;
}

/* ============================================
   Metrics Grid (Dashboard)
   ============================================ */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.metric-card {
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    padding: var(--space-5);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

.metric-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-gray-100);
    border-radius: var(--radius-md);
    color: var(--color-text);
    flex-shrink: 0;
}

.metric-icon.highlight {
    background: var(--color-black);
    color: white;
}

.metric-content {
    flex: 1;
}

.metric-value {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    line-height: 1.2;
}

.metric-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-1);
}

.metric-change {
    font-size: var(--font-size-xs);
    color: var(--color-success);
}

/* ============================================
   Stats Grid (Dashboard)
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.stats-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.stats-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4);
    background: var(--color-gray-50);
    border-bottom: 1px solid var(--color-border);
}

.stats-card-header h2 {
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
}

.stats-card-body {
    padding: var(--space-4);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-2) 0;
}

.stat-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.stat-value {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    font-family: var(--font-mono);
}

.stat-value.highlight {
    color: var(--color-success);
    font-weight: var(--font-weight-bold);
}

.stat-divider {
    height: 1px;
    background: var(--color-border);
    margin: var(--space-3) 0;
}

/* ============================================
   Activity Grid (Dashboard)
   ============================================ */
.activity-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
}

.activity-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.activity-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4);
    background: var(--color-gray-50);
    border-bottom: 1px solid var(--color-border);
}

.activity-header h2 {
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
}

.activity-list {
    max-height: 400px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border);
}

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

.activity-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.activity-title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
}

.activity-meta {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* ============================================
   Search Bar
   ============================================ */
.search-bar {
    margin-bottom: var(--space-4);
}

.search-form {
    display: flex;
    gap: var(--space-3);
    align-items: center;
}

.search-input {
    flex: 1;
    max-width: 400px;
    padding: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
}

.search-input:focus {
    outline: none;
    border-color: var(--color-black);
}

/* ============================================
   Tables (Shared)
   ============================================ */
.users-card,
.subscriptions-card,
.events-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.users-table,
.subscriptions-table,
.events-table {
    width: 100%;
    border-collapse: collapse;
}

.users-table th,
.users-table td,
.subscriptions-table th,
.subscriptions-table td,
.events-table th,
.events-table td {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.users-table th,
.subscriptions-table th,
.events-table th {
    background: var(--color-gray-50);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

.users-table td,
.subscriptions-table td,
.events-table td {
    font-size: var(--font-size-sm);
}

.users-table tbody tr:hover,
.subscriptions-table tbody tr:hover,
.events-table tbody tr:hover {
    background: var(--color-gray-50);
}

/* ============================================
   User Info
   ============================================ */
.user-email {
    display: block;
    font-weight: var(--font-weight-medium);
}

.user-id {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    background: var(--color-gray-100);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    width: fit-content;
}

td .user-id {
    background: none;
    padding: 0;
}

/* ============================================
   Tier Badges
   ============================================ */
.tier-badge {
    padding: 2px 8px;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    border-radius: var(--radius-full);
    text-transform: uppercase;
}

.tier-free {
    background: var(--color-gray-100);
    color: var(--color-text-muted);
}

.tier-pro {
    background: var(--color-black);
    color: white;
}

.tier-enterprise {
    background: var(--color-gray-900);
    color: white;
}

/* ============================================
   Status Badges
   ============================================ */
.status-badge {
    padding: 2px 8px;
    font-size: var(--font-size-xs);
    border-radius: var(--radius-full);
}

.status-active {
    background: #dcfce7;
    color: #166534;
}

.status-canceled {
    background: #fef2f2;
    color: #991b1b;
}

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

.status-gifted {
    background: #e0e7ff;
    color: #3730a3;
}

.status-none {
    color: var(--color-text-muted);
}

/* ============================================
   Event Badges
   ============================================ */
.event-badge {
    padding: 4px 10px;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.event-created {
    background: #dcfce7;
    color: #166534;
}

.event-renewed {
    background: #dbeafe;
    color: #1e40af;
}

.event-canceled {
    background: #fef2f2;
    color: #991b1b;
}

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

.badge-subscription {
    background: #dcfce7;
    color: #166534;
}

.badge-canceled {
    background: #fef2f2;
    color: #991b1b;
}

.badge-webhook {
    background: #f3e8ff;
    color: #6b21a8;
}

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

.badge-workspace {
    background: #e0e7ff;
    color: #3730a3;
}

.badge-default {
    background: var(--color-gray-100);
    color: var(--color-text-muted);
}

/* ============================================
   Event Time Display
   ============================================ */
.event-time {
    display: block;
    font-weight: var(--font-weight-medium);
}

.event-ago {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* ============================================
   Misc Elements
   ============================================ */
.subscription-id {
    font-size: var(--font-size-xs);
    background: var(--color-gray-100);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

.verified {
    color: var(--color-success);
}

.not-verified {
    color: var(--color-text-muted);
}

.already-pro {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

.text-muted {
    color: var(--color-text-muted);
}

.canceled-date {
    color: #991b1b;
}

.btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--font-size-xs);
}

.btn-link {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    text-decoration: none;
}

.btn-link:hover {
    color: var(--color-text);
    text-decoration: underline;
}

.empty-state {
    padding: var(--space-8);
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

.metadata-content {
    display: none;
}

/* ============================================
   Pagination
   ============================================ */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-6);
}

.page-link {
    padding: var(--space-2) var(--space-3);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    color: var(--color-text);
    text-decoration: none;
}

.page-link:hover {
    background: var(--color-gray-50);
}

.page-link.active {
    background: var(--color-black);
    border-color: var(--color-black);
    color: white;
}

.page-ellipsis {
    padding: var(--space-2);
    color: var(--color-text-muted);
}

/* ============================================
   Modal
   ============================================ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.modal-content.modal-lg {
    max-width: 600px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-border);
}

.modal-header h2 {
    margin: 0;
    font-size: var(--font-size-lg);
}

.modal-close {
    background: none;
    border: none;
    font-size: var(--font-size-xl);
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--color-text);
}

.modal-body {
    padding: var(--space-5);
    overflow: auto;
}

.modal-body p {
    margin: 0 0 var(--space-2);
    color: var(--color-text-muted);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--color-border);
    background: var(--color-gray-50);
}

.gift-email {
    font-weight: var(--font-weight-semibold);
    color: var(--color-text) !important;
    margin-bottom: var(--space-4) !important;
}

.metadata-display {
    background: var(--color-gray-50);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-family: var(--font-mono);
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

/* ============================================
   Form Elements
   ============================================ */
.form-group {
    margin-bottom: var(--space-4);
}

.form-group label {
    display: block;
    margin-bottom: var(--space-2);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
}

.form-select,
.form-input {
    width: 100%;
    padding: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .metrics-grid,
    .stats-grid,
    .activity-grid {
        grid-template-columns: 1fr;
    }
}
