/* Import Font */
@import url("https://fonts.googleapis.com/css2?family=Almarai:wght@400;600;700;800&display=swap");

:root {
    --brand: #689048;
    --brand-dark: #085038;
    --brand-deeper: #084830;
    --brand-light: #eef3e6;
    --brand-gold: #c8a040;
    --brand-glow: rgba(104, 144, 72, 0.35);
    --text-dark: #16301f;
    --text-muted: #7a8f83;
}

* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    font-family: "Almarai", sans-serif;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow-x: hidden;
}

/* Rotating background images */
.bg-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 1s ease-in-out;
    z-index: 0;
}

/* Brand-colored overlay above the images */
.bg-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(8, 80, 56, 0.55) 0%, rgba(104, 144, 72, 0.50) 55%, rgba(200, 160, 64, 0.35) 100%);
    z-index: 1;
    pointer-events: none;
}

/* Fine grid pattern overlay */
.grid-overlay {
    position: fixed;
    inset: 0;
    z-index: 2;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 44px 44px;
    pointer-events: none;
}

/* Language switcher */
.language-switcher {
    position: fixed;
    top: 24px;
    inset-inline-end: 24px;
    z-index: 40;
}

.lang-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 50px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
    transition: all 0.3s;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-1px);
}

.flag-icon {
    width: 24px;
    height: 17px;
    border-radius: 3px;
    object-fit: cover;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.lang-btn-arrow {
    font-size: 11px;
    opacity: 0.85;
}

.lang-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-end: 0;
    min-width: 180px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    z-index: 999;
    overflow: hidden;
    padding: 8px;
}

.lang-menu.show {
    display: block;
    animation: fadeUp 0.2s ease;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.lang-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    border-radius: 9px;
    color: var(--text-dark);
    transition: background 0.15s;
}

.lang-menu a:hover {
    background: var(--brand-light);
}

.lang-menu a.is-active {
    background: #f1f6f3;
    color: var(--brand);
    cursor: default;
}

.lang-menu a.is-active .lang-menu-text {
    font-weight: 700;
}

.check-icon {
    margin-inline-start: auto;
    font-size: 12px;
    color: var(--brand);
}

/* Login card */
.login-card {
    position: relative;
    width: 440px;
    max-width: calc(100% - 40px);
    background: rgba(255, 255, 255, 0.97);
    border-radius: 24px;
    padding: 44px 42px 34px;
    box-shadow: 0 30px 80px rgba(6, 42, 26, 0.45);
    z-index: 10;
    animation: cardIn 0.5s ease;
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(24px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-card::before {
    content: "";
    position: absolute;
    top: 0;
    inset-inline-start: 50%;
    transform: translateX(-50%);
    width: 90px;
    height: 5px;
    border-radius: 0 0 6px 6px;
    background: linear-gradient(90deg, var(--brand), var(--brand-gold));
}

.brand-wrap {
    text-align: center;
    margin-bottom: 26px;
}

.brand-wrap img.logo {
    max-height: 90px;
    max-width: 220px;
    margin: 0 auto 16px;
    object-fit: contain;
    filter: drop-shadow(0 4px 12px rgba(8, 80, 56, 0.18));
}

.brand-wrap h1 {
    font-weight: 800;
    font-size: 24px;
    color: var(--text-dark);
    margin-bottom: 6px;
}

.brand-wrap p.subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0;
}

/* Alert */
.alert-error {
    display: block;
    padding: 12px 16px;
    margin-bottom: 18px;
    background: #fdecea;
    color: #b3261e;
    border: 1px solid #f5c2c0;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}

/* Form */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 6px;
}

.input-field label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-dark);
    font-weight: 700;
    font-size: 13px;
}

.input-field input {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid #dfe9e2;
    border-radius: 12px;
    font-size: 14px;
    outline: none;
    background: #fbfdfc;
    color: var(--text-dark);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.input-field input::placeholder {
    color: #a9b8af;
}

.input-field input:focus {
    border-color: var(--brand);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(104, 144, 72, 0.12);
}

.check-field {
    margin-top: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.check-field input {
    width: 17px;
    height: 17px;
    appearance: none;
    border: 1.5px solid #c9d6cd;
    border-radius: 5px;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s;
}

.check-field input::after {
    content: "\f00c";
    font-family: "Font Awesome 6 pro";
    font-size: 11px;
    color: #fff;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.check-field input:checked {
    background: var(--brand);
    border-color: var(--brand);
}

.check-field input:checked::after {
    transform: translate(-50%, -50%) scale(1);
}

.check-field label {
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

/* Button */
form button {
    margin-top: 24px;
    width: 100%;
    height: 52px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--brand) 0%, #7aa04f 100%);
    box-shadow: 0 10px 26px var(--brand-glow);
    transition: transform 0.2s, box-shadow 0.2s, filter 0.2s;
}

form button:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 32px rgba(104, 144, 72, 0.42);
    filter: brightness(1.04);
}

form button:active {
    transform: translateY(0);
    box-shadow: 0 6px 18px var(--brand-glow);
}

[dir="rtl"] .margin {
    margin-inline-end: 3px;
}

[dir="ltr"] .margin {
    margin-inline-start: 3px;
}

/* Footer */
.footer {
    margin-top: 26px;
    padding-top: 20px;
    border-top: 1px solid #eef3f0;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

.footer-logo {
    height: 18px;
    vertical-align: middle;
}

.footer a {
    color: #444444;
    font-weight: bold;
    text-decoration: none;
}

/* Responsive */
@media (max-width: 480px) {
    .login-card {
        padding: 36px 24px 26px;
    }
    .brand-wrap h1 {
        font-size: 20px;
    }
}
