/*
  Pakistan Independence Day seasonal theme.
  Active when <html> has class theme-pk-independence (Aug 13–15 every year).
*/

html.theme-pk-independence {
    --pk-green: #01411c;
    --pk-green-mid: #0a6b3c;
    --pk-green-bright: #1a8f55;
    --pk-gold: #c9a227;
    --pk-gold-soft: #e8d48b;
    --pk-white: #ffffff;

    --maintix-base: #f3f7f4;
    --maintix-surface: #ffffff;
    --maintix-dark: #0a2e1c;
    --maintix-text: #0a2e1c;
    --maintix-muted: #4a6b58;
    --maintix-border: #d5e5db;
    --maintix-soft: #e8f2ec;
    --maintix-orange: #c9a227;
    --maintix-blue: #0a6b3c;
    --maintix-cyan: #1a8f55;
    --maintix-green: #0a6b3c;
    --maintix-active: linear-gradient(135deg, #01411c 0%, #1a8f55 100%);
    --maintix-shadow: 0 4px 24px -4px rgba(1, 65, 28, 0.08);
    --maintix-shadow-hover: 0 14px 32px -8px rgba(1, 65, 28, 0.18);
}

/* —— Boot preloader —— */
html.theme-pk-independence .loader-container {
    background:
        radial-gradient(ellipse 80% 50% at 50% 0%, rgba(26, 143, 85, 0.18), transparent 55%),
        linear-gradient(165deg, #062816 0%, #01411c 45%, #0a2e1c 100%);
    color: var(--pk-white);
}

html.theme-pk-independence .loader-container .spinner {
    display: none;
}

html.theme-pk-independence .pk-boot-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

html:not(.theme-pk-independence) .pk-boot-loader {
    display: none !important;
}

html.theme-pk-independence .pk-crescent-star {
    width: 88px;
    height: 88px;
    filter: drop-shadow(0 0 18px rgba(232, 212, 139, 0.35));
    animation: pk-rotate-soft 6s linear infinite;
}

html.theme-pk-independence .pk-crescent-star .pk-stroke {
    fill: none;
    stroke: var(--pk-gold-soft);
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 320;
    stroke-dashoffset: 320;
    animation: pk-draw-stroke 2.4s ease forwards infinite;
}

html.theme-pk-independence .pk-crescent-star .pk-fill-soft {
    fill: rgba(255, 255, 255, 0.92);
    opacity: 0;
    animation: pk-fade-fill 2.4s ease forwards infinite;
}

@keyframes pk-draw-stroke {
    0% { stroke-dashoffset: 320; }
    45% { stroke-dashoffset: 0; }
    70%, 100% { stroke-dashoffset: 0; }
}

@keyframes pk-fade-fill {
    0%, 35% { opacity: 0; }
    55%, 85% { opacity: 1; }
    100% { opacity: 0.35; }
}

@keyframes pk-rotate-soft {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

html.theme-pk-independence .loading-progress-text,
html.theme-pk-independence .pk-boot-label {
    color: rgba(255, 255, 255, 0.92);
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-align: center;
}

html.theme-pk-independence .loading-progress-text:after {
    content: none;
}

html.theme-pk-independence .pk-boot-bar-track {
    width: min(280px, 70vw);
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.15);
    overflow: visible;
    position: relative;
}

html.theme-pk-independence .pk-boot-bar-fill {
    height: 100%;
    width: 0%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--pk-green-bright), var(--pk-gold));
    box-shadow: 0 0 12px rgba(201, 162, 39, 0.55);
    transition: width 0.2s ease;
    position: relative;
}

html.theme-pk-independence .pk-boot-bar-icon {
    position: absolute;
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
    width: 22px;
    height: 22px;
    font-size: 14px;
    line-height: 22px;
    text-align: center;
    transition: left 0.2s ease;
    filter: drop-shadow(0 0 6px rgba(232, 212, 139, 0.8));
    pointer-events: none;
}

html.theme-pk-independence .pk-boot-bar-icon.is-complete {
    animation: pk-sparkle 0.7s ease;
}

@keyframes pk-sparkle {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    40% { transform: translate(-50%, -50%) scale(1.35) rotate(12deg); }
    70% { transform: translate(-50%, -50%) scale(0.95); }
}

/* —— Fixed top loading bar (boot + soft nav) —— */
.pk-top-loader {
    display: none;
}

html.theme-pk-independence .pk-top-loader {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 100002;
    pointer-events: none;
    background: transparent;
    opacity: 0;
    transition: opacity 180ms ease;
}

html.theme-pk-independence .pk-top-loader.is-active {
    opacity: 1;
    background: rgba(1, 65, 28, 0.12);
}

