@import url("https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&display=swap");

/* ============================================================
   Dammam Health Network — Login Page
   شبكة صحة الدمام · الصحة القابضة
   Designed & Developed by Ali Abukallah
   ============================================================ */

/* ── Variables ── */
:root {
    --g1:           #001d3d;
    --g2:           #003B71;
    --g3:           #00A6A6;
    --gold:         #00A6A6;
    --gold-l:       #4dd8d8;
    --white:        #ffffff;
    --gray1:        #eaf0eb;
    --gray2:        #b0bdb4;
    --gray3:        #5a6b5e;
    --gray4:        #1e2d22;
    --err-bg:       #fff5f5;
    --err-color:    #c62828;
    --err-border:   #e57373;
    --radius:       10px;
    --ease:         cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin:     0;
    padding:    0;
}

html {
    font-size: 16px;
}

body {
    min-height:      100vh;
    width:           100%;
    font-family:     'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
    color:           #1e2d22;
    background:      #000d1a;
    display:         flex;
    align-items:     center;
    justify-content: center;
    overflow-x:      hidden;
    position:        relative;
}

/* ============================================================
   Background Animation
   ============================================================ */
.bg-canvas {
    position:   fixed;
    inset:      0;
    z-index:    0;
    background: linear-gradient(
        135deg,
        #000d1a 0%,
        #001d3d 45%,
        #000d1a 100%
    );
    overflow:   hidden;
}

.bg-orb {
    position:      absolute;
    border-radius: 50%;
    filter:        blur(90px);
    animation:     orbFloat 10s ease-in-out infinite;
}

.orb-1 {
    width:            600px;
    height:           600px;
    background:       #003B71;
    top:              -220px;
    right:            -180px;
    opacity:          0.15;
    animation-delay:  0s;
}

.orb-2 {
    width:            480px;
    height:           480px;
    background:       #00A6A6;
    bottom:           -180px;
    left:             -140px;
    opacity:          0.10;
    animation-delay:  4s;
}

.orb-3 {
    width:            360px;
    height:           360px;
    background:       #00A6A6;
    top:              50%;
    left:             50%;
    transform:        translate(-50%, -50%);
    opacity:          0.08;
    animation-delay:  2s;
}

.bg-grid {
    position:          absolute;
    inset:             0;
    background-image:  radial-gradient(
        circle,
        rgba(0, 166, 166, 0.10) 1px,
        transparent 1px
    );
    background-size:   38px 38px;
    animation:         gridMove 22s linear infinite;
}

@keyframes orbFloat {
    0%,  100% { transform: translate(0, 0) scale(1);        }
    33%        { transform: translate(25px, -18px) scale(1.04); }
    66%        { transform: translate(-18px, 22px) scale(0.97); }
}

@keyframes gridMove {
    0%   { background-position: 0 0;       }
    100% { background-position: 38px 38px; }
}

/* ============================================================
   Language Toggle Button
   ============================================================ */
.lang-toggle {
    position:        fixed;
    top:             20px;
    left:            20px;
    display:         flex;
    align-items:     center;
    gap:             7px;
    padding:         9px 18px;
    background:      rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    border:          1px solid rgba(0, 166, 166, 0.30);
    border-radius:   30px;
    color:           rgba(255, 255, 255, 0.75);
    font-size:       12px;
    font-weight:     600;
    letter-spacing:  0.5px;
    text-decoration: none;
    z-index:         100;
    transition:      all 0.25s var(--ease);
}

.lang-toggle svg {
    width:  15px;
    height: 15px;
    flex-shrink: 0;
}

.lang-toggle:hover {
    background:  rgba(0, 166, 166, 0.15);
    border-color: var(--gold);
    color:        var(--gold);
    transform:   translateY(-1px);
}

/* ============================================================
   Main Wrapper
   ============================================================ */
