:root {
    --accent: #47b671;
    --accent-2: #3aa864;
    --accent-gradient: linear-gradient(135deg, #47b671 0%, #3aa864 100%);
    --accent-glow: rgba(71, 182, 113, 0.4);

    --ink: #0f1c14;
    --ink-2: #18241a;

    --bg: #f3f6f4;
    --card: rgba(255, 255, 255, 0.96);
    --text: #0f1c14;
    --muted: #66726b;
    --border: #e4e9e6;

    --soft: #f6f8f6;
    --error: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --info: #3b82f6;

    --r: 24px;
    /* More rounded card */
    --r2: 12px;
    /* More rounded inputs */
    --h: 56px;
    /* Taller inputs */

    --shadow: 0 10px 30px -10px rgba(16, 24, 40, .1);
    --shadow-lg: 0 25px 50px -12px rgba(16, 24, 40, 0.15);
    --shadow-btn: 0 10px 20px -5px rgba(71, 182, 113, 0.3);

    --ring: 0 0 0 4px rgba(71, 182, 113, .18);

    --font: "Almarai", "Noto Kufi Arabic", "Cairo", "Segoe UI", sans-serif;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html,
body {
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: var(--font);
    background:
        radial-gradient(1000px 500px at 10% -10%, rgba(71, 182, 113, .12), transparent 70%),
        radial-gradient(800px 400px at 90% 90%, rgba(58, 168, 100, .08), transparent 70%),
        linear-gradient(180deg, #f8faf9 0%, #ebf2ee 100%);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
    position: relative;
    min-height: 100vh;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 80%, rgba(71, 182, 113, .05) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(71, 182, 113, .03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.wrap {
    width: min(420px, 100%);
    animation: floatIn 0.6s ease both;
    position: relative;
    z-index: 1;
}

.card {
    background: var(--card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--r);
    box-shadow: var(--shadow-lg);
    padding: 32px 28px 24px;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--accent-gradient);
    z-index: 1;
}

.card::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(380px 160px at 50% -10%, rgba(71, 182, 113, .06), transparent 70%);
    pointer-events: none;
}

.card>* {
    position: relative;
    z-index: 2;
}

.logo {
    display: flex;
    justify-content: center;
    margin-top: 2px;
    margin-bottom: -40px;
    animation: fadeUp 0.8s ease 0.1s both, float 5s ease-in-out 1s infinite;
}

.logo img {
    width: 190px;
    height: auto;
    transition: transform 0.3s ease;
}

.logo img:hover {
    transform: scale(1.05);
}

.title {
    text-align: center;
    font-weight: 700;
    font-size: 23px;
    letter-spacing: .2px;
    line-height: 1.35;
    margin-bottom: 10px;
    animation: fadeUp 0.6s ease 0.15s both;
}

.title .to {
    display: block;
    color: var(--accent);
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 800;
}

.field {
    margin-top: 14px;
}

.control {
    position: relative;
}

.input {
    width: 100%;
    height: var(--h);
    border-radius: var(--r2);
    border: 1px solid var(--border);
    background: #f9fbfa;
    color: var(--text);
    outline: none;
    padding: 0 16px;
    font-size: 16px;
    font-weight: 500;
    text-align: start;
    transition: var(--transition);
}

.input::placeholder {
    color: #8a948e;
    font-weight: 400;
}

.input:focus {
    border-color: var(--accent);
    background: #ffffff;
    box-shadow: var(--ring);
    transform: translateY(-2px);
}

.input-pass {
    background: var(--soft);
    border-color: #e7ece8;
}

.hasToggle .input {
    padding-inline-end: 52px;
}

.toggle {
    position: absolute;
    top: 50%;
    inset-inline-end: 12px;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 0;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    z-index: 2;
}

.toggle:hover {
    background: rgba(71, 182, 113, .08);
}

.toggle:active {
    transform: translateY(-50%) scale(.98);
}

.toggle i {
    color: var(--accent);
    font-size: 14px;
}

.row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-top: 14px;
}

.remember {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-weight: 600;
    user-select: none;
    cursor: pointer;
}

.remember input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.btn {
    width: 100%;
    height: 58px;
    margin-top: 20px;
    border: none;
    border-radius: 18px;
    color: #ffffff;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    background: var(--accent-gradient);
    box-shadow: var(--shadow-btn);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    letter-spacing: 0.3px;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .2), transparent);
    transition: 0.5s;
}