html.theme-pk-independence .pk-top-loader-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #01411c, #1a8f55 55%, #c9a227);
    box-shadow: 0 0 10px rgba(26, 143, 85, 0.55);
    transition: width 160ms ease;
    position: relative;
}

html.theme-pk-independence .pk-top-loader-icon {
    position: absolute;
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    line-height: 1;
    color: var(--pk-gold);
    text-shadow: 0 0 8px rgba(201, 162, 39, 0.95);
    transition: left 160ms ease;
    filter: drop-shadow(0 0 4px rgba(1, 65, 28, 0.4));
}

html.theme-pk-independence .pk-top-loader-icon.is-complete {
    animation: pk-sparkle 0.55s ease;
}

html.theme-pk-independence .pk-top-loader.is-done .pk-top-loader-fill {
    background: linear-gradient(90deg, #1a8f55, #e8d48b);
}

/* —— Top scroll progress —— */
.pk-scroll-progress {
    display: none;
}

html.theme-pk-independence .pk-scroll-progress {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 100000;
    pointer-events: none;
    background: rgba(1, 65, 28, 0.08);
}

html.theme-pk-independence .pk-scroll-progress-fill {
    position: relative;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--pk-green-mid), var(--pk-gold));
    box-shadow: 0 0 8px rgba(201, 162, 39, 0.45);
    transition: width 60ms linear;
}

html.theme-pk-independence .pk-scroll-progress-fill::after {
    content: "☪";
    position: absolute;
    right: 0;
    top: 50%;
    transform: translate(50%, -50%);
    font-size: 11px;
    line-height: 1;
    color: var(--pk-gold);
    text-shadow: 0 0 6px rgba(201, 162, 39, 0.9);
    opacity: 0.95;
}

/* Hide scroll bar while top loader is showing to avoid double bars */
html.theme-pk-independence .pk-top-loader.is-active ~ #pk-scroll-progress,
html.theme-pk-independence body:has(.pk-top-loader.is-active) .pk-scroll-progress {
    opacity: 0;
}

/* —— Floating animated flag —— */
.pk-flag-float {
    display: none;
}

html.theme-pk-independence .pk-flag-float {
    display: flex;
    align-items: flex-end;
    gap: 0;
    position: fixed;
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 99990;
    pointer-events: none;
    transform-origin: bottom left;
    filter: drop-shadow(0 10px 18px rgba(1, 65, 28, 0.35));
}

html.theme-pk-independence .pk-flag-pole {
    width: 4px;
    height: 78px;
    border-radius: 3px;
    background: linear-gradient(180deg, #d4af37, #8a7020);
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.15);
}

html.theme-pk-independence .pk-flag-wave {
    width: 72px;
    height: 48px;
    margin-bottom: 28px;
    transform-origin: left center;
    animation: pk-flag-wave 2.4s ease-in-out infinite;
}

html.theme-pk-independence .pk-flag-svg {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 2px;
}

@keyframes pk-flag-wave {
    0%, 100% { transform: perspective(120px) rotateY(-8deg) skewY(0deg); }
    25% { transform: perspective(120px) rotateY(6deg) skewY(-1.5deg); }
    50% { transform: perspective(120px) rotateY(-4deg) skewY(1deg); }
    75% { transform: perspective(120px) rotateY(8deg) skewY(-1deg); }
}

@media (max-width: 640px) {
    html.theme-pk-independence .pk-flag-float {
        transform: scale(0.85);
        transform-origin: bottom right;
    }
}

/* —— Click sparks —— */
.pk-spark-layer {
    display: none;
}

html.theme-pk-independence .pk-spark-layer {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 100010;
    pointer-events: none;
    overflow: hidden;
}

html.theme-pk-independence .pk-spark-burst {
    position: absolute;
    width: 0;
    height: 0;
}

