/* Global framework styles. Page specific rules belong in css/pages. */

:root {
    --app-primary: #3c8dbc;
    --app-radius: 0.5rem;
    --app-border: rgba(0, 0, 0, 0.08);
    --app-muted-bg: #f4f6f9;
    --app-hover-bg: rgba(60, 141, 188, 0.08);
    --app-selected-bg: rgba(60, 141, 188, 0.16);
}

.dark-mode {
    --app-border: rgba(255, 255, 255, 0.1);
    --app-muted-bg: #2b3035;
    --app-hover-bg: rgba(255, 255, 255, 0.06);
    --app-selected-bg: rgba(60, 141, 188, 0.35);
}

.min-width-0 {
    min-width: 0;
}

.btn-xs {
    padding: 0.1rem 0.35rem;
    font-size: 0.75rem;
}

.brand-link .brand-image {
    float: none;
    line-height: 1.5;
}

/* Uploaded logo in the sidebar brand */
.brand-link .app-brand-logo {
    width: 2.1rem;
    height: 2.1rem;
    margin-left: 0.8rem;
    margin-right: 0.5rem;
    object-fit: contain;
    vertical-align: middle;
}

/* Logo / favicon setting: preview and actions */
.app-setting-image {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.app-setting-image-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 6rem;
    height: 4rem;
    padding: 0.25rem;
    border: 1px dashed var(--app-border);
    border-radius: 0.25rem;
    background: var(--app-muted-bg);
}

.app-setting-image-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Impersonation: fixed to the bottom so it never covers the fixed navbar */
.app-impersonation-banner {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1045;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    padding: 0.5rem 1rem;
    color: #212529;
    background: repeating-linear-gradient(45deg, #ffc107, #ffc107 12px, #ffcd38 12px, #ffcd38 24px);
    box-shadow: 0 -0.25rem 1rem rgba(0, 0, 0, 0.15);
    font-weight: 600;
}

.app-impersonation-banner ~ .main-footer {
    padding-bottom: 3.5rem;
}

.app-tenant-badge {
    font-weight: 500;
}

/* Avatars */
.app-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 50%;
    color: #fff;
    font-weight: 600;
    user-select: none;
}

.app-avatar-xs { width: 1.5rem; height: 1.5rem; font-size: 0.6rem; }
.app-avatar-sm { width: 2rem; height: 2rem; font-size: 0.75rem; }
.app-avatar-md { width: 2.5rem; height: 2.5rem; font-size: 0.9rem; }
.app-avatar-xl { width: 6rem; height: 6rem; font-size: 2rem; }

