﻿:root {
    --primary-blue: #00a8ff;
    --glass-bg: rgba(255, 255, 255, 0.06);
    --glass-border: rgba(255, 255, 255, 0.14);
    --glass-rim: rgba(255,255,255,0.06);
    /* POS themed palette */
    /* slightly brighter POS palette for page background */
    --c1: #283650; /* deep - slightly lighter */
    --c2: #2e4168; /* mid  - slightly lighter */
    --c3: #2b3f72; /* accent */
    --c4: #4f6fbf; /* highlight */
}

/* Import modern display font for logo */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@700;800&family=Inter:wght@300;400&display=swap');

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* Light theme variables (default: dark theme currently). We'll toggle .light-mode on body */
:root.light-mode {
    --primary-blue: #007bff;
    --glass-bg: rgba(255,255,255,0.85);
    --glass-border: rgba(0,0,0,0.06);
    --glass-rim: rgba(0,0,0,0.08);
    --text-color: #1f2a44;
    --muted-color: rgba(31,42,68,0.6);
}

/* Default variables for dark mode already set in :root above */

/* Improve mobile Safari behavior */
html, body { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }

/* sensible box-sizing across layout to avoid overflow calculations */
*, *::before, *::after { box-sizing: border-box; }

/* prevent horizontal scrollbar from subtle background or large elements */
html, body { overflow-x: hidden; }

.main-wrapper {
    /* Point-of-sale conic-gradient hero background (no external image) */
    /* fallback for older browsers (linear gradient) */
    /* lighter background similar to Bootstrap's light page background */
    background-color: #f8f9fa; /* bootstrap light */
    background: linear-gradient(180deg, #f8f9fa, #eef2f7);

    /* layered conic gradients for modern browsers */
    background-image: 
        conic-gradient(from 20deg at 15% 20%, var(--c1), var(--c2) 35%, var(--c1) 70%, var(--c1)),
        conic-gradient(from -40deg at 85% 25%, var(--c2), var(--c3) 30%, var(--c2) 65%, var(--c2)),
        conic-gradient(from 90deg at 30% 80%, var(--c3), var(--c4) 40%, var(--c3) 75%, var(--c3)),
        conic-gradient(from 200deg at 80% 75%, var(--c1), var(--c2) 45%, var(--c1) 85%, var(--c1));
    background-blend-mode: hard-light;
    background-size: cover;
    background-position: center;
    /* Support iOS viewport quirks: prefer dynamic viewport units where available */
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.glass-card {
    /* more transparent purple-tinted glass (brand #5a1978) */
    background: linear-gradient(
        180deg,
        rgba(90, 25, 120, 0.14),
        rgba(255, 255, 255, 0.06)
    );
    backdrop-filter: blur(24px) saturate(170%);
    -webkit-backdrop-filter: blur(24px) saturate(170%);
    /* remove hard border for a cleaner glass look; rim and highlights are handled by box-shadow and ::before/::after */
    border: none;
    border-radius: 20px;
    padding: 50px 40px;
    width: 400px;
    max-width: 92%;
    margin: 0 auto;
    /* ensure the card never forces the page to scroll horizontally and fits vertically */
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overflow-x: hidden; /* prevent horizontal scrollbar from sparkle animation */
    -webkit-overflow-scrolling: touch;
    /* reserve space for scrollbar to avoid layout shift when it appears */
    scrollbar-gutter: stable both-edges;
    box-shadow:
        0 18px 48px rgba(17, 24, 39, 0.28),
        0 0 28px rgba(90, 25, 120, 0.12),
        inset 0 1px 0 rgba(255,255,255,0.14);
    text-align: center;
}

/* Glossy glass effect: add layered highlights, rim and soft inner shadows */
.glass-card {
    position: relative;
    isolation: isolate; /* ensure internal z-index ordering works as expected */
    /* slightly stronger blur for modern glass feel (kept in addition to the base backdrop above) */
    backdrop-filter: blur(22px) saturate(140%);
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    /* subtle outer rim + faint shadow to lift the card and a soft halo glow */
    box-shadow: 0 6px 30px rgba(4,12,30,0.6), 0 0 30px rgba(79,111,191,0.045), inset 0 1px 0 rgba(255,255,255,0.02);
    /* calmer, professional look */
    animation: none;
}

/* When light mode is active, tone down the rim/halo so border doesn't look heavier at the bottom */
.light-mode .glass-card {
    border: none; /* remove bottom border/line in light mode */
    /* softer shadow in light mode to avoid heavy bottom line */
    box-shadow: 0 6px 18px rgba(20,30,40,0.06), inset 0 1px 0 rgba(255,255,255,0.02);
    animation: none; /* stop flashing in light mode for a calmer look */
}

@keyframes borderFlash {
    0% {
        box-shadow: 0 6px 30px rgba(4,12,30,0.6), 0 0 6px rgba(79,111,191,0.02), inset 0 1px 0 rgba(255,255,255,0.02);
    }
    50% {
        box-shadow: 0 10px 40px rgba(4,12,30,0.65), 0 0 46px rgba(79,111,191,0.12), inset 0 1px 0 rgba(255,255,255,0.04);
    }
    100% {
        box-shadow: 0 6px 30px rgba(4,12,30,0.6), 0 0 6px rgba(79,111,191,0.02), inset 0 1px 0 rgba(255,255,255,0.02);
    }
}

@media (prefers-reduced-motion: reduce) {
    .glass-card { animation: none; }
}

/* Sparkle layer across the glass card but keep clear of the scrollbar area */
.glass-card .card-sparkle {
    position: absolute;
    left: 8px;
    right: 22px; /* leave room for scrollbar/thumb */
    top: 0;
    bottom: 0;
    pointer-events: none;
    background: linear-gradient(120deg, rgba(255,255,255,0.02) 0%, rgba(255,255,255,0.06) 30%, rgba(255,255,255,0.02) 60%, rgba(255,255,255,0.01) 100%);
    mix-blend-mode: screen;
    opacity: 0.65;
    filter: blur(18px);
    transform: translateX(-40%);
    animation: cardSparkle 6s linear infinite;
    z-index: 0; /* behind content */
}

/* ensure card content sits above sparkle */
.glass-card > *:not(.card-sparkle) { position: relative; z-index: 10; }

/* Scrollbar styling for WebKit */
.glass-card::-webkit-scrollbar { width: 12px; }
.glass-card::-webkit-scrollbar-track { background: rgba(255,255,255,0.02); border-radius: 8px; }
.glass-card::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 8px; border: 3px solid transparent; background-clip: padding-box; }
.glass-card:hover::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); }

