:root {
    --portal-brand: #d2602e;
    --portal-brand-dark: #b84f22;
    --portal-brand-light: #e87a4a;
    --portal-bg-1: #1a1a1f;
    --portal-bg-2: #2a2420;
    --portal-card: #ffffff;
    --portal-muted: #6b7280;
    --portal-border: #e5e7eb;
    --portal-danger: #dc2626;
    --portal-radius: 16px;
    --portal-shadow: 0 20px 40px rgba(0, 0, 0, 0.28);
    --portal-safe-top: env(safe-area-inset-top, 0px);
    --portal-safe-bottom: env(safe-area-inset-bottom, 0px);
    --portal-safe-left: env(safe-area-inset-left, 0px);
    --portal-safe-right: env(safe-area-inset-right, 0px);
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

html,
body.portal-login-body {
    min-height: 100%;
    margin: 0;
}

body.portal-login-body {
    font-family: 'Cairo', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(160deg, var(--portal-bg-1) 0%, var(--portal-bg-2) 50%, #1f1814 100%);
    color: #111827;
    -webkit-font-smoothing: antialiased;
}

body.portal-login-body.rtl {
    direction: rtl;
}

.portal-login-wrap {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(1rem + var(--portal-safe-top)) calc(1rem + var(--portal-safe-right)) calc(1rem + var(--portal-safe-bottom)) calc(1rem + var(--portal-safe-left));
    position: relative;
    overflow-x: hidden;
}

.portal-login-wrap::before {
    content: '';
    position: absolute;
    width: min(520px, 100vw);
    height: min(520px, 100vw);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(210, 96, 46, 0.18) 0%, transparent 70%);
    top: -100px;
    right: -60px;
    pointer-events: none;
}

.portal-login-top {
    position: absolute;
    top: calc(0.75rem + var(--portal-safe-top));
    left: calc(0.75rem + var(--portal-safe-left));
    right: calc(0.75rem + var(--portal-safe-right));
    display: flex;
    align-items: center;
    justify-content: flex-end;
    z-index: 2;
}

.portal-login-lang a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: 0.8125rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
    min-height: 36px;
    transition: background 0.2s, border-color 0.2s;
}

.portal-login-lang a:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

.portal-login-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 400px;
    background: var(--portal-card);
    border-radius: var(--portal-radius);
    box-shadow: var(--portal-shadow);
    overflow: hidden;
}

.portal-login-brand {
    text-align: center;
    padding: 1.75rem 1.25rem 1rem;
    background: #fff;
    border-bottom: 1px solid var(--portal-border);
}

.portal-login-logo-circle {
    width: 120px;
    height: 120px;
    margin: 0 auto 0.85rem;
    border-radius: 50%;
    overflow: hidden;
    background: #fff;
    border: 3px solid rgba(210, 96, 46, 0.25);
    box-shadow: 0 8px 24px rgba(210, 96, 46, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem;
}

.portal-login-logo-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.portal-login-subtitle {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--portal-muted);
}

.portal-login-form {
    padding: 1.25rem 1.25rem 1.5rem;
}

.portal-alert {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--portal-danger);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.portal-field {
    margin-bottom: 1rem;
}

.portal-field label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.4rem;
}

.portal-field-hint {
    font-weight: 400;
    color: var(--portal-muted);
}

