/* =============================================================
   UX IMPROVEMENTS CSS
   1. Skeleton loading
   2. Toast notifications
   3. Responsive tables
   4. Pull-to-refresh
   5. Infinite scroll
   6. Button micro-interactions
   7. Breadcrumbs
   8. Connection indicator
   9. Compact mode
   10. Accessibility (focus-visible + aria)
   ============================================================= */

/* === 1. SKELETON LOADING === */
.skeleton {
    position: relative;
    overflow: hidden;
    background: var(--glass-bg, rgba(255,255,255,0.05));
    border-radius: 8px;
    color: transparent !important;
    pointer-events: none;
    user-select: none;
}
.skeleton * { visibility: hidden; }
.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255,255,255,0.06) 40%,
        rgba(255,255,255,0.12) 50%,
        rgba(255,255,255,0.06) 60%,
        transparent 100%);
    animation: skeletonShimmer 1.8s infinite;
}
[data-theme="light"] .skeleton::after {
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(0,0,0,0.04) 40%,
        rgba(0,0,0,0.08) 50%,
        rgba(0,0,0,0.04) 60%,
        transparent 100%);
}
@keyframes skeletonShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}
.skeleton-line {
    height: 14px;
    border-radius: 6px;
    margin-bottom: 10px;
    background: var(--glass-bg, rgba(255,255,255,0.08));
}
.skeleton-line.w-50 { width: 50%; }
.skeleton-line.w-75 { width: 75%; }
.skeleton-line.w-100 { width: 100%; }
.skeleton-line.h-lg { height: 24px; }
.skeleton-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--glass-bg, rgba(255,255,255,0.08));
}
.skeleton-card {
    padding: 20px;
    border-radius: 16px;
    background: var(--glass-bg, rgba(255,255,255,0.03));
    border: 1px solid var(--glass-border, rgba(255,255,255,0.06));
}