/* Firefox scrollbar colors */
.glass-card { scrollbar-color: rgba(255,255,255,0.12) rgba(255,255,255,0.02); }

.glass-card::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    /* transparent glass highlight with subtle purple vignette */
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.16),
        inset 0 -18px 40px rgba(90, 25, 120, 0.14);
    background: linear-gradient(
        180deg,
        rgba(255,255,255,0.10),
        rgba(255,255,255,0.04) 35%,
        rgba(90, 25, 120, 0.06) 70%
    );
    mix-blend-mode: overlay;
    opacity: 0.95;
}

.glass-card::after {
    content: "";
    position: absolute;
    left: 8%;
    right: 8%;
    top: 4px;
    height: 34%;
    border-radius: 50%;
    pointer-events: none;
    /* specular sheen: brighter, narrower and slightly angled */
    background: linear-gradient(180deg, rgba(255,255,255,0.28), rgba(255,255,255,0.05));
    transform: translateY(-46%) rotate(-2deg);
    filter: blur(14px);
    opacity: 0.9;
}

/* subtle rim highlight along top-left edge */
.glass-card::marker { }

/* optional extra tiny rim using pseudo-element to add crisp edge */
.glass-card .rim-edge {
    position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.02) inset;
}

/* Slight lift on hover for desktop */
.glass-card:hover {
    box-shadow:
        0 18px 52px rgba(17, 24, 39, 0.30),
        0 0 32px rgba(90, 25, 120, 0.14),
        inset 0 1px 0 rgba(255,255,255,0.14);
    transform: none;
    transition: box-shadow 220ms ease;
}

