@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ============================================
   LOGIN PAGE - MODERN REDESIGN
   ============================================ */

:root {
    --primary: #1e3a5f;
    --primary-light: #2d5a8e;
    --accent: #0ea5e9;
    --accent-light: #38bdf8;
    --bg-gradient-start: #0f172a;
    --bg-gradient-end: #1e3a5f;
    --card-bg: #ffffff;
    --input-bg: #f8fafc;
    --input-border: #e2e8f0;
    --input-focus: #0ea5e9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --error: #ef4444;
    --error-bg: #fef2f2;
    --success: #22c55e;
    --success-bg: #f0fdf4;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
    --radius: 12px;
    --radius-lg: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body.login-page-modern {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    min-height: 100vh;
    background: var(--bg-gradient-start);
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Background --- */
.login-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 50%, #0c4a6e 100%);
    overflow: hidden;
}

.login-bg::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(14,165,233,0.15) 0%, transparent 70%);
    top: -200px;
    right: -100px;
    animation: float 20s ease-in-out infinite;
}

.login-bg::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(14,165,233,0.1) 0%, transparent 70%);
    bottom: -100px;
    left: -100px;
    animation: float 15s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.05); }
    66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* --- Grid Pattern Overlay --- */
.login-bg-pattern {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 40px 40px;
}

