/* ═══════════════════════════════════════════════
 *  Super Admin Dashboard
 * ═══════════════════════════════════════════════ */

.sa-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: var(--space-lg) var(--space-xl);
    box-sizing: border-box;
}

.sa-title {
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
    margin-bottom: var(--space-lg);
}

/* ── Stats Grid — 6 cards (3 x 2) ──────────── */
.sa-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.sa-stats-grid .stat-card {
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: var(--space-md);
    transition: var(--transition);
}

.sa-stats-grid .stat-card:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-lg);
}

.sa-stats-grid .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sa-stats-grid .stat-icon.blue   { background: var(--primary-bg); color: var(--primary); }
.sa-stats-grid .stat-icon.green  { background: #E8F5E9; color: var(--success); }
.sa-stats-grid .stat-icon.orange { background: #FFF3E0; color: #FF9800; }
.sa-stats-grid .stat-icon.trial  { background: #E3F2FD; color: #1976D2; }
.sa-stats-grid .stat-icon.gray   { background: var(--gray-100); color: var(--gray-500); }
.sa-stats-grid .stat-icon.purple { background: #EDE7F6; color: #5E35B1; }

.sa-stats-grid .stat-info h4 {
    font-size: 0.8125rem;
    font-weight: var(--font-medium);
    color: var(--gray-500);
    margin-bottom: var(--space-xs);
}

.sa-stats-grid .stat-info .stat-value {
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
    color: var(--gray-900);
    min-height: 2rem;
    display: flex;
    align-items: center;
}

/* Stat loading skeleton */
.stat-loading {
    display: inline-block;
    width: 48px;
    height: 20px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease infinite;
}

@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Section ────────────────────────────────── */
.sa-section {
    margin-bottom: var(--space-xl);
}

.sa-section-title {
    font-size: var(--text-lg);
    font-weight: var(--font-bold);
    margin-bottom: var(--space-md);
}

/* ── Table Wrapper (admin.css .qa-table-wrap pattern) ── */
.sa-table-wrap {
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    position: relative;
}

/* Loading overlay */
.table-loading {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.7);
    z-index: 5;
    align-items: center;
    justify-content: center;
}

.table-loading.show {
    display: flex;
}

.table-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: tableSpin 0.7s linear infinite;
}

@keyframes tableSpin {
    to { transform: rotate(360deg); }
}

.sa-table {
    width: 100%;
}

/* Cell link */
.cell-link {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}

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

/* Company detail modal grid — 2 columns */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.5rem;
}

.detail-row {
    display: flex;
    align-items: baseline;
    gap: var(--space-md);
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--gray-100);
}

.detail-row:nth-last-child(-n+2) {
    border-bottom: none;
}

.detail-label {
    flex-shrink: 0;
    width: 100px;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--gray-500);
}

.detail-value {
    font-size: var(--text-sm);
    color: var(--gray-900);
}

/* Admin list in modal */
.admin-list-title {
    font-size: var(--text-base);
    font-weight: var(--font-bold);
    margin-top: var(--space-lg);
    margin-bottom: var(--space-sm);
    padding-top: var(--space-md);
    border-top: 1px solid var(--gray-200);
}

.admin-list-area {
    font-size: var(--text-sm);
}

.admin-list-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.admin-list-table th,
.admin-list-table td {
    padding: 0.5rem 0.625rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.admin-list-table th {
    font-weight: 600;
    color: var(--gray-600);
    background: var(--gray-50);
    white-space: nowrap;
    font-size: var(--text-xs);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-500);
}

/* ── Toolbar (admin.css pattern) ────────────── */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: var(--space-md);
}

.toolbar select {
    min-width: 120px;
}

/* ── Status Badges ──────────────────────────── */
.badge-active,
.badge-success {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    background: #E8F5E9;
    color: #2E7D32;
}

.badge-trial {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    background: #E3F2FD;
    color: #1565C0;
}

.badge-failed {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    background: #FFEBEE;
    color: #C62828;
}