.btn:hover {
    filter: brightness(1.08);
    transform: translateY(-3px) scale(1.01);
    box-shadow: 0 15px 30px -5px rgba(71, 182, 113, 0.4);
}

.btn:hover::before {
    left: 100%;
}

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

.btn[disabled] {
    opacity: .65;
    cursor: not-allowed;
    filter: grayscale(.15);
    transform: none !important;
}

.spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    display: none;
    animation: spin 1s linear infinite;
}

.btn.isLoading .spinner {
    display: inline-block;
}

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

.forgot {
    text-align: center;
    margin-top: 12px;
}

.forgot a {
    color: var(--ink);
    font-weight: 700;
    text-decoration: none;
    position: relative;
    transition: var(--transition);
}

.forgot a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: width 0.3s ease;
}

.forgot a:hover::after {
    width: 100%;
}

.forgot a:hover {
    color: var(--accent);
}

.err {
    display: none;
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid #fecaca;
    background: #fff7ed;
    color: #9a3412;
    font-weight: 600;
    font-size: 13px;
    animation: shake 0.5s ease;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20%,
    60% {
        transform: translateX(-5px);
    }

    40%,
    80% {
        transform: translateX(5px);
    }
}




/* نافذة التحميل */
#loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.loading-content {
    text-align: center;
    animation: floatIn 0.5s ease;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 20px;
}

.loading-spinner svg {
    width: 100%;
    height: 100%;
    animation: rotate 2s linear infinite;
}

.loading-text {
    font-weight: 600;
    color: var(--text);
    font-size: 16px;
}

/* زر التثبيت */
#install-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--accent-gradient);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 12px 24px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(71, 182, 113, .3);
    display: none;
    z-index: 1000;
    transition: var(--transition);
}

#install-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(71, 182, 113, .4);
}

#install-button i {
    margin-right: 8px;
}

/* فاحص الاتصال */
#connection-checker {
    visibility: hidden;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.98);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.connection-content {
    text-align: center;
    max-width: 90%;
}

.connection-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.reconnect {
    border: none;
    outline: none;
    color: #fff;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 12px 24px;
    border-radius: 50px;
    background: var(--accent-gradient);
    margin-top: 20px;
    transition: var(--transition);
}

.reconnect:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(71, 182, 113, .3);
}

/* أنيميشن */
@keyframes floatIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* الطباعة */
@media print {
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .btn,
    .toggle,
    #install-button {
        display: none !important;
    }
}

/* الأجهزة الصغيرة */
@media (max-width: 420px) {
    body {
        padding: 16px;
    }

    .logo img {
        width: 170px;
    }

    .title {
        font-size: 22px;
    }

    .card {
        padding: 22px 18px 18px;
    }

    #install-button {
        bottom: 10px;
        right: 10px;
        padding: 10px 20px;
        font-size: 14px;
    }
}

/* الوضع الداكن */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d1410;
        --card: #121c15;
        --text: #e6eee8;
        --muted: #aab6ae;
        --border: rgba(71, 182, 113, .25);
        --soft: rgba(255, 255, 255, .05);
        --shadow-lg: 0 18px 50px rgba(3, 8, 18, .6);
    }

    body {
        background:
            radial-gradient(800px 500px at 12% -10%, rgba(71, 182, 113, .14), transparent 60%),
            linear-gradient(180deg, #0f1711 0%, #0c130f 100%);
    }

    .input {
        background: rgba(255, 255, 255, .04);
        color: var(--text);
    }

    .input::placeholder {
        color: rgba(226, 232, 240, .55);
    }

    .input-pass {
        background: rgba(255, 255, 255, .06);
    }

    .btn {
        color: #ffffff;
    }

    .forgot a {
        color: #dfe6e1;
    }

    #loading-overlay {
        background: rgba(13, 20, 16, 0.95);
    }

    #connection-checker {
        background: rgba(13, 20, 16, 0.98);
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}



/* تقليل الحركة */
@media (prefers-reduced-motion: reduce) {

    *,
    :before,
    :after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* عالي التباين */
@media (prefers-contrast: high) {
    :root {
        --accent: #006400;
        --accent-2: #004d00;
        --border: #000000;
    }
}

/* إمكانية الوصول */
.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;
}

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

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}