/* --- Main Container --- */
.login-container {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* --- Card --- */
.login-card-modern {
    width: 100%;
    max-width: 960px;
    display: flex;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.4);
    animation: cardEntrance 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes cardEntrance {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* --- Left Branding Panel --- */
.login-brand-panel {
    flex: 0 0 42%;
    background: linear-gradient(160deg, var(--primary) 0%, #0c4a6e 100%);
    padding: 48px 36px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.login-brand-panel::before {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: rgba(14,165,233,0.08);
    top: -80px;
    right: -80px;
}

.login-brand-panel::after {
    content: '';
    position: absolute;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: rgba(14,165,233,0.06);
    bottom: -50px;
    left: -50px;
}

.brand-content {
    position: relative;
    z-index: 1;
}

.brand-logo {
    margin-bottom: 40px;
}

.brand-logo img {
    height: 48px;
    filter: brightness(0) invert(1);
}

.brand-welcome {
    margin-bottom: 16px;
}

.brand-welcome h1 {
    font-size: 28px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.3;
    margin: 0 0 8px 0;
}

.brand-welcome p {
    font-size: 15px;
    color: rgba(255,255,255,0.7);
    line-height: 1.6;
    margin: 0;
    font-weight: 300;
}

.brand-hospital-name {
    font-size: 14px;
    color: var(--accent-light);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 24px;
}

/* --- Feature List on Brand Panel --- */
.brand-features {
    position: relative;
    z-index: 1;
    margin-top: 32px;
}

.brand-feature-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
}

.brand-feature-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(14,165,233,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-feature-icon .bi {
    font-size: 16px;
    color: var(--accent-light);
}

.brand-feature-text {
    font-size: 13px;
    color: rgba(255,255,255,0.8);
    font-weight: 400;
}

/* --- Brand Footer --- */
.brand-footer {
    position: relative;
    z-index: 1;
    margin-top: auto;
    padding-top: 32px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.brand-footer-contact {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.brand-footer-contact a,
.brand-footer-contact span {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.brand-footer-contact a:hover {
    color: rgba(255,255,255,0.8);
}

.brand-footer-contact .bi {
    font-size: 12px;
    width: 16px;
    text-align: center;
}

/* --- Right Form Panel --- */
.login-form-panel {
    flex: 1;
    background: var(--card-bg);
    padding: 48px 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.form-logo {
    margin-bottom: 24px;
}

.form-logo img {
    height: 44px;
    display: block;
}

.form-header {
    margin-bottom: 32px;
}

.form-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 6px 0;
}

.form-header p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
    font-weight: 400;
}

/* --- Toast Notification --- */
.login-toast {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    min-width: 320px;
    max-width: 420px;
    padding: 14px 20px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-xl);
    transform: translateX(calc(100% + 30px));
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.login-toast.show {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

.login-toast.toast-error {
    background: var(--error-bg);
    border: 1px solid #fecaca;
    color: #991b1b;
}

.login-toast.toast-success {
    background: var(--success-bg);
    border: 1px solid #bbf7d0;
    color: #166534;
}

.login-toast .toast-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.login-toast .toast-message {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    flex: 1;
}

.login-toast .toast-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.5;
    padding: 0;
    line-height: 1;
    color: inherit;
    flex-shrink: 0;
}

.login-toast .toast-close:hover {
    opacity: 1;
}

/* --- Form Input Groups --- */
.login-input-group {
    position: relative;
    margin-bottom: 20px;
}

.login-input-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.login-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.login-input-wrapper .input-icon {
    position: absolute;
    left: 14px;
    font-size: 18px;
    color: var(--text-muted);
    z-index: 1;
    transition: var(--transition);
    pointer-events: none;
}

.login-input {
    width: 100%;
    height: 48px;
    padding: 0 14px 0 44px;
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    transition: var(--transition);
    outline: none;
}

/* Extra right padding for password field to accommodate eye toggle */
.login-input-pwd {
    padding-right: 46px;
}

.login-input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.login-input:hover {
    border-color: #cbd5e1;
    background: #ffffff;
}

.login-input:focus {
    border-color: var(--input-focus);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(14,165,233,0.1);
}

/* Focus state for icon when input is focused */
.login-input-wrapper:focus-within .input-icon {
    color: var(--input-focus);
}

/* --- Validation States --- */
.login-input-group.has-error .login-input {
    border-color: var(--error);
    background: var(--error-bg);
}

.login-input-group.has-error .input-icon {
    color: var(--error);
}

.login-input-group.has-error .input-error-msg {
    display: block;
}

.input-error-msg {
    display: none;
    font-size: 12px;
    color: var(--error);
    margin-top: 4px;
    padding-left: 2px;
    font-weight: 500;
}

/* --- Password Toggle --- */
.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    font-size: 18px;
    color: var(--text-muted);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    border-radius: 6px;
}

.password-toggle:hover {
    color: var(--text-secondary);
    background: rgba(0,0,0,0.04);
}

.login-input-group .login-input[type="password"] ~ .password-toggle .bi-eye {
    display: none;
}

.login-input-group .login-input[type="text"] ~ .password-toggle .bi-eye-slash {
    display: none;
}

/* --- Caps Lock Warning --- */
.caps-lock-warning {
    display: none;
    font-size: 11px;
    color: #d97706;
    margin-top: 4px;
    padding-left: 2px;
    font-weight: 500;
}

.caps-lock-warning .bi {
    font-size: 12px;
    margin-right: 2px;
}

.caps-lock-warning.show {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* --- Login Button --- */
.login-btn {
    width: 100%;
    height: 48px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
    letter-spacing: 0.3px;
}

.login-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    box-shadow: 0 4px 12px rgba(30,58,95,0.4);
    transform: translateY(-1px);
}

.login-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: var(--shadow-md);
}

.login-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* --- Loading Spinner --- */
.login-btn .btn-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.login-btn.loading .btn-text {
    opacity: 0;
    visibility: hidden;
}

.login-btn.loading .btn-spinner {
    display: block;
    position: absolute;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- OTP Section --- */
.otp-section {
    display: none;
    animation: slideDown 0.3s ease-out;
}

.otp-section.show {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.otp-info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.otp-info .bi {
    color: var(--accent);
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

.otp-info p {
    font-size: 13px;
    color: #1e40af;
    margin: 0;
    line-height: 1.5;
}

/* --- Contact Footer --- */
.login-form-footer {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid #f1f5f9;
    text-align: center;
}

.login-form-footer p {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0 0 8px 0;
}

.login-form-footer .footer-links {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.login-form-footer .footer-links a,
.login-form-footer .footer-links span {
    font-size: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: var(--transition);
}

.login-form-footer .footer-links a:hover {
    color: var(--accent);
}

.login-form-footer .footer-links .bi {
    font-size: 12px;
}

/* --- Credential Section Transition --- */
.credential-section {
    transition: var(--transition);
}

.credential-section.hide {
    display: none;
}

/* --- Remember Me --- */
.remember-section {
    display: none;
    margin-top: 12px;
    margin-bottom: 8px;
}

.remember-section.show {
    display: block;
}

.remember-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.remember-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
    margin: 0;
}

.remember-check span {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 400;
    user-select: none;
}

/* --- OTP Back Link --- */
.otp-back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--accent);
    text-decoration: none;
    margin-top: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.otp-back-link:hover {
    color: var(--primary-light);
    text-decoration: none;
}

.otp-back-link .bi {
    font-size: 14px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .login-card-modern {
        flex-direction: column;
        max-width: 440px;
    }

    .login-brand-panel {
        flex: none;
        padding: 28px 24px;
    }

    .brand-welcome h1 {
        font-size: 22px;
    }

    .brand-features {
        display: none;
    }

    .brand-footer {
        display: none;
    }

    .login-form-panel {
        padding: 32px 24px;
    }

    .login-toast {
        left: 16px;
        right: 16px;
        min-width: auto;
        top: 16px;
    }
}

@media (max-width: 480px) {
    .login-container {
        padding: 12px;
    }

    .login-brand-panel {
        padding: 20px 20px;
    }

    .brand-hospital-name {
        font-size: 11px;
    }

    .brand-welcome h1 {
        font-size: 20px;
    }

    .brand-welcome p {
        display: none;
    }

    .login-form-panel {
        padding: 24px 20px;
    }

    .form-header h2 {
        font-size: 20px;
    }

    .login-input {
        height: 44px;
        font-size: 14px;
    }

    .login-btn {
        height: 44px;
    }
}

/* --- High-contrast / prefers-reduced-motion --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* --- Keyboard focus visible --- */
.login-input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.login-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.password-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
