/* ================================================================
   FILE: assets/css/core/core.css
   PURPOSE: Core Application Layout, Preloaders, Progress Bars & Animations
   ================================================================ */

body {
    background-color: var(--panel-bg);
    color: var(--text-primary);
    display: flex;
    height: 100vh;
    overflow: hidden;
    transition: background-color var(--transition-base), color var(--transition-base);
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
}

.layout-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    width: 100%;
    position: relative;
}

.main-content {
    flex: 1;
    padding: 2rem 2.5rem;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    min-width: 0;
    min-height: 0;
    position: relative;
}

@media (max-width: 768px) {
    .main-content {
        padding: 1.25rem 1rem;
    }
}

.page-header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 1.75rem;
    margin: 0;
    letter-spacing: -0.025em;
    font-weight: 800;
}

/* ------------------------------------------------------------
   NProgress-Style Top Progress Bar
   ------------------------------------------------------------ */
#top-progress-bar,
.top-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: var(--primary-gradient);
    box-shadow: 0 0 10px var(--primary-glow);
    z-index: 99999;
    pointer-events: none;
    transition: width 200ms ease, opacity 250ms ease;
    border-radius: 0 2px 2px 0;
}

#top-progress-bar.finished,
.top-progress-bar.finished {
    opacity: 0;
    transition: opacity 300ms ease 100ms;
}

/* ------------------------------------------------------------
   Full-Screen Page Preloader
   ------------------------------------------------------------ */
#page-preloader {
    position: fixed;
    inset: 0;
    background: var(--bg-color);
    z-index: 99998;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

#page-preloader.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.preloader-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.preloader-logo {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px var(--primary-glow);
    animation: preloaderPulse 1.6s ease-in-out infinite;
}

.preloader-logo svg {
    width: 28px;
    height: 28px;
    fill: #ffffff;
}

.preloader-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.preloader-bar-wrap {
    width: 140px;
    height: 3px;
    background: var(--border-color);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.preloader-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 40%;
    background: var(--primary-gradient);
    border-radius: 999px;
    animation: preloaderIndeterminate 1.2s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

@keyframes preloaderPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 8px 20px var(--primary-glow); }
    50% { transform: scale(1.06); box-shadow: 0 14px 30px var(--primary-glow); }
}

@keyframes preloaderIndeterminate {
    0% { left: -40%; width: 30%; }
    50% { width: 60%; }
    100% { left: 100%; width: 30%; }
}

/* ------------------------------------------------------------
   Skeleton Loaders (Shimmer)
   ------------------------------------------------------------ */
.skeleton {
    background: linear-gradient(90deg, 
        rgba(148, 163, 184, 0.12) 25%, 
        rgba(148, 163, 184, 0.24) 50%, 
        rgba(148, 163, 184, 0.12) 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite;
    border-radius: var(--radius-sm);
    display: inline-block;
}

[data-theme="dark"] .skeleton {
    background: linear-gradient(90deg, 
        rgba(30, 41, 59, 0.6) 25%, 
        rgba(51, 65, 85, 0.7) 50%, 
        rgba(30, 41, 59, 0.6) 75%);
    background-size: 200% 100%;
}

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

.skeleton-text {
    height: 14px;
    width: 100%;
    margin-bottom: 8px;
    border-radius: 4px;
}

.skeleton-title {
    height: 22px;
    width: 60%;
    margin-bottom: 12px;
    border-radius: 6px;
}

.skeleton-card {
    height: 120px;
    width: 100%;
    border-radius: var(--radius-md);
}

.skeleton-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

/* ------------------------------------------------------------
   Scrollbar Theming
   ------------------------------------------------------------ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--slate-300);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--slate-400);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: var(--slate-700);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: var(--slate-600);
}

/* ------------------------------------------------------------
   Micro-Animations & Smooth Motion
   ------------------------------------------------------------ */
@keyframes spin {
    100% { transform: rotate(360deg); }
}

.icon-spin {
    animation: spin 1s linear infinite;
}

@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInOverlay {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes popupScaleIn {
    from {
        opacity: 0;
        transform: translate(-50%, -48%) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Animation utilities */
.animate-fade-up {
    animation: fadeSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ------------------------------------------------------------
   Progressive Enhancement: prefers-reduced-motion
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    #top-progress-bar,
    .top-progress-bar {
        display: none !important;
    }
    #page-preloader {
        display: none !important;
    }
}
