* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #f8fafc;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --error-color: #ef4444;
    --success-color: #10b981;
    --shadow-light: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-medium: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-large: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --gradient-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --glass-bg: rgba(255, 255, 255, 0.25);
    --glass-border: rgba(255, 255, 255, 0.18);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gradient-bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(120, 219, 255, 0.2) 0%, transparent 50%);
    pointer-events: none;
}

.container {
    width: 100%;
    max-width: 400px;
    position: relative;
    z-index: 1;
}

.login-wrapper {
    perspective: 1000px;
}

.login-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 40px;
    box-shadow: var(--shadow-large);
    transform-style: preserve-3d;
    transition: transform 0.6s ease;
    position: relative;
    overflow: hidden;
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
    opacity: 0.8;
}

.login-card:hover {
    transform: rotateY(2deg) rotateX(2deg);
}

.card-header {
    text-align: center;
    margin-bottom: 32px;
}

.logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 8px;
}

.logo-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-radius: 16px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-medium);
}

.logo-icon::before {
    content: '';
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 6px;
    transform: rotate(45deg);
}

.logo h2 {
    color: white;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.subtitle {
    color: rgba(255, 255, 255, 0.8);
    font-size: 16px;
    font-weight: 400;
}

.form-group {
    margin-bottom: 24px;
}

.input-wrapper {
    position: relative;
}

.input-wrapper input {
    width: 100%;
    padding: 16px 50px 16px 16px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    color: white;
    font-size: 16px;
    transition: all 0.3s ease;
    outline: none;
}

.input-wrapper input:focus {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.3);
}

.input-wrapper input:valid {
    border-color: var(--success-color);
}

.input-wrapper label {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
    pointer-events: none;
    transition: all 0.3s ease;
    background: transparent;
    padding: 0 4px;
}

/* Nổi nhãn: khi đang focus trong ô, khi đã có chữ (has-value), hoặc khi input hợp lệ */
.input-wrapper:focus-within label,
.input-wrapper.has-value label,
.input-wrapper input:valid + label {
    top: 0;
    font-size: 12px;
    color: var(--primary-color);
    background: rgba(255, 255, 255, 0.9);
    border-radius: 4px;
    font-weight: 500;
    transform: translateY(0);
}

.input-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: rgba(255, 255, 255, 0.6);
}

.input-icon svg {
    width: 100%;
    height: 100%;
    stroke-width: 2;
}

.toggle-password {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    width: 20px;
    height: 20px;
    padding: 0;
    transition: color 0.3s ease;
}

.toggle-password:hover {
    color: white;
}

.toggle-password svg {
    width: 100%;
    height: 100%;
    stroke-width: 2;
}

.toggle-password .eye-closed {
    display: none;
}

.toggle-password.active .eye-open {
    display: none;
}

.toggle-password.active .eye-closed {
    display: block;
}

.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    font-size: 14px;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    user-select: none;
}

.checkbox-wrapper input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    position: relative;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.1);
}

.checkbox-wrapper input[type="checkbox"]:checked + .checkmark {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.checkbox-wrapper input[type="checkbox"]:checked + .checkmark::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.forgot-password {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: color 0.3s ease;
}

.forgot-password:hover {
    color: var(--primary-color);
}

.login-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    margin-bottom: 24px;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

.login-btn:active {
    transform: translateY(0);
}

.login-btn.loading {
    pointer-events: none;
}

.btn-text {
    transition: opacity 0.3s ease;
}

.btn-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.login-btn.loading .btn-text {
    opacity: 0;
}

.login-btn.loading .btn-loader {
    opacity: 1;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.divider {
    text-align: center;
    margin: 24px 0;
    position: relative;
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
}

.divider span {
    background: var(--glass-bg);
    padding: 0 16px;
    position: relative;
    z-index: 1;
}

.social-login {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.social-btn {
    flex: 1;
    padding: 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.social-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.social-btn svg {
    width: 18px;
    height: 18px;
}

.signup-link {
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
}

.signup-link a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

.signup-link a:hover {
    color: white;
}

/* Responsive Design */
@media (max-width: 480px) {
    .container {
        max-width: 100%;
        padding: 0 16px;
    }
    
    .login-card {
        padding: 24px;
        border-radius: 16px;
    }
    
    .logo h2 {
        font-size: 24px;
    }
    
    .social-login {
        flex-direction: column;
    }
}

/* Animation for card entrance */
@keyframes cardEntrance {
    0% {
        opacity: 0;
        transform: translateY(30px) rotateX(10deg);
    }
    100% {
        opacity: 1;
        transform: translateY(0) rotateX(0);
    }
}

.login-card {
    animation: cardEntrance 0.8s ease-out;
}

/* Floating particles animation */
.container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: 
        radial-gradient(circle, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: float 20s linear infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes float {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(-50px, -50px) rotate(360deg); }
}
/* Satellite Gen: tránh chồng icon khóa và nút mắt */
.input-wrapper .input-icon-lock { right: 44px; }
.social-btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* Header + footer cố định (trang / khi bật auth = luôn thấy) */
body.login-page {
    padding: calc(52px + max(16px, env(safe-area-inset-top))) 16px calc(52px + max(16px, env(safe-area-inset-bottom)));
    min-height: 100vh;
    min-height: 100dvh;
}

.login-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px 10px;
    min-height: 48px;
    padding: 10px 14px;
    padding-top: max(10px, env(safe-area-inset-top));
    background: rgba(15, 23, 42, 0.78);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    font-size: 13px;
    color: rgba(255, 255, 255, 0.92);
}

.login-topbar-brand {
    color: #e0e7ff;
    font-weight: 700;
    text-decoration: none;
}

.login-topbar-brand:hover {
    text-decoration: underline;
}

.login-topbar-sep {
    opacity: 0.5;
}

.login-topbar-title {
    font-weight: 600;
}

.login-topbar-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.22);
}

.login-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px 8px;
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    font-size: 12px;
    color: rgba(255, 255, 255, 0.78);
    background: rgba(15, 23, 42, 0.88);
    border-top: 1px solid rgba(99, 102, 241, 0.28);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.login-footer-sep {
    opacity: 0.45;
}