.wrap {
    position:        relative;
    z-index:         1;
    width:           100%;
    max-width:       480px;
    padding:         24px 16px 32px;
    display:         flex;
    flex-direction:  column;
    align-items:     center;
    gap:             0;
}

/* ============================================================
   Logo Section
   ============================================================ */
.logo-wrap {
    display:        flex;
    flex-direction: column;
    align-items:    center;
    gap:            14px;
    margin-bottom:  28px;
    animation:      fadeDown 0.9s var(--ease) both;
}

@keyframes fadeDown {
    from { opacity: 0; transform: translateY(-28px); }
    to   { opacity: 1; transform: translateY(0);     }
}

/* ── الختم الدائري ── */
.logo-seal {
    position:        relative;
    width:           100px;
    height:          100px;
    display:         flex;
    align-items:     center;
    justify-content: center;
}

.seal-ring {
    position:      absolute;
    border-radius: 50%;
    border:        1px solid rgba(0, 166, 166, 0.25);
    top:           50%;
    left:          50%;
    transform:     translate(-50%, -50%);
    animation:     ringPulse 3.5s ease-in-out infinite;
}

.r1 { width: 92px;  height: 92px;  animation-delay: 0s;    }
.r2 { width: 108px; height: 108px; animation-delay: 0.6s;  opacity: 0.55; }
.r3 { width: 124px; height: 124px; animation-delay: 1.2s;  opacity: 0.28; }

@keyframes ringPulse {
    0%,  100% { transform: translate(-50%, -50%) scale(1);    opacity: 0.5; }
    50%        { transform: translate(-50%, -50%) scale(1.04); opacity: 1.0; }
}

.seal-core {
    width:            80px;
    height:           80px;
    background:       linear-gradient(145deg, #003B71, #001d3d);
    border-radius:    50%;
    display:          flex;
    align-items:      center;
    justify-content:  center;
    position:         relative;
    z-index:          2;
    box-shadow:
        0 0 0 2px rgba(0, 166, 166, 0.40),
        0 10px 36px rgba(0, 0, 0, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.10);
    animation:        corePulse 3.5s ease-in-out infinite;
}

@keyframes corePulse {
    0%,  100% { box-shadow: 0 0 0 2px rgba(0,166,166,0.40), 0 10px 36px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.10); }
    50%        { box-shadow: 0 0 0 3px rgba(0,166,166,0.90), 0 10px 44px rgba(0,166,166,0.20), inset 0 1px 0 rgba(255,255,255,0.15); }
}

.seal-m {
    font-size:   36px;
    font-weight: 900;
    color:       white;
    line-height: 1;
    letter-spacing: -1px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    position:    relative;
    font-family: 'Segoe UI', Arial, sans-serif;
}

.seal-m::after {
    content:       '';
    position:      absolute;
    bottom:        -7px;
    left:          50%;
    transform:     translateX(-50%);
    width:         24px;
    height:        2.5px;
    background:    linear-gradient(
        90deg, transparent, var(--gold), transparent
    );
    border-radius: 2px;
    animation:     goldBar 2.5s ease-in-out infinite;
}

@keyframes goldBar {
    0%,  100% { width: 18px; opacity: 0.6; }
    50%        { width: 30px; opacity: 1.0; }
}

/* نقطة دوارة حول الختم */
.orbit-dot {
    position:        absolute;
    width:           9px;
    height:          9px;
    border-radius:   50%;
    background:      var(--gold);
    box-shadow:      0 0 8px rgba(0, 166, 166, 0.9);
    top:             50%;
    left:            50%;
    margin-top:      -4.5px;
    margin-left:     -4.5px;
    transform-origin: 4.5px -42px;
    animation:       orbit 7s linear infinite;
}

@keyframes orbit {
    from { transform: rotate(0deg);   }
    to   { transform: rotate(360deg); }
}

/* ── نصوص الشعار ── */
.logo-text-block {
    display:        flex;
    flex-direction: column;
    align-items:    center;
    gap:            6px;
}