/* ── Approval Status Badges ────────────────── */
.badge-pending {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    background: #FFF8E1;
    color: #F57F17;
}

.badge-approved {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    background: #E8F5E9;
    color: #2E7D32;
}

.badge-rejected {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    background: #FFEBEE;
    color: #C62828;
}

/* ── Management Column Buttons ─────────────── */
.action-btn-group {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.btn-admin-view,
.btn-validate,
.btn-approve,
.btn-reject,
.btn-delete,
.btn-sub-activate,
.btn-sub-deactivate {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    cursor: pointer;
    border: 1px solid;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-admin-view {
    background: #F3E5F5;
    color: #6A1B9A;
    border-color: #E1BEE7;
}

.btn-admin-view:hover {
    background: #E1BEE7;
}

.btn-validate {
    background: #E3F2FD;
    color: #1565C0;
    border-color: #BBDEFB;
}

.btn-validate:hover {
    background: #BBDEFB;
}

.btn-approve {
    background: #E8F5E9;
    color: #2E7D32;
    border-color: #C8E6C9;
}

.btn-approve:hover {
    background: #C8E6C9;
}

.btn-reject {
    background: #FFEBEE;
    color: #C62828;
    border-color: #FFCDD2;
}

.btn-reject:hover {
    background: #FFCDD2;
}

.btn-delete {
    background: #D32F2F;
    color: #fff;
    border-color: #B71C1C;
}

.btn-delete:hover {
    background: #B71C1C;
}

.btn-sub-activate {
    background: #E8F5E9;
    color: #2E7D32;
    border-color: #C8E6C9;
}

.btn-sub-activate:hover {
    background: #C8E6C9;
}

.btn-sub-deactivate {
    background: #FFF3E0;
    color: #E65100;
    border-color: #FFE0B2;
}

.btn-sub-deactivate:hover {
    background: #FFE0B2;
}

/* ── Validation Result Modal ───────────────── */
.validation-result {
    padding: var(--space-md);
}

.validation-pass {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: #E8F5E9;
    border-radius: var(--radius-md);
    color: #2E7D32;
    font-weight: var(--font-medium);
}

.validation-warn-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: #FFF3E0;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    color: #E65100;
    font-weight: var(--font-medium);
}

.validation-warn-list {
    list-style: none;
    padding: 0;
    margin: 0;
    border: 1px solid #FFE0B2;
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    max-height: 300px;
    overflow-y: auto;
}

.validation-warn-item {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid #FFF3E0;
    font-size: var(--text-sm);
}

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

.validation-warn-item .warn-type {
    font-weight: var(--font-bold);
    color: #E65100;
    margin-right: 0.25rem;
}

.validation-warn-item .warn-detail {
    display: block;
    margin-top: 0.25rem;
    color: var(--gray-500);
    font-size: var(--text-xs);
}

/* ── Reject Reason Textarea ────────────────── */
.reject-textarea {
    width: 100%;
    min-height: 100px;
    padding: var(--space-sm);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
}

.reject-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.badge-cancelled,
.badge-expired,
.badge-inactive {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    background: var(--gray-100);
    color: var(--gray-600);
}

/* ── Role Badge (reused from admin.css) ─────── */
.role-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.6875rem;
    font-weight: var(--font-medium);
    line-height: 1.4;
}

.role-badge.role-super_admin {
    background: #E8EAF6;
    color: #283593;
}

/* ── Excel Upload ────────────────────────────── */
.sa-upload-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
}

.upload-template-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--primary);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    text-decoration: none;
    padding: 0.375rem 0;
}

.upload-template-link:hover {
    text-decoration: underline;
}

.upload-file-area {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--gray-400);
}

.upload-file-area:hover,
.upload-file-area.dragover {
    border-color: var(--primary);
    background: var(--primary-bg);
    color: var(--primary);
}

.upload-file-text {
    font-size: var(--text-sm);
    color: var(--gray-600);
    margin: 0.5rem 0 0.25rem;
}

.upload-file-hint {
    font-size: var(--text-xs);
    color: var(--gray-400);
    margin: 0;
}