/* === 2. TOAST NOTIFICATIONS === */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    pointer-events: none;
    max-width: 400px;
}
.toast {
    pointer-events: auto;
    padding: 14px 18px;
    border-radius: 14px;
    background: rgba(30,41,59,0.95);
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 12px 40px rgba(0,0,0,0.4);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    animation: toastIn 0.35s ease;
    transform-origin: bottom right;
}
[data-theme="light"] .toast {
    background: rgba(255,255,255,0.95);
    color: #1e293b;
    border-color: rgba(0,0,0,0.08);
    box-shadow: 0 12px 40px rgba(0,0,0,0.12);
}
.toast.toast-out { animation: toastOut 0.3s ease forwards; }
.toast-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.85rem;
}
.toast.toast-success .toast-icon { background: rgba(34,197,94,0.15); color: #22c55e; }
.toast.toast-error .toast-icon { background: rgba(239,68,68,0.15); color: #ef4444; }
.toast.toast-info .toast-icon { background: rgba(59,130,246,0.15); color: #3b82f6; }
.toast.toast-warning .toast-icon { background: rgba(245,158,11,0.15); color: #f59e0b; }
.toast-close {
    margin-left: auto;
    cursor: pointer;
    opacity: 0.5;
    padding: 4px;
    transition: opacity 0.2s;
}
.toast-close:hover { opacity: 1; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(100%); } }
@media (max-width: 480px) {
    #toast-container { left: 12px; right: 12px; bottom: 80px; max-width: none; }
}

/* === 3. RESPONSIVE TABLES === */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
}
.table-responsive::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 30px;
    height: 100%;
    background: linear-gradient(to left, var(--bg-secondary, #111625), transparent);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}
.table-responsive.has-scroll::after { opacity: 1; }
.table-responsive table { min-width: 600px; }

/* === 4. PULL-TO-REFRESH === */
.ptr-indicator {
    position: fixed;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-color, #4361ee);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(67,97,238,0.3);
    transition: top 0.3s ease;
    z-index: 9999;
    font-size: 1.1rem;
}
.ptr-indicator.visible { top: 80px; }
.ptr-indicator.refreshing i { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* === 5. INFINITE SCROLL === */
.infinite-scroll-loader {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary, #a0a8c0);
    font-weight: 600;
    font-size: 0.85rem;
}
.infinite-scroll-loader i { margin-right: 8px; }
.infinite-scroll-end {
    text-align: center;
    padding: 16px;
    color: var(--text-secondary, #a0a8c0);
    font-size: 0.82rem;
    font-weight: 600;
    opacity: 0.6;
}

/* === 6. BUTTON MICRO-INTERACTIONS === */
.btn, button, [type="submit"], [type="button"], .btn-primary, .btn-secondary,
.btn-text, .btn-outline, .btn-danger, .btn-success, .btn-view-site {
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, background 0.2s ease !important;
}
.btn:active, button:active:not(:disabled), [type="submit"]:active, [type="button"]:active {
    transform: scale(0.97) !important;
}
.btn:hover:not(:disabled), button:hover:not(:disabled) {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.btn:disabled, button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
/* Ripple effect placeholder */
.btn-ripple {
    position: relative;
    overflow: hidden;
}
.btn-ripple::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--ripple-x, 50%) var(--ripple-y, 50%), rgba(255,255,255,0.25), transparent 60%);
    opacity: 0;
    transition: opacity 0.4s;
}
.btn-ripple:active::after { opacity: 1; transition: opacity 0s; }

/* === 7. BREADCRUMBS === */
.breadcrumb-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    margin-bottom: 16px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary, #a0a8c0);
    flex-wrap: wrap;
}
.breadcrumb-bar a {
    color: var(--text-secondary, #a0a8c0);
    text-decoration: none;
    transition: color 0.2s;
}
.breadcrumb-bar a:hover { color: var(--primary-color, #4361ee); }
.breadcrumb-bar .sep {
    color: var(--glass-border, rgba(255,255,255,0.15));
    font-size: 0.7rem;
}
.breadcrumb-bar .current {
    color: var(--text-primary, #fff);
    font-weight: 700;
}

/* === 8. CONNECTION INDICATOR === */
.conn-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34,197,94,0.5);
    display: inline-block;
    margin-right: 8px;
    transition: background 0.3s, box-shadow 0.3s;
}
.conn-indicator.offline {
    background: #ef4444;
    box-shadow: 0 0 8px rgba(239,68,68,0.5);
    animation: connPulse 1.5s infinite;
}
@keyframes connPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* === 9. COMPACT MODE === */
body.compact-mode .data-table th,
body.compact-mode .data-table td,
body.compact-mode table.tbl th,
body.compact-mode table.tbl td {
    padding: 5px 8px !important;
    font-size: 0.78rem !important;
}
body.compact-mode .data-table,
body.compact-mode table.tbl {
    font-size: 0.82rem;
}
body.compact-mode .stat-card { padding: 12px !important; }
body.compact-mode .card { padding: 14px !important; }
.compact-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--glass-border, rgba(255,255,255,0.1));
    background: var(--glass-bg, rgba(255,255,255,0.05));
    color: var(--text-secondary, #a0a8c0);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}
.compact-toggle:hover { background: rgba(255,255,255,0.08); color: var(--text-primary, #fff); }
.compact-toggle.active { background: var(--primary-color, #4361ee); color: #fff; border-color: transparent; }

/* === 10. ACCESSIBILITY === */
:focus-visible {
    outline: 2px solid var(--primary-color, #4361ee) !important;
    outline-offset: 2px !important;
    border-radius: 4px;
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}
/* Skip to content link */
.skip-link {
    position: absolute;
    top: -100px;
    left: 12px;
    background: var(--primary-color, #4361ee);
    color: #fff;
    padding: 10px 18px;
    border-radius: 0 0 8px 8px;
    font-weight: 700;
    z-index: 100000;
    text-decoration: none;
    transition: top 0.2s;
}
.skip-link:focus { top: 0; }
