:root {
    --login-primary: #2563eb;
    --login-primary-hover: #1d4ed8;
    --login-primary-light: #dbeafe;
    --login-text: #1f2937;
    --login-text-secondary: #6b7280;
    --login-text-muted: #9ca3af;
    --login-border: #e5e7eb;
    --login-border-focus: #2563eb;
    --login-bg: #f9fafb;
    --login-white: #ffffff;
    --login-error: #ef4444;
}

* {
    box-sizing: border-box;
}

.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    background-color: #e8ecf4;
    padding: 20px 0;
}

.login-background {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-image: url('../images/login-bg.png');
    z-index: 0;
    transition: opacity 0.5s ease;
}

.login-background:not([style*="background-image"]) {
    /* Keep default background-image if not overridden by JS */
}

/* Centered narrow login card */
.login-wrapper {
    position: relative;
    z-index: 10;
    width: min(420px, 90vw);
    max-width: 420px;
    margin: 40px 20px;
    background: var(--login-white);
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(30, 58, 95, 0.22), 0 8px 24px rgba(0, 0, 0, 0.08);
    overflow: visible;
}

/* 3D cat sticker attached to top-left corner of the card */
.login-cat {
    position: absolute;
    top: -90px;
    left: -48px;
    width: 140px;
    height: auto;
    z-index: 20;
    filter: drop-shadow(0 12px 20px rgba(0, 0, 0, 0.25));
    pointer-events: none;
    user-select: none;
    animation: catBob 3.5s ease-in-out infinite;
}

@keyframes catBob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* Decorative gradient accent at top of card */
.login-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    border-radius: 16px 16px 0 0;
    z-index: -1;
}

.login-panel {
    padding: 88px 40px 32px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-panel-header {
    margin-bottom: 28px;
    text-align: center;
}

.login-panel-header h2 {
    font-size: clamp(20px, 4vw, 26px);
    font-weight: 700;
    color: var(--login-text);
    margin: 0 0 8px 0;
    letter-spacing: 0.5px;
}

.login-panel-header p {
    font-size: clamp(12px, 2.5vw, 13px);
    color: var(--login-text-secondary);
    margin: 0;
}

.login-form .form-group {
    margin-bottom: 18px;
}

.login-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--login-text);
    font-size: 14px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 14px;
    width: 18px;
    height: 18px;
    color: var(--login-text-muted);
    pointer-events: none;
}

.login-form input {
    width: 100%;
    padding: 12px 40px 12px 42px;
    border: 1px solid var(--login-border);
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: var(--login-bg);
    color: var(--login-text);
    font-family: inherit;
}

.login-form input:hover {
    border-color: var(--login-text-muted);
}

.login-form input:focus {
    outline: none;
    border-color: var(--login-border-focus);
    background: var(--login-white);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.login-form input::placeholder {
    color: var(--login-text-muted);
}

.login-form input:focus + .input-icon,
.input-wrapper:focus-within .input-icon {
    color: var(--login-primary);
}

.toggle-password {
    position: absolute;
    right: 14px;
    cursor: pointer;
    color: var(--login-text-muted);
    display: flex;
    align-items: center;
    transition: color 0.2s;
    user-select: none;
}

.toggle-password:hover {
    color: var(--login-text-secondary);
}

.toggle-password:hover svg {
    stroke: var(--login-text-secondary);
}

.btn-login {
    width: 100%;
    padding: 13px 20px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    color: white;
    font-family: inherit;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

.btn-login:hover:not(:disabled) {
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

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

.btn-login:disabled {
    background: var(--login-text-muted);
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-login .btn-icon {
    width: 18px;
    height: 18px;
    transition: transform 0.2s;
}

.btn-login:hover:not(:disabled) .btn-icon {
    transform: translateX(4px);
}

.login-panel-footer {
    text-align: center;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--login-border);
}

.login-panel-footer p {
    margin: 0;
    font-size: 12px;
    color: var(--login-text-muted);
}

.notification {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 9999;
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.notification.error {
    background: var(--login-error);
}

.notification.info {
    background: var(--login-primary);
}

.notification.success {
    background: #10b981;
}

/* ========== Responsive Breakpoints ========== */

/* Large tablets and small laptops */
@media (max-width: 1024px) {
    .login-wrapper {
        width: min(400px, 85vw);
        margin: 30px 20px;
    }

    .login-cat {
        width: 130px;
        top: -82px;
        left: -42px;
    }

    .login-panel {
        padding: 80px 36px 28px;
    }
}

/* Tablets and large phones */
@media (max-width: 768px) {
    .login-wrapper {
        width: min(380px, 88vw);
        margin: 80px 20px 20px;
    }

    .login-cat {
        top: -72px;
        left: 50%;
        transform: translateX(-50%);
        width: 120px;
    }

    .login-panel {
        padding: 72px 28px 24px;
    }

    .login-panel-header {
        margin-bottom: 24px;
    }

    .login-panel-header h2 {
        font-size: clamp(18px, 5vw, 22px);
    }

    .login-form .form-group {
        margin-bottom: 16px;
    }

    .btn-login {
        padding: 12px 18px;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .login-wrapper {
        width: min(340px, 92vw);
        margin: 70px 16px 20px;
        border-radius: 14px;
    }

    .login-cat {
        width: 100px;
        top: -58px;
    }

    .login-wrapper::before {
        height: 48px;
    }

    .login-panel {
        padding: 64px 22px 20px;
    }

    .login-panel-header {
        margin-bottom: 20px;
    }

    .login-panel-header h2 {
        font-size: 20px;
    }

    .login-panel-header p {
        font-size: 12px;
    }

    .login-form input {
        padding: 11px 36px 11px 38px;
        font-size: 13px;
    }

    .input-icon {
        left: 12px;
        width: 16px;
        height: 16px;
    }

    .btn-login {
        padding: 12px 16px;
        font-size: 14px;
    }

    .login-panel-footer {
        margin-top: 20px;
        padding-top: 16px;
    }
}

/* Very small phones */
@media (max-width: 360px) {
    .login-wrapper {
        width: calc(100vw - 24px);
        margin: 60px 12px 16px;
    }

    .login-cat {
        width: 90px;
        top: -52px;
    }

    .login-panel {
        padding: 58px 18px 16px;
    }
}

/* Landscape mode on phones */
@media (max-height: 500px) and (orientation: landscape) {
    .login-wrapper {
        margin: 10px auto;
    }

    .login-cat {
        width: 80px;
        top: -44px;
    }

    .login-panel {
        padding: 52px 24px 16px;
    }

    .login-panel-header {
        margin-bottom: 16px;
    }

    .login-panel-header h2 {
        font-size: 18px;
    }
}

/* High DPI / Retina optimization */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .login-cat {
        filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.2));
    }
}
