/* =====================================================
   Clinic Station – Login Page  |  Glass Morphism Design
   Phase 49.1 – Integrated with Real API Authentication
   ===================================================== */

/* ─── Reset & Base ─── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --teal:         #0ec4d0;
    --teal-dark:    #0891b2;
    --teal-glow:    rgba(14, 196, 208, 0.55);
    --glass-bg:     rgba(10, 30, 40, 0.52);
    --glass-border: rgba(14, 196, 208, 0.35);
    --glass-blur:   18px;
    --white:        #ffffff;
    --white-80:     rgba(255,255,255,0.80);
    --white-50:     rgba(255,255,255,0.50);
    --white-20:     rgba(255,255,255,0.20);
    --white-10:     rgba(255,255,255,0.10);
    --input-bg:     rgba(255,255,255,0.12);
    --input-border: rgba(255,255,255,0.25);
    --input-focus:  rgba(14, 196, 208, 0.70);
    --text-main:    #ffffff;
    --text-sub:     rgba(255,255,255,0.72);
    --error-color:  #ff6b6b;
    --radius-lg:    20px;
    --radius-md:    14px;
    --radius-sm:    10px;
    --shadow-card:  0 8px 40px rgba(0,0,0,0.45);
    --shadow-btn:   0 4px 24px rgba(14, 196, 208, 0.50);
    --font:         'Cairo', 'Segoe UI', system-ui, sans-serif;
}

/* ─── Screen-reader only ─── */
.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;
}

html, body {
    width: 100%;
    height: 100%;
    font-family: var(--font);
    overflow: hidden;
}

/* ─── Background ─── */
body {
    background-image: url('../img/bg_clinic.jpg');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    position: relative;
}

.bg-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(
        160deg,
        rgba(0, 20, 35, 0.55) 0%,
        rgba(0, 40, 60, 0.45) 50%,
        rgba(0, 10, 20, 0.60) 100%
    );
    z-index: 0;
}

/* ─── Page Wrapper ─── */
.page-wrapper {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 20px;
}

/* ─── Glass Card Base ─── */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1.5px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card), inset 0 1px 0 rgba(255,255,255,0.12);
    color: var(--text-main);
}

.glass-card-sm {
    background: rgba(10, 30, 40, 0.45);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1.5px solid var(--glass-border);
    border-radius: 50px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.30);
    color: var(--text-main);
}

/* ─── Logo Card ─── */
.logo-card {
    width: 100%;
    max-width: 480px;
    padding: 18px 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: slideDown 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.logo-img {
    height: 64px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 12px rgba(14,196,208,0.4));
}

/* ─── Login Card ─── */
.login-card {
    width: 100%;
    max-width: 480px;
    padding: 36px 36px 28px;
    animation: slideUp 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both;
    position: relative;
    overflow: hidden;
}

/* Glowing top line */
.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--teal), transparent);
    border-radius: 2px;
}

/* ─── Welcome Text ─── */
.welcome-text {
    font-size: 22px;
    font-weight: 700;
    color: var(--white);
    text-align: center;
    margin-bottom: 28px;
    line-height: 1.5;
    text-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

/* ─── Input Group ─── */
.input-group {
    position: relative;
    margin-bottom: 16px;
}

.input-group input {
    width: 100%;
    padding: 14px 48px;
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    border-radius: 50px;
    color: var(--white);
    font-family: var(--font);
    font-size: 15px;
    font-weight: 400;
    transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
    outline: none;
}

.input-group input::placeholder {
    color: var(--white-50);
    font-size: 14px;
}

.input-group input:focus {
    border-color: var(--teal);
    background: rgba(14, 196, 208, 0.10);
    box-shadow: 0 0 0 3px rgba(14, 196, 208, 0.18), 0 0 20px rgba(14, 196, 208, 0.12);
}

.input-group input:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 2px;
}

/* Branch dropdown — same glass style as inputs (Phase 49.2B) */
.input-group select {
    width: 100%;
    padding: 14px 48px 14px 16px;
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    border-radius: 12px;
    color: var(--white-80);
    font-family: inherit;
    font-size: 15px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    outline: none;
    transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
}
.input-group select option {
    background: #0d2030;
    color: #fff;
}
.input-group select:focus {
    border-color: var(--teal);
    background: rgba(14, 196, 208, 0.10);
    box-shadow: 0 0 0 3px rgba(14, 196, 208, 0.18), 0 0 20px rgba(14, 196, 208, 0.12);
}
.input-group select:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 2px;
}

/* Input icon – RTL: right side (logical start) */
.input-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--white-50);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.input-icon svg {
    width: 18px;
    height: 18px;
}