.logo-name {
    font-size:      38px;
    font-weight:    900;
    letter-spacing: 8px;
    line-height:    1;
    background:     linear-gradient(
        135deg,
        #ffffff  0%,
        #c8e8d0 50%,
        #ffffff 100%
    );
    background-size:         200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip:         text;
    animation:               shimmer 4.5s ease-in-out infinite;
}

@keyframes shimmer {
    0%   { background-position: 0%   50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0%   50%; }
}

.logo-divider {
    display:     flex;
    align-items: center;
    gap:         10px;
    width:       100%;
}

.logo-divider-line {
    flex:       1;
    height:     1px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(0, 166, 166, 0.55),
        transparent
    );
}

.logo-sub {
    font-size:      12px;
    color:          var(--gold);
    font-weight:    700;
    letter-spacing: 1.5px;
    white-space:    nowrap;
}

.logo-entity {
    font-size:      10px;
    color:          rgba(255, 255, 255, 0.40);
    letter-spacing: 1.8px;
    font-weight:    500;
    text-align:     center;
}

/* ============================================================
   Card
   ============================================================ */
.card {
    width:            100%;
    background:       rgba(255, 255, 255, 0.97);
    backdrop-filter:  blur(20px);
    border-radius:    20px;
    border:           1px solid rgba(255, 255, 255, 0.25);
    overflow:         hidden;
    box-shadow:
        0 24px 64px rgba(0, 0, 0, 0.45),
        0  2px  6px rgba(0, 0, 0, 0.15);
    animation:        fadeUp 0.9s var(--ease) 0.25s both;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(36px); }
    to   { opacity: 1; transform: translateY(0);    }
}

/* شريط أعلى الكارد */
.card-stripe {
    height:   4px;
    position: relative;
    overflow: hidden;
    background: linear-gradient(
        90deg,
        var(--g1)   0%,
        var(--g2)  40%,
        var(--g3)  70%,
        var(--gold) 100%
    );
}

.card-stripe::after {
    content:    '';
    position:   absolute;
    inset:      0;
    background: linear-gradient(
        90deg,
        transparent           0%,
        rgba(255,255,255,0.5) 50%,
        transparent           100%
    );
    animation: stripeShine 3s ease-in-out infinite;
}

@keyframes stripeShine {
    0%   { transform: translateX(-150%); }
    100% { transform: translateX(150%);  }
}

.card-body {
    padding: 36px 36px 30px;
}

/* ── عنوان الكارد ── */
.card-title {
    text-align:    center;
    margin-bottom: 28px;
}

.card-title h1 {
    font-size:     21px;
    font-weight:   700;
    color:         var(--g1);
    margin-bottom: 6px;
}

.card-title p {
    font-size: 13px;
    color:     var(--gray3);
}

.card-title-bar {
    width:         44px;
    height:        3px;
    background:    linear-gradient(90deg, var(--g2), var(--gold));
    border-radius: 3px;
    margin:        12px auto 0;
}

/* ── Alert ── */
.alert {
    display:       flex;
    align-items:   flex-start;
    gap:           10px;
    padding:       12px 16px;
    border-radius: 8px;
    font-size:     13px;
    font-weight:   500;
    margin-bottom: 22px;
    background:    var(--err-bg);
    color:         var(--err-color);
    border:        1px solid var(--err-border);
    border-right:  4px solid var(--err-border);
    animation:     shake 0.4s ease;
}

[dir="ltr"] .alert {
    border-right: 1px solid var(--err-border);
    border-left:  4px solid var(--err-border);
}

.alert svg {
    width:      18px;
    height:     18px;
    flex-shrink: 0;
    margin-top: 1px;
}

@keyframes shake {
    0%,  100% { transform: translateX(0);   }
    20%,  60% { transform: translateX(-5px); }
    40%,  80% { transform: translateX(5px);  }
}

/* ============================================================
   Form
   ============================================================ */
.form-group {
    margin-bottom: 22px;
}