.portal-autofill-trap {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.portal-phone-row {
    display: flex;
    flex-direction: row;
    direction: ltr;
    align-items: stretch;
    border: 1px solid var(--portal-border);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    min-height: 48px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.portal-phone-row:focus-within {
    border-color: var(--portal-brand);
    box-shadow: 0 0 0 3px rgba(210, 96, 46, 0.2);
}

.portal-phone-prefix {
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
    background: #f9fafb;
    color: #4b5563;
    font-size: 1rem;
    font-weight: 600;
    border-right: 1px solid var(--portal-border);
    white-space: nowrap;
    user-select: none;
    flex-shrink: 0;
    order: 0;
}

.portal-phone-row input,
.portal-password-wrap input {
    font-size: 16px;
}

.portal-phone-row input {
    flex: 1;
    border: 0;
    padding: 0.75rem 0.85rem;
    letter-spacing: 0.05em;
    outline: none;
    min-width: 0;
    background: transparent;
    width: 100%;
    direction: ltr;
    text-align: left;
    order: 1;
}

.portal-text-input {
    width: 100%;
    border: 1px solid var(--portal-border);
    border-radius: 12px;
    padding: 0.75rem 0.85rem;
    outline: none;
    min-height: 48px;
    font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.portal-text-input:focus {
    border-color: var(--portal-brand);
    box-shadow: 0 0 0 3px rgba(210, 96, 46, 0.2);
}

.portal-password-wrap {
    position: relative;
}

.portal-password-wrap input {
    width: 100%;
    border: 1px solid var(--portal-border);
    border-radius: 12px;
    padding: 0.75rem 2.75rem 0.75rem 0.85rem;
    outline: none;
    min-height: 48px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

body.portal-login-body.rtl .portal-password-wrap input {
    padding: 0.75rem 0.85rem 0.75rem 2.75rem;
}

.portal-password-wrap input:focus {
    border-color: var(--portal-brand);
    box-shadow: 0 0 0 3px rgba(210, 96, 46, 0.2);
}

.portal-toggle-pw {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    inset-inline-end: 0.5rem;
    border: 0;
    background: transparent;
    color: var(--portal-muted);
    cursor: pointer;
    padding: 0.5rem;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.portal-toggle-pw:hover {
    color: var(--portal-brand);
}

.portal-remember {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.15rem 0 1.1rem;
    font-size: 0.875rem;
    color: #4b5563;
    cursor: pointer;
    min-height: 44px;
}

.portal-remember input {
    width: 1.125rem;
    height: 1.125rem;
    accent-color: var(--portal-brand);
    flex-shrink: 0;
}

.portal-submit {
    width: 100%;
    border: 0;
    border-radius: 12px;
    padding: 0.95rem 1rem;
    font-size: 1.0625rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--portal-brand) 0%, var(--portal-brand-dark) 100%);
    cursor: pointer;
    min-height: 52px;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
    box-shadow: 0 8px 20px rgba(210, 96, 46, 0.35);
}

.portal-submit:hover {
    filter: brightness(1.05);
}

.portal-submit:active {
    transform: scale(0.98);
}

.portal-alt-login {
    text-align: center;
    margin: 0.85rem 0 0;
    padding: 0;
    font-size: 0.8125rem;
}

.portal-alt-login a {
    color: var(--portal-brand);
    text-decoration: none;
    font-weight: 600;
    padding: 0.35rem 0.5rem;
    display: inline-block;
    min-height: 36px;
    line-height: 1.6;
}

.portal-alt-login a:hover {
    color: var(--portal-brand-dark);
    text-decoration: underline;
}

.portal-footer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--portal-muted);
    margin-top: 0.85rem;
    line-height: 1.5;
    padding-bottom: 0.15rem;
}

@media (max-width: 380px) {
    .portal-login-logo-circle {
        width: 100px;
        height: 100px;
        padding: 0.5rem;
    }

    .portal-login-form {
        padding: 1rem 1rem 1.25rem;
    }

    .portal-login-brand {
        padding: 1.25rem 1rem 0.85rem;
    }
}

@media (max-height: 520px) and (orientation: landscape) {
    .portal-login-wrap {
        align-items: flex-start;
        padding-top: calc(3.5rem + var(--portal-safe-top));
    }

    .portal-login-logo-circle {
        width: 72px;
        height: 72px;
        margin-bottom: 0.35rem;
        padding: 0.4rem;
    }

    .portal-login-brand {
        padding: 0.85rem 1rem 0.5rem;
    }

    .portal-login-form {
        padding: 0.85rem 1.25rem 1rem;
    }

    .portal-field {
        margin-bottom: 0.65rem;
    }
}
