/* Super Admin Dashboard Styles */

/* Screen Layout */
#screen-super-admin {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.screen-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.screen-header h1 {
    margin: 0 0 0.5rem 0;
    font-size: 1.75rem;
    color: var(--text-primary);
}

.screen-header p {
    margin: 0;
    color: var(--text-muted);
}

.super-admin-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

.accounts-section {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.section-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

#account-search {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-width: 300px;
    font-size: 0.9rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
}

.data-table th {
    background: var(--bg-tertiary);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    color: var(--text-primary);
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.data-table tbody tr {
    transition: background-color 0.2s;
}

.data-table tbody tr:hover {
    background: var(--bg-tertiary);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.table-container {
    overflow-x: auto;
    border-radius: 4px;
    border: 1px solid var(--border);
}

/* Badge Styles */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-personal {
    background: #e3f2fd;
    color: #1976d2;
}

.badge-team {
    background: #f3e5f5;
    color: #7b1fa2;
}

.badge-partner {
    background: #fff3e0;
    color: #e65100;
}

.badge-owner {
    background: #fff8e1;
    color: #b26a00;
}

.badge-admin {
    background: #e3f2fd;
    color: #1565c0;
}

.badge-member {
    background: #eceff1;
    color: #455a64;
}

.badge-active {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-suspended {
    background: #fff3e0;
    color: #f57c00;
}

.badge-deleted {
    background: #ffebee;
    color: #c62828;
}

/* Action Buttons */
.btn-manage-partner {
    background: var(--accent-primary, #2aa198);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    margin-right: 0.5rem;
    transition: filter 0.2s;
}

.btn-manage-partner:hover {
    filter: brightness(1.15);
}

.partner-invite-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    align-items: center;
}

/* The global `input, textarea, select { width: 100% }` rule makes every
   control demand the full row, so widths must be reset explicitly here:
   the email field takes the remaining space, the role select sizes to its
   content, and the remove button stays intrinsic. */
.partner-invite-row .invite-email {
    flex: 1 1 auto;
    width: auto;
    min-width: 12rem;
}

.partner-invite-row .invite-role {
    flex: 0 0 auto;
    width: auto;
}

.partner-invite-row .invite-remove {
    flex: 0 0 auto;
}

.partner-invite-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.75rem;
}

.btn-delete-account {
    background: var(--error);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background-color 0.2s;
}

.btn-delete-account:hover {
    background: var(--error);
}

.btn-restore-account {
    background: var(--success);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background-color 0.2s;
}

.btn-restore-account:hover {
    opacity: 0.9;
}

/* Warning Box */
.warning-box {
    background: #fff3cd;
    border: 1px solid #ffc107;
    padding: 1rem;
    border-radius: 4px;
    margin: 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.warning-box i {
    color: #856404;
    font-size: 1.5rem;
}

.warning-box p {
    margin: 0;
    color: #856404;
}

/* Audit Log */
.audit-log-section {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1.5rem;
}

.audit-log-section h2 {
    margin: 0 0 1rem 0;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.audit-log {
    background: var(--bg-primary);
    border-radius: 4px;
    padding: 1rem;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border);
}

.audit-log-entry {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.audit-log-entry:last-child {
    border-bottom: none;
}

.audit-log-entry strong {
    color: var(--text-primary);
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Delete Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal[hidden] {
    display: none;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 2rem;
    max-width: 600px;
    width: 90%;
    /* max-height makes overflow-y actually scroll instead of growing past
       the viewport. overflow-x must be set explicitly: a specified
       overflow-y of auto forces the computed overflow-x from visible to
       auto, so any 1px overflow would otherwise show a horizontal bar. */
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Partner provisioning/detail carry more content than the delete dialog */
#partner-detail-modal .modal-content,
#provision-partner-modal .modal-content {
    max-width: 720px;
}

.modal-content h2 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
}

.account-details {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 4px;
    margin: 1rem 0;
    /* Long emails, tenant names and account ids must wrap rather than
       widen the dialog (which now clips overflow-x) */
    overflow-wrap: anywhere;
}

.account-details ul {
    margin: 0.25rem 0 0;
    padding-left: 1.25rem;
    list-style: disc;
}

.account-details p {
    margin: 0.5rem 0;
    color: var(--text-primary);
}

/* Deletion Type Radio Buttons */
.deletion-options {
    margin: 1.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.radio-option {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-primary);
}

.radio-option:hover {
    border-color: var(--accent-primary);
    background: var(--bg-tertiary);
}

.radio-option input[type="radio"] {
    margin-top: 0.25rem;
    cursor: pointer;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    max-width: 18px;
    max-height: 18px;
    appearance: auto;
}

.radio-option div {
    flex: 1;
}

.radio-option input[type="radio"]:checked + div strong {
    color: var(--accent-primary);
}

.radio-option strong {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.radio-option p {
    margin: 0.25rem 0 0 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.radio-option:has(input[value="permanent"]) {
    border-color: #dc3545;
}

.radio-option:has(input[value="permanent"]:checked) {
    background: #fff5f5;
    border-color: #dc3545;
}

.radio-option:has(input[value="permanent"]:checked) strong {
    color: #dc3545;
}

/* Form Groups */
.form-group {
    margin: 1rem 0;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="url"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Modal Actions */
.modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* Buttons keep their intrinsic width and wrap to a new line instead of
   being squashed until their labels overflow (the partner detail modal
   carries several actions) */
.modal-actions > button {
    flex: 0 0 auto;
}

.btn-small {
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
}

.btn-danger {
    background: var(--error);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.btn-danger:hover:not(:disabled) {
    background: var(--error);
}

.btn-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Deleted accounts styling */
.data-table tbody tr.account-deleted {
    opacity: 0.6;
    font-style: italic;
}

.data-table tbody tr.account-deleted td {
    color: var(--text-muted);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    margin: 0;
    font-size: 1.1rem;
}