﻿/* Background mặc định (Light mode) */
body {
    margin: 0;
    font-family: sans-serif;
    background: url('/assets/back-light.png') no-repeat center center fixed;
    background-size: 100%;
    background-position: center 50%;
    transition: all 0.4s ease;
}

    /* Dark mode */
    body.dark {
        background: url('/assets/back-night.png') no-repeat center center fixed;
        background-size: 100%;
        background-position: center 50%;
        transition: all 0.4s ease;
    }

/* Card glass effect */
#loginCard {
    backdrop-filter: blur(10px) saturate(200%);
    -webkit-backdrop-filter: blur(10px) saturate(200%);
    background: rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(0, 0, 0, 0.1);
    transition: background 0.4s ease, color 0.4s ease;
}

/* Dark mode card */
body.dark #loginCard {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

/* Label animation fix */
input:focus ~ label,
input:valid ~ label {
    top: -1rem;
    font-size: 0.75rem;
}

/* Tiêu đề */
#loginCard h2 {
    font-size: 2rem;
    transition: color 0.4s ease;
}

/* Dark mode text */
body.dark #loginCard h2,
body.dark #loginCard label,
body.dark #loginCard span svg {
    color: white;
    stroke: white;
}

/* Light mode text */
body:not(.dark) #loginCard h2,
body:not(.dark) #loginCard label,
body:not(.dark) #loginCard span svg {
    color: black;
    stroke: black;
}

#login-btn {
    padding: 0.75rem;
    font-size: 1.125rem;
}

input.not-empty ~ label {
    top: -1rem;
    font-size: 0.75rem;
    color: #a5f3fc;
}

/* Autofill fix */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0px 1000px rgba(255,255,255,0) inset !important;
    box-shadow: 0 0 0px 1000px rgba(255,255,255,0) inset !important;
    -webkit-text-fill-color: inherit !important;
    caret-color: inherit;
    background-clip: text !important;
    transition: background-color 9999s ease-in-out 0s !important;
}

/* Ẩn default checkbox */
input[type="checkbox"].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;
}

/* Nút gạt mượt hơn */
#theme-toggle + div {
    transition: background-color 0.3s ease;
}

#theme-toggle:checked + div + div {
    transform: translateX(6px);
}

/* Nút gradient động */
.gradient-btn {
    background-size: 200% 200%;
    background-image: linear-gradient(90deg, #007BFF, #00FFFF, #007BFF);
    animation: gradient-move 4s ease infinite;
    border: none;
    color: white;
    position: relative;
    overflow: hidden;
    transition: transform 0.25s ease, filter 0.25s ease, background-color 0.4s ease, color 0.4s ease;
}

    .gradient-btn:hover {
        filter: brightness(1.15);
        transform: scale(1.05);
    }

@keyframes gradient-move {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* Loading spinner */
.btn-loading {
    pointer-events: none;
    background: linear-gradient(90deg, #00aaff, #00e6e6);
    animation: gradient-move 1.5s ease infinite; /* giữ nhịp */
}

    .btn-loading::after {
        content: "";
        position: absolute;
        right: 16px;
        width: 20px;
        height: 20px;
        border: 3px solid white;
        border-top-color: transparent;
        border-radius: 50%;
        animation: spin 0.6s linear infinite;
    }

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Thành công */
.btn-success {
    background: #22c55e !important;
    animation: none; /* dừng gradient */
}

    .btn-success::after {
        content: "✔";
        font-size: 1.2rem;
        margin-left: 8px;
        opacity: 0;
        animation: fadeIn 0.4s forwards;
    }

/* Thất bại */
.btn-fail {
    background: #ef4444 !important;
    animation: shake 0.4s ease, none;
}

    .btn-fail::after {
        content: "✖";
        font-size: 1.2rem;
        margin-left: 8px;
        opacity: 0;
        animation: fadeIn 0.4s forwards;
    }

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }

    20%, 60% {
        transform: translateX(-6px);
    }

    40%, 80% {
        transform: translateX(6px);
    }
}

/* Fade chữ & icon */
.gradient-btn span,
.gradient-btn::after {
    transition: opacity 0.4s ease;
}

.btn-success span,
.btn-fail span {
    opacity: 1;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}