.logo-area h1 {
    color: var(--text-color, white);
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
    letter-spacing: 0.14em;
    margin: 0;
    text-transform: uppercase;
    background: linear-gradient(90deg, var(--primary-blue), #9be0ff 60%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 6px 18px rgba(0,0,0,0.28));
}

/* In light mode make the logo more subtle (no bright gradient or heavy shadow) */
.light-mode .logo-area h1 {
    /* use solid text color instead of gradient fill */
    background: none !important;
    -webkit-background-clip: initial;
    background-clip: initial;
    color: var(--text-color, #1f2a44) !important;
    -webkit-text-fill-color: var(--text-color, #1f2a44) !important;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.06));
    letter-spacing: 0.06em;
}

/* soften subtitle in light mode */
.light-mode .subtitle { color: rgba(31,42,68,0.65); }

    .logo-area h1 span {
        color: var(--primary-blue);
    }

.subtitle {
    color: var(--muted-color, rgba(255, 255, 255, 0.7));
    /* smaller subtitle for a more compact professional look */
    font-size: clamp(0.5rem, 1.2vw, 0.65rem);
    letter-spacing: 2px;
    margin-bottom: 28px;
    text-transform: lowercase;
}

/* Logo area: constrain both heading and subtitle to the same block width for a polished look */
.logo-area {
    display: inline-block;
    max-width: 340px; /* adjust to taste */
    width: 100%;
    text-align: center;
}
.logo-area h1, .logo-area .subtitle {
    width: 100%;
    box-sizing: border-box;
}
.logo-area h1 span { letter-spacing: 0.02em; }

/* Decorative subtle line with moving sparkle behind the subtitle */
.logo-area { position: relative; }
.logo-area .subtitle {
    position: relative;
    display: inline-block;
    z-index: 3; /* above the base line */
    padding: 0 10px; /* small cushions so text sits over the line */
    background: transparent;
}
.logo-area .subtitle::after {
    /* small sparkle that moves only across the subtitle text area */
    content: "";
    position: absolute;
    left: -10%;
    top: 50%;
    width: 30%;
    height: 10px;
    transform: translateY(-50%);
    border-radius: 50%;
    background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.5) 30%, rgba(255,255,255,0.12) 50%, transparent 60%);
    filter: blur(6px);
    opacity: 0.9;
    z-index: 4;
    pointer-events: none;
    animation: sparkleMove 2.6s linear infinite;
}

@keyframes sparkleMove {
    0% { left: -10%; opacity: 0; transform: translateY(-50%) scale(0.85); }
    10% { opacity: 0.85; }
    50% { left: 110%; opacity: 0.95; transform: translateY(-50%) scale(1.0); }
    90% { opacity: 0.25; }
    100% { left: 110%; opacity: 0; transform: translateY(-50%) scale(1.1); }
}

@media (prefers-reduced-motion: reduce) {
    .logo-area .subtitle::after { animation-play-state: paused; opacity: 0.6; }
}

.form-group {
    position: relative;
    margin-bottom: 20px;
}

    .form-group .input-icon {
        position: absolute;
        left: 12px;
        top: 50%;
        transform: translateY(-50%);
        width: 18px;
        height: 18px;
        /* use primary accent color for icons to make them stand out */
        color: var(--primary-blue);
        fill: currentColor;
        stroke: currentColor; /* ensure stroked SVGs pick up color */
        filter: drop-shadow(0 1px 0 rgba(0,0,0,0.45));
        z-index: 30; /* ensure icon sits above sparkle layer */
        pointer-events: none;
    }

    .form-group input {
        width: 100%;
        padding: 14px 15px 14px 42px;
        border-radius: 8px;
        border: none;
        outline: none;
        font-size: 1rem;
        /* prevent iOS from auto-zooming inputs (keep >=16px) */
        font-size: 16px;
        box-sizing: border-box;
    }

/* Password toggle button */
.password-wrapper { position: relative; }
.password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent; /* no visible button background */
    border: none;
    color: inherit;
    width: 36px;
    height: 36px;
    padding: 4px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 120ms ease;
    z-index: 30; /* above sparkle */
}
.password-toggle:active { transform: translateY(-50%) scale(0.98); }
.password-toggle .icon-eye { width: 20px; height: 20px; display: inline-block; stroke: currentColor; fill: none; }

/* dark mode: make eye icon use accent color instead of white */
.dark-mode .password-toggle .icon-eye,
:root:not(.light-mode) .password-toggle .icon-eye {
    color: var(--primary-blue);
    stroke: currentColor;
}
.password-toggle[aria-pressed="true"] { background: rgba(255,255,255,0.12); }

/* Ensure icon inherits button color and is visible in both themes */
.password-toggle .icon-eye { color: inherit; }

/* Light mode: make toggle darker background and use primary-blue for icon */
.light-mode .password-toggle { color: var(--primary-blue); }
.light-mode .password-toggle[aria-pressed="true"] { opacity: 0.9; }

/* Accessibility focus state */
.password-toggle:focus {
    outline: 3px solid rgba(0,168,255,0.16);
    outline-offset: 2px;
}

.login-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
}