.form-group label {
    display:        block;
    font-size:      12px;
    font-weight:    700;
    color:          var(--g1);
    margin-bottom:  8px;
    letter-spacing: 0.3px;
}

/* ── Input Wrapper ── */
.input-wrap {
    position:    relative;
    display:     flex;
    align-items: center;
}

.input-icon {
    position:       absolute;
    right:          14px;
    display:        flex;
    align-items:    center;
    justify-content: center;
    color:          var(--gray2);
    pointer-events: none;
    transition:     color 0.2s var(--ease);
    width:          20px;
    height:         20px;
}

/* LTR — أيقونة على اليسار */
[dir="ltr"] .input-icon {
    right: auto;
    left:  14px;
}

.input-wrap input {
    width:         100%;
    height:        50px;
    padding:       0 48px;
    border:        1.5px solid var(--gray1);
    border-radius: var(--radius);
    font-size:     14px;
    color:         var(--gray4);
    background:    #f8fbf9;
    transition:    all 0.2s var(--ease);
    outline:       none;
    font-family:   inherit;
}

/* RTL padding */
[dir="rtl"] .input-wrap input {
    direction: rtl;
}

/* LTR padding */
[dir="ltr"] .input-wrap input {
    direction: ltr;
}

.input-wrap input:hover {
    border-color: var(--gray2);
}

.input-wrap input:focus {
    border-color: var(--g2);
    background:   #fff;
    box-shadow:   0 0 0 4px rgba(26, 107, 60, 0.10);
}

.input-wrap:focus-within .input-icon {
    color: var(--g2);
}

.input-wrap input::placeholder {
    color:     var(--gray2);
    font-size: 13px;
}

/* ── زر إظهار/إخفاء كلمة المرور ── */
.toggle-pw {
    position:      absolute;
    left:          12px;
    background:    none;
    border:        none;
    cursor:        pointer;
    display:       flex;
    align-items:   center;
    justify-content: center;
    padding:       6px;
    border-radius: 6px;
    color:         var(--gray2);
    transition:    all 0.2s var(--ease);
    width:         32px;
    height:        32px;
}

[dir="ltr"] .toggle-pw {
    left:  auto;
    right: 12px;
}

.toggle-pw:hover {
    background: var(--gray1);
    color:      var(--g2);
}

/* ── زر الدخول ── */
.btn-login {
    width:          100%;
    height:         52px;
    background:     linear-gradient(135deg, var(--g1) 0%, var(--g2) 100%);
    color:          #fff;
    border:         none;
    border-radius:  var(--radius);
    font-size:      15px;
    font-weight:    700;
    cursor:         pointer;
    transition:     all 0.25s var(--ease);
    margin-top:     8px;
    letter-spacing: 0.5px;
    font-family:    inherit;
    position:       relative;
    overflow:       hidden;
}

.btn-login::after {
    content:    '';
    position:   absolute;
    top:        0;
    left:       -100%;
    width:      60%;
    height:     100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.15),
        transparent
    );
    transition: left 0.55s;
}

.btn-login:hover {
    transform:  translateY(-2px);
    box-shadow: 0 8px 28px rgba(26, 107, 60, 0.45);
    background: linear-gradient(135deg, var(--g2) 0%, var(--g3) 100%);
}

.btn-login:hover::after {
    left: 140%;
}

.btn-login:active {
    transform:  translateY(0);
    box-shadow: none;
}

/* ============================================================
   Footer
   ============================================================ */
.footer {
    margin-top:  20px;
    text-align:  center;
    animation:   fadeUp 0.9s var(--ease) 0.5s both;
}

.footer p {
    font-size:   11px;
    color:       rgba(255, 255, 255, 0.30);
    line-height: 2;
}

.footer-stamp {
    display:         flex;
    align-items:     center;
    justify-content: center;
    margin-top:      12px;
}
.footer-stamp-img {
    width:      170px;
    height:     auto;
    max-width:  100%;
    display:    block;
    object-fit: contain;
    transition: transform 0.25s var(--ease);
}
.footer-stamp:hover .footer-stamp-img {
    transform: scale(1.05);
}