/* Eye toggle – RTL: left side (logical end) */
.toggle-eye {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--white-50);
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    padding: 0;
}

.toggle-eye:hover { color: var(--teal); }
.toggle-eye:focus-visible { outline: 2px solid var(--teal); border-radius: 4px; }

.toggle-eye svg { width: 18px; height: 18px; }

/* LTR overrides – flip icon positions */
[dir="ltr"] .input-icon { right: auto; left: 16px; }
[dir="ltr"] .toggle-eye { left: auto; right: 16px; }

/* ─── Forgot Row ─── */
.forgot-row {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 22px;
    padding: 0 4px;
}

[dir="ltr"] .forgot-row {
    justify-content: flex-end;
}

.forgot-link {
    font-size: 13px;
    color: var(--white-80);
    text-decoration: none;
    transition: color 0.2s;
    font-weight: 400;
}

.forgot-link:hover { color: var(--teal); text-decoration: underline; }
.forgot-link:focus-visible { outline: 2px solid var(--teal); border-radius: 4px; }

/* ─── Error Banner ─── */
.error-banner {
    background: rgba(255, 107, 107, 0.18);
    border: 1px solid rgba(255, 107, 107, 0.45);
    border-radius: var(--radius-sm);
    color: #ff9a9a;
    font-size: 13px;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease, margin 0.3s ease;
    text-align: center;
    margin-bottom: 0;
    line-height: 1.5;
}

.error-banner.visible {
    max-height: 80px;
    padding: 10px 16px;
    margin-bottom: 16px;
}

/* ─── Login Button ─── */
.login-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
    border: none;
    border-radius: 50px;
    color: var(--white);
    font-family: var(--font);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    box-shadow: var(--shadow-btn);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.5px;
    margin-bottom: 24px;
}

.login-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.18) 0%, transparent 60%);
    border-radius: inherit;
    pointer-events: none;
}

.login-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(14, 196, 208, 0.65);
}

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

.login-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.login-btn:focus-visible {
    outline: 2px solid white;
    outline-offset: 3px;
}

/* Spinner */
.btn-spinner svg {
    width: 22px;
    height: 22px;
    animation: spin 0.8s linear infinite;
}

/* ─── Clinic Picker ─── */
.clinic-sub {
    text-align: center;
    color: var(--white-50);
    font-size: 13px;
    margin-bottom: 20px;
}

#clinicList {
    max-height: 260px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 8px;
}

#clinicList::-webkit-scrollbar { width: 4px; }
#clinicList::-webkit-scrollbar-thumb { background: var(--teal-glow); border-radius: 3px; }

.clinic-option {
    width: 100%;
    padding: 14px 20px;
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    border-radius: var(--radius-md);
    color: var(--white);
    font-family: var(--font);
    font-size: 14px;
    cursor: pointer;
    text-align: start;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transition: border-color 0.2s, background 0.2s;
}

.clinic-option:hover:not(:disabled) {
    border-color: var(--teal);
    background: rgba(14, 196, 208, 0.10);
}

.clinic-option:disabled { opacity: 0.5; cursor: not-allowed; }

.clinic-name { font-weight: 600; }
.clinic-role {
    font-size: 12px;
    color: var(--teal);
    background: rgba(14, 196, 208, 0.15);
    padding: 2px 10px;
    border-radius: 20px;
    white-space: nowrap;
}

.back-btn {
    font-size: 15px;
    margin-bottom: 0;
}

/* ─── Card Footer ─── */
.card-footer {
    border-top: 1px solid var(--white-10);
    padding-top: 18px;
    text-align: center;
}

.card-footer p {
    font-size: 12px;
    color: var(--white-50);
    margin-bottom: 6px;
}

.contact-link {
    font-size: 13px;
    color: var(--teal);
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.2s;
}

.contact-link:hover { color: #5ee7ef; }
.contact-link:focus-visible { outline: 2px solid var(--teal); border-radius: 4px; }

/* ─── Language Switcher ─── */
.lang-switcher {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 22px;
    animation: fadeIn 0.8s ease 0.3s both;
}

.globe-icon {
    width: 18px;
    height: 18px;
    color: var(--teal);
    flex-shrink: 0;
}

.lang-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font);
    font-size: 14px;
    color: var(--white-50);
    transition: color 0.2s;
    padding: 0;
}

.lang-btn.active,
.lang-btn:hover { color: var(--white); font-weight: 600; }
.lang-btn:focus-visible { outline: 2px solid var(--teal); border-radius: 4px; }

.lang-sep {
    color: var(--white-50);
    font-size: 14px;
}