.btn-login {
    background: #007cc0;
    color: white;
    border: none;
    padding: 12px 35px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

    .btn-login:hover {
        background: var(--primary-blue);
        box-shadow: 0 0 15px rgba(0, 168, 255, 0.4);
    }

/* Modern inline alert styling (warning) */
.modern-alert {
    background: linear-gradient(90deg, rgba(255,243,205,0.95), rgba(255,249,230,0.95));
    border: 1px solid rgba(255,193,7,0.2);
    color: #856404;
    padding: 10px 14px;
    border-radius: 8px;
}
.modern-alert .alert-icon { margin-right: 10px; flex: 0 0 24px; }
.modern-alert .alert-content { font-weight: 600; }

/* Modern alert interactions */
.modern-alert { display: flex; align-items: center; gap: 12px; position: relative; overflow: hidden; }
.modern-alert-close {
    position: absolute; right: 8px; top: 6px; background: transparent; border: none; color: rgba(0,0,0,0.6);
    font-size: 20px; line-height: 1; padding: 6px 8px; cursor: pointer; border-radius: 6px;
}
.modern-alert-close:hover { background: rgba(0,0,0,0.03); }

/* subtle entrance animation */
.modern-alert { animation: slideIn 360ms cubic-bezier(.2,.8,.2,1); }
@keyframes slideIn { from { transform: translateY(-8px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }

/* auto dismiss fade-out helper class */
.modern-alert.fade-out { animation: fadeOut 360ms forwards; }
@keyframes fadeOut { to { opacity: 0; transform: translateY(-6px); height: 0; margin: 0; padding: 0 } }

/* theme toggle button placement and style */
.theme-toggle {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 9999;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
    cursor: pointer;
}
.theme-toggle:hover { transform: translateY(-2px); }

/* light mode style for toggle */
:root.light-mode .theme-toggle { background: rgba(255,255,255,0.9); color: #1f2a44; box-shadow: 0 6px 20px rgba(20,30,40,0.08); }

/* Center login buttons inside forms/cards */
.card-login .d-grid { display: flex !important; justify-content: center; }
.card-login .d-grid .btn-login, .glass-card .login-footer .btn-login {
    display: inline-block;
    margin: 0 auto;
    min-width: 160px;
}

.info-text {
    text-align: left;
    color: white;
    font-size: 0.7rem;
    line-height: 1.5;
    opacity: 0.8;
}

.malaysia-badge {
    margin-top: 50px;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    letter-spacing: 1px;
}

/* Responsive rules */
@media (max-width: 991px) {
    .main-wrapper {
        padding: 30px 16px;
        background-position: center top;
    }

    .glass-card {
        width: 520px;
        max-width: 92%;
        padding: 36px 28px;
        border-radius: 16px;
    }

    .logo-area h1 {
        font-size: 2.2rem;
        letter-spacing: 4px;
    }

    .subtitle {
        font-size: 0.62rem;
        margin-bottom: 28px;
    }

    .form-group input {
        padding: 12px 14px 12px 44px;
        font-size: 0.95rem;
    }

    .btn-login {
        padding: 10px 28px;
    }
}

@media (max-width: 575px) {
    .main-wrapper {
        /* center the card on small screens both vertically and horizontally */
        align-items: center;
        justify-content: center;
        padding-top: 0;
        background-position: center 20%;
    }

    .glass-card {
        width: min(420px, 92%);
        max-width: 420px;
        margin: 0 auto;
        padding: 28px 18px;
        border-radius: 12px;
        box-shadow: 0 6px 20px rgba(0,0,0,0.6);
    }

    .logo-area h1 {
        font-size: 1.8rem;
        letter-spacing: 3px;
    }

    .subtitle {
        font-size: 0.6rem;
        margin-bottom: 18px;
    }

    .form-group i { left: 12px; }

    .form-group input { padding-left: 42px; }

    .btn-login { width: 100%; padding: 12px; }

    .login-footer { flex-direction: column; gap: 12px; align-items: stretch; }

    .malaysia-badge { justify-content: center; margin-top: 20px; }
}

/* Large screens - center content with more breathing room */
@media (min-width: 1200px) {
    .main-wrapper { padding: 40px; }
    .glass-card { width: 480px; padding: 56px 48px; }
    .logo-area h1 { font-size: 3rem; }
}

/* Accessibility: increase contrast slightly when prefers-reduced-transparency */
@media (prefers-reduced-transparency: reduce) {
    .glass-card { background: rgba(0,0,0,0.55); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