@media (max-width: 400px) {
    .footer-stamp-img { width: 130px; }
}

/* ============================================================
   Responsive — All Devices
   ============================================================ */

/* Mobile S — 380px */
@media (max-width: 400px) {
    .logo-name          { font-size: 28px; letter-spacing: 5px; }
    .seal-core          { width: 66px; height: 66px; }
    .seal-m             { font-size: 30px; }
    .r1                 { width: 76px;  height: 76px;  }
    .r2                 { width: 90px;  height: 90px;  }
    .r3                 { width: 104px; height: 104px; }
    .card-body          { padding: 24px 18px 20px; }
    .input-wrap input   { height: 46px; }
    .btn-login          { height: 48px; font-size: 14px; }
    .lang-toggle        { top: 12px; left: 12px; padding: 7px 14px; }
}

/* Mobile M — 520px */
@media (max-width: 520px) {
    .wrap               { padding: 20px 14px 28px; }
    .card-body          { padding: 28px 22px 22px; }
    .logo-name          { font-size: 32px; }
}

/* Tablet ── 768px */
@media (min-width: 768px) {
    .wrap               { max-width: 500px; }
    .card-body          { padding: 40px 44px 34px; }
    .logo-name          { font-size: 42px; }
}

/* Desktop ── 1200px+ */
@media (min-width: 1200px) {
    .wrap               { max-width: 520px; }
}

/* شاشات قصيرة ── الختم يختفي */
@media (max-height: 680px) {
    .logo-seal          { display: none; }
    .logo-wrap          { margin-bottom: 16px; }
}
/* ============================================================
   CRITICAL MOBILE FIX
   ============================================================ */

/* منع أي عنصر من تجاوز عرض الشاشة */
* { max-width: 100%; }

/* SVG fix — أساسي */
svg {
    max-width: 100%;
    height: auto;
}

/* زر اللغة */
.lang-toggle {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 100;
    max-width: calc(100% - 32px);
}
.lang-toggle svg {
    width: 15px !important;
    height: 15px !important;
    flex-shrink: 0;
}

/* الشعار في الجوال */
.logo-seal img {
    width: 90px !important;
    height: 90px !important;
    max-width: 90px !important;
}
.logo-seal {
    width: 90px !important;
    height: 90px !important;
    min-width: unset !important;
}

/* الكارد */
.card {
    width: 100%;
    max-width: 100%;
}

/* الخلفية */
.bg-canvas {
    max-width: 100vw;
    overflow: hidden;
}

/* ── Mobile ── */
@media (max-width: 480px) {
    html, body { overflow-x: hidden; }

    .wrap { padding: 16px 14px 24px; max-width: 100%; }

    .logo-seal img {
        width: 75px !important;
        height: 75px !important;
    }
    .logo-seal {
        width: 75px !important;
        height: 75px !important;
    }

    .logo-name { font-size: 24px !important; letter-spacing: 4px; }
    .logo-sub  { font-size: 10px !important; }
    .logo-entity { font-size: 10px !important; }

    .card { border-radius: 14px; }
    .card-body { padding: 20px 16px 18px; }

    .input-wrap input {
        height: 44px;
        font-size: 16px; /* منع zoom في iOS */
    }

    .btn-login { height: 46px; font-size: 14px; }

    .lang-toggle {
        top: 10px;
        left: 10px;
        padding: 6px 12px;
        font-size: 11px;
    }

    /* إخفاء الـ rings المتحركة في الجوال */
    .seal-ring, .orbit-dot { display: none; }
}

@media (max-width: 360px) {
    .logo-seal img {
        width: 65px !important;
        height: 65px !important;
    }
    .logo-name { font-size: 20px !important; }
    .card-body { padding: 16px 12px; }
}