html.theme-pk-independence .pk-spark-core {
    position: absolute;
    left: 0;
    top: 0;
    width: 10px;
    height: 10px;
    margin: -5px 0 0 -5px;
    border-radius: 50%;
    background: radial-gradient(circle, #e8d48b 0%, #1a8f55 55%, transparent 70%);
    animation: pk-spark-core 480ms ease-out forwards;
}

html.theme-pk-independence .pk-spark-particle {
    position: absolute;
    left: 0;
    top: 0;
    width: 6px;
    height: 6px;
    margin: -3px 0 0 -3px;
    border-radius: 50%;
    background: #1a8f55;
    box-shadow: 0 0 8px rgba(26, 143, 85, 0.85);
    animation: pk-spark-fly 520ms ease-out forwards;
    animation-delay: var(--delay, 0ms);
}

html.theme-pk-independence .pk-spark-particle:nth-child(odd) {
    background: #c9a227;
    box-shadow: 0 0 8px rgba(201, 162, 39, 0.9);
    width: 4px;
    height: 4px;
    margin: -2px 0 0 -2px;
}

@keyframes pk-spark-core {
    0% { transform: scale(0.4); opacity: 1; }
    100% { transform: scale(2.4); opacity: 0; }
}

@keyframes pk-spark-fly {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}

/* —— Login page —— */
html.theme-pk-independence .auth-wrapper {
    background:
        radial-gradient(ellipse 70% 45% at 50% -10%, rgba(26, 143, 85, 0.22), transparent 55%),
        linear-gradient(145deg, #e8f2ec 0%, #d5e8dc 40%, #c5dccf 100%) !important;
}

html.theme-pk-independence .auth-wrapper::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 12% 88%, rgba(201, 162, 39, 0.14), transparent 28%),
        radial-gradient(circle at 90% 12%, rgba(1, 65, 28, 0.1), transparent 30%);
    z-index: 0;
}

html.theme-pk-independence .auth-card {
    position: relative;
    z-index: 1;
    border: 1px solid rgba(1, 65, 28, 0.12);
    box-shadow:
        0 18px 48px rgba(1, 65, 28, 0.12),
        0 0 0 1px rgba(201, 162, 39, 0.18) !important;
    overflow: hidden;
}

html.theme-pk-independence .auth-card::before {
    content: "";
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #01411c, #1a8f55 50%, #c9a227);
}