.app-avatar-color-0 { background: #3c8dbc; }
.app-avatar-color-1 { background: #00a65a; }
.app-avatar-color-2 { background: #f39c12; }
.app-avatar-color-3 { background: #dd4b39; }
.app-avatar-color-4 { background: #605ca8; }
.app-avatar-color-5 { background: #39cccc; }
.app-avatar-color-6 { background: #d81b60; }
.app-avatar-color-7 { background: #6c757d; }
.app-avatar-group { background: linear-gradient(135deg, #605ca8, #3c8dbc); }

/* Status icon (round icon with tinted background) */
.app-status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    background: var(--app-muted-bg);
    color: var(--app-primary);
    font-size: 1.1rem;
}

.app-status-icon.is-success { background: rgba(40, 167, 69, 0.15); color: #28a745; }
.app-status-icon.is-warning { background: rgba(255, 193, 7, 0.2); color: #d39e00; }

/* Empty state */
.app-empty-state {
    padding: 2.5rem 1rem;
    text-align: center;
    color: #adb5bd;
}

.app-empty-state p {
    color: #6c757d;
}

/* Skeleton loading */
.app-skeleton {
    display: inline-block;
    width: 100%;
    height: 0.9rem;
    border-radius: 0.25rem;
    background: linear-gradient(90deg, var(--app-muted-bg) 25%, var(--app-border) 37%, var(--app-muted-bg) 63%);
    background-size: 400% 100%;
    animation: app-skeleton 1.4s ease infinite;
}

.app-skeleton-line { height: 1rem; margin: 0.4rem 0; }
.app-skeleton-circle { width: 2.5rem; height: 2.5rem; border-radius: 50%; flex-shrink: 0; }

@keyframes app-skeleton {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

/* Chips */
.app-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    margin: 0 0.25rem 0.25rem 0;
    padding: 0.2rem 0.6rem;
    overflow: hidden;
    border: 1px solid var(--app-border);
    border-radius: 1rem;
    background: var(--app-muted-bg);
    color: inherit;
    font-size: 0.85rem;
}

a.app-chip:hover {
    background: var(--app-hover-bg);
    text-decoration: none;
}

.app-chip-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    background: var(--app-primary);
    transition: width 0.2s ease;
}

.app-chip-input {
    display: flex;
    flex-wrap: wrap;
    min-height: 0.5rem;
}

/* Autocomplete / pickers */
.app-autocomplete {
    position: absolute;
    z-index: 1050;
    left: 0;
    right: 0;
    max-height: 260px;
    overflow-y: auto;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.app-user-picker-list {
    max-height: 280px;
    margin-top: 0.5rem;
    overflow-y: auto;
}

.app-user-picker-selected {
    margin-bottom: 0.5rem;
}

.app-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.25rem 1rem;
}

/* Tables */
.app-table-loading {
    opacity: 0.6;
    pointer-events: none;
}

.app-data-table td {
    vertical-align: middle;
}

.app-sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.app-sortable::after {
    content: "\f0dc";
    margin-left: 0.35rem;
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    opacity: 0.25;
}

.app-sortable.is-sorted-asc::after { content: "\f0de"; opacity: 0.8; }
.app-sortable.is-sorted-desc::after { content: "\f0dd"; opacity: 0.8; }

.app-table-search {
    max-width: 320px;
}

.app-filter,
.app-table-filter,
.app-page-size {
    width: auto;
}

.app-json-cell {
    max-width: 360px;
    overflow-wrap: anywhere;
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.app-override-cell {
    width: 160px;
}

.app-change-table {
    max-height: 60vh;
    overflow: auto;
}

.app-error-detail {
    max-height: 50vh;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Permission groups */
.app-permission-group {
    padding: 0.75rem 1rem;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
}

.app-permission-group legend {
    width: auto;
    margin-bottom: 0;
    padding: 0 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
}

/* Sticky helpers */
.app-sticky-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    padding: 0.75rem 0;
    background: var(--app-muted-bg);
    border-top: 1px solid var(--app-border);
}

.app-sticky-card {
    position: sticky;
    top: 4.5rem;
}

/* Timeline */
.app-timeline {
    position: relative;
    margin: 0;
    padding: 0 0 0 1.5rem;
    list-style: none;
}

.app-timeline::before {
    content: "";
    position: absolute;
    top: 0.3rem;
    bottom: 0.3rem;
    left: 0.4rem;
    width: 2px;
    background: var(--app-border);
}

.app-timeline > li {
    position: relative;
    padding-bottom: 1rem;
}

.app-timeline-dot {
    position: absolute;
    top: 0.35rem;
    left: -1.35rem;
    width: 0.75rem;
    height: 0.75rem;
    border: 2px solid var(--app-primary);
    border-radius: 50%;
    background: #fff;
}

.dark-mode .app-timeline-dot {
    background: #343a40;
}

/* Notifications */
.app-notification-menu {
    width: 360px;
    max-width: 95vw;
}

.app-notification-item {
    white-space: normal;
    border-left: 3px solid transparent;
}

.app-notification-item.is-unread,
.app-notification-row.is-unread {
    border-left-color: var(--app-primary);
    background: var(--app-hover-bg);
}

.app-notification-row {
    display: flex;
    align-items: flex-start;
    border-left: 3px solid transparent;
}

.app-notification-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    margin-right: 0.75rem;
    border-radius: 50%;
    background: var(--app-muted-bg);
}

.app-notification-preview {
    display: flex;
    align-items: flex-start;
    padding: 0.75rem;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    background: var(--app-muted-bg);
    overflow-wrap: anywhere;
}

/* Profile */
.app-profile-nav .nav-link {
    border-radius: 0;
}

.app-qr {
    max-width: 220px;
    border-radius: var(--app-radius);
    background: #fff;
    padding: 0.5rem;
}

.app-otp-input {
    letter-spacing: 0.5rem;
}

.app-recovery-codes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.app-recovery-codes code {
    padding: 0.35rem;
    border-radius: 0.25rem;
    background: var(--app-muted-bg);
    font-size: 1rem;
}

/* Password strength meter (score 0-4 from data-score) */
.app-strength {
    display: flex;
    gap: 0.25rem;
}

.app-strength span {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--app-border);
    transition: background 0.2s ease;
}

.app-strength[data-score="1"] span:nth-child(-n+1) { background: #dc3545; }
.app-strength[data-score="2"] span:nth-child(-n+2) { background: #fd7e14; }
.app-strength[data-score="3"] span:nth-child(-n+3) { background: #ffc107; }
.app-strength[data-score="4"] span { background: #28a745; }

/* System */
.app-stat-button {
    border: 0;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.app-stat-button:hover {
    transform: translateY(-2px);
}

.app-health-card .card-body {
    padding: 0.9rem 1rem;
}

/* Context menu (file explorer) */
.app-context-menu {
    position: fixed;
    z-index: 1060;
}

.app-context-menu.show {
    display: block;
}

/* SweetAlert2 inside AdminLTE */
.swal2-popup {
    font-size: 0.95rem;
}

.swal2-popup .list-group-item.active .text-muted {
    color: rgba(255, 255, 255, 0.8) !important;
}

.dark-mode .swal2-popup {
    background: #343a40;
    color: #fff;
}

.dark-mode .swal2-title,
.dark-mode .swal2-html-container {
    color: #fff;
}

/* Dark mode tweaks */
.dark-mode .app-chip,
.dark-mode .app-notification-preview {
    color: #fff;
}
