/* Sigvera Admin Styles */
:root {
    --primary: #1E3A5F;
    --primary-dark: #152A45;
    --primary-light: #2D5A8A;
    --secondary: #00A878;
    --secondary-dark: #008560;
    --accent: #F4A261;
    --success: #00A878;
    --warning: #F4A261;
    --error: #E63946;
    --info: #457B9D;
    --white: #FFFFFF;
    --gray-100: #F8F9FA;
    --gray-200: #E9ECEF;
    --gray-300: #DEE2E6;
    --gray-400: #CED4DA;
    --gray-500: #ADB5BD;
    --gray-600: #6C757D;
    --gray-700: #495057;
    --gray-800: #343A40;
    --gray-900: #212529;
    --sidebar-width: 250px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: var(--gray-900);
    margin: 0;
    padding: 0;
    background: var(--gray-100);
}

/* Accessibility - prevent focus outline on h1 during FocusOnNavigate */
h1:focus {
    outline: none;
}

/* Admin Layout */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: var(--sidebar-width);
    background: var(--primary);
    color: var(--white);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--primary-light);
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.nav-menu {
    list-style: none;
    padding: 1rem 0;
    margin: 0;
    flex: 1;
}

.nav-menu li {
    margin: 0;
}

.nav-menu a {
    display: block;
    padding: 0.75rem 1.5rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.2s;
}

.nav-menu a:hover,
.nav-menu a.active {
    background: var(--primary-dark);
    color: var(--white);
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--primary-light);
}

.user-info {
    margin-bottom: 0.75rem;
}

.user-info span {
    display: block;
}

.user-info .role {
    font-size: 0.75rem;
    opacity: 0.7;
}

.btn-logout {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--white);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.1);
}

.admin-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
}

.login-card {
    background: var(--white);
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
}

.login-card h1 {
    color: var(--primary);
    margin: 0 0 0.5rem;
    text-align: center;
}

.login-card .subtitle {
    color: var(--gray-600);
    text-align: center;
    margin-bottom: 2rem;
}

/* Dashboard */
.dashboard h1 {
    margin: 0 0 2rem;
    color: var(--primary);
}

.dashboard h2 {
    margin: 2rem 0 1rem;
    color: var(--primary);
}

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

.stat-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.stat-card h3 {
    margin: 0 0 0.5rem;
    font-size: 0.875rem;
    color: var(--gray-600);
    font-weight: 500;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-secondary {
    font-size: 0.875rem;
    color: var(--secondary);
    margin-top: 0.25rem;
}

.stat-breakdown {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--gray-200);
    font-size: 0.875rem;
    color: var(--gray-600);
}

.stat-breakdown span {
    display: block;
}

/* Activity List */
.activity-list {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

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

.activity-type {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.activity-type.inkcode {
    background: var(--primary-light);
    color: var(--white);
}

.activity-type.verification {
    background: var(--secondary);
    color: var(--white);
}

.activity-desc {
    flex: 1;
}

.activity-time {
    color: var(--gray-500);
    font-size: 0.875rem;
}

/* Data Tables */
.data-table {
    width: 100%;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border-collapse: collapse;
    overflow: hidden;
}

.data-table th,
.data-table td {
    padding: 1rem 1.5rem;
    text-align: left;
}

.data-table th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.875rem;
}

.data-table td {
    border-bottom: 1px solid var(--gray-200);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: var(--gray-100);
}

/* Badges */
.tier-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.tier-badge.basic {
    background: var(--gray-200);
    color: var(--gray-700);
}

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

.tier-badge.enterprise {
    background: var(--primary);
    color: var(--white);
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge.active {
    background: var(--success);
    color: var(--white);
}

.status-badge.used {
    background: var(--info);
    color: var(--white);
}

.status-badge.expired {
    background: var(--gray-400);
    color: var(--gray-700);
}

.status-badge.invalid {
    background: var(--error);
    color: var(--white);
}

.action-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--gray-200);
    color: var(--gray-700);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--white);
    border-color: var(--secondary);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: var(--white);
}

.btn-danger {
    background: var(--error);
    color: var(--white);
    border-color: var(--error);
}

.btn-success {
    background: var(--success);
    color: var(--white);
    border-color: var(--success);
}

.btn-block {
    display: block;
    width: 100%;
}

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

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--gray-700);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--gray-300);
    border-radius: 8px;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

.search-input {
    padding: 0.5rem 1rem;
    border: 2px solid var(--gray-300);
    border-radius: 8px;
    min-width: 250px;
}

/* Page Headers */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    margin: 0;
    color: var(--primary);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding: 1rem;
}

/* User Detail */
.user-detail {
    max-width: 1000px;
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0 2rem;
}