html.theme-pk-independence .auth-header::after {
    content: "Pakistan Independence Day · 14 August";
    display: block;
    margin-top: 0.75rem;
    color: #0a6b3c;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

html.theme-pk-independence .auth-wrapper .form-control:focus {
    border-color: #0a6b3c !important;
    box-shadow: 0 0 0 4px rgba(26, 143, 85, 0.15) !important;
}

html.theme-pk-independence .auth-wrapper .btn-login {
    background: linear-gradient(135deg, #01411c 0%, #1a8f55 100%) !important;
    box-shadow: 0 8px 18px rgba(1, 65, 28, 0.28);
}

html.theme-pk-independence .auth-wrapper .btn-login:hover:not(:disabled) {
    background: linear-gradient(135deg, #0a6b3c 0%, #22a35f 100%) !important;
}

html.theme-pk-independence .auth-footer p {
    color: #4a6b58 !important;
}

/* —— Apps Hub —— */
html.theme-pk-independence .hub-wrapper,
html.theme-pk-independence .hub-wrapper.maintix-apps-hub {
    --hub-orange: #c9a227;
    --hub-blue: #0a6b3c;
    --hub-cyan: #1a8f55;
    --hub-green: #0a6b3c;
    --hub-dark: #0a2e1c;
    --ex-blue: #0a6b3c;
    --ex-blue-deep: #01411c;
    --ex-cyan: #1a8f55;
    --ex-navy: #0a2e1c;
    background:
        radial-gradient(ellipse 60% 40% at 50% 0%, rgba(26, 143, 85, 0.16), transparent 55%),
        linear-gradient(180deg, rgba(243, 247, 244, 0.98), rgba(232, 242, 236, 0.98)),
        linear-gradient(120deg, rgba(1, 65, 28, 0.08), rgba(201, 162, 39, 0.1)) !important;
}

html.theme-pk-independence .hub-wrapper .portal-brand-logo {
    border-color: rgba(1, 65, 28, 0.16) !important;
    background: rgba(255, 255, 255, 0.9) !important;
    box-shadow: 0 18px 44px rgba(1, 65, 28, 0.12) !important;
}

html.theme-pk-independence .hub-header-copy .hub-eyebrow,
html.theme-pk-independence .hub-header-copy p {
    color: #0a6b3c !important;
}

html.theme-pk-independence .hub-header-copy .hub-title {
    color: #0a2e1c !important;
}

html.theme-pk-independence .hub-header-copy::after {
    content: "Celebrating 14 August";
    display: block;
    margin-top: 0.35rem;
    color: #c9a227;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

html.theme-pk-independence .hub-card {
    border-color: rgba(1, 65, 28, 0.14) !important;
    box-shadow: 0 18px 42px rgba(1, 65, 28, 0.1) !important;
}

html.theme-pk-independence .hub-card:hover,
html.theme-pk-independence .hub-card:focus-visible {
    border-color: rgba(26, 143, 85, 0.45) !important;
    box-shadow: 0 24px 58px rgba(1, 65, 28, 0.16) !important;
}

html.theme-pk-independence .hub-card.maintenance-card::before,
html.theme-pk-independence .hub-card.pem-card::before {
    background: linear-gradient(90deg, #01411c, #c9a227) !important;
}

html.theme-pk-independence .hub-card .hub-card-arrow {
    background: #0a6b3c !important;
    color: #ffffff !important;
}

html.theme-pk-independence .hub-card .pem-icon,
html.theme-pk-independence .hub-card .maintenance-icon {
    background: rgba(26, 143, 85, 0.12) !important;
    color: #0a6b3c !important;
}

html.theme-pk-independence .hub-card .hub-card-kicker {
    color: #0a6b3c !important;
}

html.theme-pk-independence .btn-logout:hover {
    border-color: rgba(26, 143, 85, 0.4) !important;
    color: #0a6b3c !important;
    background: rgba(26, 143, 85, 0.08) !important;
}

/* —— Shell / overall screens —— */
html.theme-pk-independence .maintix-bento-shell.portal-page {
    background:
        radial-gradient(ellipse 50% 30% at 100% 0%, rgba(201, 162, 39, 0.08), transparent 50%),
        var(--maintix-base);
}

html.theme-pk-independence .maintix-sidebar-glow {
    background: rgba(26, 143, 85, 0.42);
}

html.theme-pk-independence .maintix-sidebar-panel {
    background: linear-gradient(165deg, #062816 0%, #0a2e1c 55%, #161618 100%);
    border-color: rgba(201, 162, 39, 0.22);
}

html.theme-pk-independence .maintix-topbar {
    border-color: rgba(1, 65, 28, 0.1);
}

html.theme-pk-independence .maintix-bento-shell .portal-card,
html.theme-pk-independence .maintix-bento-shell .rz-card {
    border-color: rgba(1, 65, 28, 0.1);
}

html.theme-pk-independence .maintix-bento-shell .workflow-strip.maintix-workflow-stepper::before {
    background: linear-gradient(
        90deg,
        var(--pk-green-mid) 0,
        var(--pk-green-bright) var(--workflow-progress),
        #e8edf4 var(--workflow-progress),
        #e8edf4 100%
    );
}

html.theme-pk-independence .maintix-bento-shell .workflow-badge.complete {
    border-color: rgba(26, 143, 85, 0.55);
    background: rgba(26, 143, 85, 0.16);
    color: var(--pk-green-mid);
    box-shadow: 0 0 0 6px #ffffff, 0 0 0 7px rgba(26, 143, 85, 0.2);
}

html.theme-pk-independence .maintix-bento-shell .workflow-badge.current {
    border-color: rgba(201, 162, 39, 0.85);
    background: linear-gradient(135deg, #01411c 0%, #1a8f55 100%);
    color: #fff;
    box-shadow: 0 0 0 7px rgba(26, 143, 85, 0.16), 0 14px 26px rgba(1, 65, 28, 0.28);
}

html.theme-pk-independence .maintix-bento-shell .workflow-badge.current::after {
    border-color: rgba(201, 162, 39, 0.4);
}

html.theme-pk-independence .maintix-bento-shell .workflow-step.is-complete .workflow-step-label {
    color: var(--pk-green-mid);
}

html.theme-pk-independence .maintix-brand {
    flex-direction: column;
    gap: 0.45rem;
}

html.theme-pk-independence .maintix-brand::after {
    content: "14 August · Pakistan";
    display: block;
    width: min(160px, 100%);
    padding: 0.22rem 0.55rem;
    border-radius: 999px;
    border: 1px solid rgba(201, 162, 39, 0.45);
    background: linear-gradient(90deg, rgba(1, 65, 28, 0.9), rgba(201, 162, 39, 0.28));
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-align: center;
    text-transform: uppercase;
}

/* Leave Petty Cash module visuals alone */
html.theme-pk-independence .pc-module,
html.theme-pk-independence .pc-dashboard {
    --maintix-orange: #ed8030;
    --maintix-blue: #5393cb;
    --maintix-cyan: #2d9ad1;
    --maintix-green: #64af68;
    --maintix-active: linear-gradient(135deg, #5393cb 0%, #2d9ad1 100%);
}

@media (prefers-reduced-motion: reduce) {
    html.theme-pk-independence .pk-flag-wave,
    html.theme-pk-independence .pk-crescent-star,
    html.theme-pk-independence .pk-crescent-star .pk-stroke,
    html.theme-pk-independence .pk-crescent-star .pk-fill-soft {
        animation: none !important;
    }

    html.theme-pk-independence .pk-spark-particle,
    html.theme-pk-independence .pk-spark-core {
        animation-duration: 1ms !important;
    }
}