/* ─── Toast ─── */
.toast-notification {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(10, 30, 40, 0.92);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    color: var(--white);
    font-size: 14px;
    padding: 12px 28px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
    opacity: 0;
    z-index: 9999;
    max-width: 90vw;
    white-space: normal;
    word-break: break-word;
    text-align: center;
    pointer-events: none;
}

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

.toast-notification.success { border-color: rgba(16, 185, 129, 0.5); color: #6ee7b7; }
.toast-notification.error   { border-color: rgba(255, 107, 107, 0.5); color: #ff9a9a; }

/* ─── Animations ─── */
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-40px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(40px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes shake {
    0%,100% { transform: translateX(0); }
    15%      { transform: translateX(-8px); }
    30%      { transform: translateX(8px); }
    45%      { transform: translateX(-6px); }
    60%      { transform: translateX(6px); }
    75%      { transform: translateX(-3px); }
    90%      { transform: translateX(3px); }
}

/* ─── Particles ─── */
.particles-container {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.particle {
    position: absolute;
    background: radial-gradient(circle, var(--teal) 0%, rgba(14, 196, 208, 0.3) 70%, transparent 100%);
    border-radius: 50%;
    opacity: 0.4;
    filter: blur(1px);
    box-shadow: 0 0 20px rgba(14, 196, 208, 0.5), 0 0 40px rgba(14, 196, 208, 0.2);
}

.particle.size-1 { width: 4px;  height: 4px;  }
.particle.size-2 { width: 8px;  height: 8px;  }
.particle.size-3 { width: 12px; height: 12px; }
.particle.size-4 { width: 16px; height: 16px; }
.particle.size-5 { width: 20px; height: 20px; }

@keyframes float1 {
    0%,100% { transform: translate(0,0) scale(1); opacity: 0.4; }
    25%      { transform: translate(30px,-40px) scale(1.1); opacity: 0.6; }
    50%      { transform: translate(-20px,-80px) scale(0.9); opacity: 0.3; }
    75%      { transform: translate(40px,-50px) scale(1.05); opacity: 0.5; }
}
@keyframes float2 {
    0%,100% { transform: translate(0,0) scale(1); opacity: 0.3; }
    25%      { transform: translate(-40px,-50px) scale(0.95); opacity: 0.5; }
    50%      { transform: translate(30px,-70px) scale(1.1); opacity: 0.4; }
    75%      { transform: translate(-30px,-40px) scale(1); opacity: 0.6; }
}
@keyframes float3 {
    0%,100% { transform: translate(0,0) scale(1); opacity: 0.5; }
    25%      { transform: translate(50px,-60px) scale(1.05); opacity: 0.4; }
    50%      { transform: translate(-50px,-30px) scale(0.95); opacity: 0.6; }
    75%      { transform: translate(20px,-80px) scale(1.1); opacity: 0.3; }
}
@keyframes float4 {
    0%,100% { transform: translate(0,0) scale(1); opacity: 0.4; }
    25%      { transform: translate(-60px,-40px) scale(1.1); opacity: 0.5; }
    50%      { transform: translate(40px,-60px) scale(0.9); opacity: 0.4; }
    75%      { transform: translate(-20px,-70px) scale(1.05); opacity: 0.6; }
}
@keyframes float5 {
    0%,100% { transform: translate(0,0) scale(1); opacity: 0.3; }
    25%      { transform: translate(35px,-70px) scale(0.95); opacity: 0.6; }
    50%      { transform: translate(-45px,-50px) scale(1.1); opacity: 0.4; }
    75%      { transform: translate(25px,-60px) scale(1); opacity: 0.5; }
}

/* ─── Responsive ─── */
@media (max-width: 520px) {
    .page-wrapper { gap: 14px; padding: 16px; }
    .logo-card { padding: 14px 20px; }
    .logo-img { height: 52px; }
    .login-card { padding: 28px 22px 22px; }
    .welcome-text { font-size: 18px; margin-bottom: 22px; }
    .input-group input { font-size: 14px; padding: 13px 44px; }
    .login-btn { font-size: 16px; padding: 13px; }
}

@media (max-height: 700px) {
    .page-wrapper {
        gap: 10px;
        justify-content: flex-start;
        padding-top: 16px;
        overflow-y: auto;
        height: 100vh;
    }
    .logo-card { padding: 12px 24px; }
    .logo-img { height: 48px; }
    .login-card { padding: 24px 30px 20px; }
    .welcome-text { font-size: 18px; margin-bottom: 20px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
    .logo-card, .login-card, .lang-switcher { animation: none; opacity: 1; transform: none; }
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--teal-glow); border-radius: 3px; }