.upload-file-name {
    font-size: var(--text-sm);
    color: var(--primary);
    font-weight: var(--font-medium);
    margin-top: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: var(--primary-bg);
    border-radius: var(--radius-sm);
}

.upload-result {
    margin-top: var(--space-md);
    padding: var(--space-md);
    background: var(--gray-50);
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
}

.upload-result h4 {
    font-size: var(--text-sm);
    font-weight: var(--font-bold);
    margin-bottom: var(--space-sm);
    color: var(--gray-700);
}

.upload-result-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.upload-stat-item {
    text-align: center;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    background: var(--white);
    border: 1px solid var(--gray-200);
}

.upload-stat-item.success { border-color: #C8E6C9; background: #E8F5E9; }
.upload-stat-item.skipped { border-color: #FFE0B2; background: #FFF3E0; }
.upload-stat-item.failed  { border-color: #FFCDD2; background: #FFEBEE; }

.upload-stat-label {
    display: block;
    font-size: var(--text-xs);
    color: var(--gray-500);
    margin-bottom: 0.125rem;
}

.upload-stat-value {
    display: block;
    font-size: var(--text-lg);
    font-weight: var(--font-bold);
    color: var(--gray-800);
}

.upload-stat-item.success .upload-stat-value { color: var(--success); }
.upload-stat-item.skipped .upload-stat-value { color: #FF9800; }
.upload-stat-item.failed .upload-stat-value  { color: var(--danger); }

.upload-result-errors {
    margin-top: 0.75rem;
}

.upload-result-errors h5 {
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    color: var(--danger);
    margin-bottom: 0.375rem;
}

.upload-result-errors ul {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 150px;
    overflow-y: auto;
}

.upload-result-errors li {
    font-size: var(--text-xs);
    color: var(--gray-600);
    padding: 0.25rem 0.5rem;
    border-bottom: 1px solid var(--gray-100);
    line-height: 1.5;
}

.upload-result-errors li:last-child {
    border-bottom: none;
}

.required { color: var(--danger); }

#uploadBtn {
    position: relative;
    min-width: 80px;
}

#uploadBtn .btn-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: tableSpin 0.6s linear infinite;
}

#uploadBtn.loading .btn-text { visibility: hidden; }
#uploadBtn.loading .btn-spinner {
    display: block;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

/* ── Toast (reused from admin.css) ──────────── */
.toast-container {
    position: fixed;
    top: calc(var(--header-height) + 0.5rem);
    right: var(--space-lg);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    background: var(--white);
    box-shadow: var(--shadow-lg);
    font-size: var(--text-sm);
    min-width: 260px;
    max-width: 400px;
    animation: toastIn 0.3s ease;
    border-left: 4px solid var(--gray-400);
}

.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon   { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }

.toast-msg {
    flex: 1;
    line-height: 1.4;
}

.toast-close {
    color: var(--gray-400);
    cursor: pointer;
    padding: 2px;
    font-size: var(--text-lg);
    line-height: 1;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.toast-close:hover {
    color: var(--gray-700);
    background: var(--gray-100);
}

.toast.removing {
    animation: toastOut 0.25s ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(40px); }
}

/* ── Responsive ─────────────────────────────── */

/* Mobile */
@media (max-width: 767px) {
    .sa-container {
        padding: var(--space-md);
    }

    .sa-title {
        font-size: 1.25rem;
    }

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

    .sa-stats-grid .stat-card:hover {
        transform: none;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .sa-table .col-card,
    .sa-table .col-date {
        display: none;
    }

    .toast-container {
        right: 0.75rem;
        left: 0.75rem;
    }

    .toast {
        min-width: auto;
        max-width: 100%;
    }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 1023px) {
    .sa-container {
        padding: 1.5rem;
    }

    .sa-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .sa-container {
        padding: 1.5rem 2rem;
    }
}

/* Large screens */
@media (min-width: 1440px) {
    .sa-container {
        padding: 1.5rem 2.5rem;
    }
}