.detail-header h1 {
    margin: 0;
    color: var(--primary);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.detail-section {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.detail-section h3 {
    margin: 0 0 1rem;
    color: var(--primary);
    font-size: 1rem;
}

.detail-section dl {
    margin: 0;
}

.detail-section dt {
    font-size: 0.75rem;
    color: var(--gray-600);
    margin-top: 0.75rem;
}

.detail-section dt:first-child {
    margin-top: 0;
}

.detail-section dd {
    margin: 0;
    font-weight: 500;
}

/* Admin Actions */
.admin-actions {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 2rem;
}

.admin-actions h3 {
    margin: 0 0 1rem;
    color: var(--primary);
}

.action-group {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.action-group:last-child {
    margin-bottom: 0;
}

.action-group select,
.action-group input[type="text"] {
    padding: 0.5rem 1rem;
    border: 2px solid var(--gray-300);
    border-radius: 8px;
}

.action-group input[type="text"] {
    flex: 1;
    min-width: 200px;
}

/* Recent Codes */
.recent-codes {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.recent-codes h3 {
    margin: 0 0 1rem;
    color: var(--primary);
}

.recent-codes code {
    font-family: 'Courier New', monospace;
    background: var(--gray-100);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.alert-error {
    background: #fce4e4;
    color: var(--error);
    border: 1px solid #f5c6c6;
}

.alert-success {
    background: #d4f4e4;
    color: var(--success);
    border: 1px solid #a8e6c1;
}

/* Loading */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--gray-600);
}

/* Validation */
.valid.modified:not([type=checkbox]) {
    outline: 2px solid var(--success);
}

.invalid {
    outline: 2px solid var(--error);
}

.validation-message {
    color: var(--error);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Blazor Error */
.blazor-error-boundary {
    background: var(--error);
    padding: 1rem;
    color: white;
    border-radius: 8px;
    margin: 1rem;
}

.blazor-error-boundary::after {
    content: "An error has occurred. Please refresh the page.";
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* Billing Page */
.billing-page h1 {
    margin: 0 0 2rem;
    color: var(--primary);
}

.billing-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.billing-stats .stat-card.revenue {
    border-left: 4px solid var(--success);
}

.billing-stats .stat-card.refunds {
    border-left: 4px solid var(--warning);
}

.billing-stats .stat-card.failed {
    border-left: 4px solid var(--error);
}

.stat-detail {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-top: 0.25rem;
}

.billing-sections {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.billing-section {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.billing-section h2 {
    margin: 0 0 1rem;
    color: var(--primary);
    font-size: 1.25rem;
}

.no-data {
    color: var(--gray-500);
    text-align: center;
    padding: 2rem;
}

.error-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--error);
    color: var(--white);
}

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

/* Modals */
.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: 1000;
}

.user-billing-modal {
    background: var(--white);
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.refund-modal {
    background: var(--white);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h2,
.modal-header h3 {
    margin: 0;
    color: var(--primary);
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-600);
    cursor: pointer;
    padding: 0.5rem;
}

.btn-close:hover {
    color: var(--gray-900);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid var(--gray-200);
}

/* Customer Info */
.customer-info {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--gray-100);
    border-radius: 8px;
}

.customer-info h3 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    color: var(--primary);
}

/* Subscription Section */
.subscription-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
}

.subscription-section h3 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    color: var(--primary);
}

.subscription-status {
    margin-bottom: 0.75rem;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 1.5rem;
}

.tab {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-600);
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--primary);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    min-height: 200px;
}

/* Billing Status Badges */
.status-badge.succeeded {
    background: var(--success);
    color: var(--white);
}

.status-badge.paid {
    background: var(--success);
    color: var(--white);
}

.status-badge.requires_payment_method,
.status-badge.failed,
.status-badge.canceled,
.status-badge.past_due,
.status-badge.unpaid {
    background: var(--error);
    color: var(--white);
}

.status-badge.pending,
.status-badge.processing,
.status-badge.draft,
.status-badge.open {
    background: var(--warning);
    color: var(--gray-900);
}

.status-badge.trialing {
    background: var(--info);
    color: var(--white);
}

.status-badge.warning {
    background: var(--warning);
    color: var(--gray-900);
}

.status-badge.danger {
    background: var(--error);
    color: var(--white);
}

/* Refund Form */
.refund-modal .form-group {
    margin-bottom: 1rem;
}

.refund-modal .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.refund-modal .form-group input,
.refund-modal .form-group select,
.refund-modal .form-group textarea {
    width: 100%;
    padding: 0.5rem;
    border: 2px solid var(--gray-300);
    border-radius: 8px;
    font-size: 1rem;
}

.refund-modal .form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--gray-600);
}

.error-message {
    background: #fce4e4;
    color: var(--error);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.success-message {
    background: #d4f4e4;
    color: var(--success);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .admin-sidebar {
        width: 60px;
    }

    .admin-sidebar .sidebar-header h2,
    .admin-sidebar .nav-menu a span,
    .admin-sidebar .sidebar-footer {
        display: none;
    }

    .admin-content {
        margin-left: 60px;
    }
}

/* Security / admin-users pages */
.security-page .card, .admin-users-page .card { background: #fff; border-radius: 0.75rem; padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.security-page .qr-block { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: center; margin: 1rem 0; }
.security-page .qr-block img { border: 1px solid #e5e7eb; border-radius: 0.5rem; background: #fff; }
.security-page .manual-key code { font-size: 0.95rem; letter-spacing: 0.08em; }
.security-page .setup-steps { padding-left: 1.25rem; }
.security-page form + form { margin-top: 1.5rem; }
.alert { padding: 0.75rem 1rem; border-radius: 0.5rem; margin-bottom: 1rem; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.status-badge.danger { background: #fee2e2; color: #991b1b; }
.status-badge.active { background: #d1fae5; color: #065f46; }
.text-muted { color: #6b7280; }
.admin-users-page .action-group { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.admin-users-page .action-group input, .admin-users-page .action-group select { min-width: 12rem; }
