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

/* تبديل سلس بين الشاشات — opacity بدل display:none لتفادي الوميض */
.portal-view {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    width: 100%;
    max-width: 100%;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.34s cubic-bezier(0.4, 0, 0.2, 1),
        visibility 0.34s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.34s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translate3d(0, 12px, 0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.portal-view--active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    z-index: 500;
    transform: translate3d(0, 0, 0);
}

@media (prefers-reduced-motion: reduce) {
    .portal-view {
        transition: opacity 0.18s ease;
        transform: none;
    }
    .portal-view--active {
        transform: none;
    }
}

html, body {
    font-family: 'Tajawal', sans-serif;
    background: var(--dp-page);
    height: 100vh;
    height: 100dvh;
    color: var(--dp-text);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
}

/* Intro Screen Styles */
#intro-screen {
    background: var(--dp-page);
}

.header-wrapper {
    position: relative;
    margin-bottom: 40px; /* Increased to allow space for the bottom curves */
    z-index: 30;
    flex-shrink: 0;
}

.top-section {
    background: var(--dp-primary);
    height: 34vh;
    min-height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding: calc(env(safe-area-inset-top, 0px) + 52px) 22px 40px;
    position: relative;
    border-radius: 0 0 50% 50% / 0 0 20% 20%;
    z-index: 3;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}

.hero-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 340px;
    text-align: center;
}

.top-section::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: -5%;
    right: -5%;
    height: 100%;
    background: var(--dp-primary);
    opacity: 0.4;
    border-radius: 0 0 50% 50% / 0 0 20% 20%;
    z-index: -1;
}

.top-section::before {
    content: '';
    position: absolute;
    bottom: -30px;
    left: -10%;
    right: -10%;
    height: 100%;
    background: var(--dp-primary);
    opacity: 0.15;
    border-radius: 0 0 50% 50% / 0 0 20% 20%;
    z-index: -2;
}

.logo-text {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--dp-on-primary, #000);
    text-align: center;
    padding: 0 20px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* نص عادي: SVG textPath يكسر الربط والاتجاه في العربية على الجوال */
.welcome-text {
    width: 100%;
    max-width: 320px;
    margin-top: 10px;
    padding: 0 12px;
    color: var(--dp-on-primary, #fff);
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.55;
    text-align: center;
    direction: rtl;
    unicode-bidi: isolate;
    font-feature-settings: "kern" 1;
    /* انحناء بصري خفيف يقترب من شكل الموجة دون كسر الحروف */
    transform: perspective(420px) rotateX(5deg);
    transform-origin: center top;
}

.bottom-section {
    flex: 1;
    background: var(--dp-page);
    padding: 0 24px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 10;
    position: relative;
    overflow-y: auto;
}

.heading {
    font-size: 1.5rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 12px;
    color: var(--dp-text);
}

.subheading {
    text-align: center;
    color: var(--dp-muted);
    font-size: 0.95rem;
    margin-bottom: 30px;
    line-height: 1.6;
}

.buttons-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 10px;
    width: 100%;
    max-width: 400px;
}

.btn {
    width: 100%; padding: 15px; border: none; border-radius: 14px; font-family: inherit; font-weight: 800;
    font-size: 1.1rem; cursor: pointer; text-align: center; text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.3s;
    display: flex; justify-content: center; align-items: center;
}

.btn-primary {
    background: var(--dp-primary); color: var(--dp-on-primary, #000);
    box-shadow: 0 6px 20px var(--dp-primary-glow);
}

.btn-primary:active { transform: scale(0.98); }

.btn-outline {
    background: transparent;
    color: var(--dp-text);
    border: 2px solid var(--dp-line);
}

.btn-outline:active { transform: scale(0.98); background: #f8fafc; }

/* General Button Styles */
.btn-continue {
    width: 100%; padding: 16px; border: none; border-radius: 50px; font-family: inherit; font-weight: 800;
    font-size: 1.1rem; cursor: pointer; text-align: center; text-decoration: none;
    transition: all 0.3s;
    background: #e2e8f0;
    color: #64748b;
}
.btn-continue.active {
    background: #1e293b; /* Dark like the design */
    color: #fff;
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}
.btn-continue.active:active { transform: scale(0.98); }

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    margin: -10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0f172a;
}

/* Login Screen Styles — طبقة ثابتة بيضاء تغطي كامل الشاشة بما فيها شريط الحالة */
#login-screen {
    background: #fff;
    padding: calc(env(safe-area-inset-top, 0px) + 8px) max(24px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(24px, env(safe-area-inset-left, 0px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.login-header {
    display: flex;
    justify-content: flex-start;
    padding-top: 8px;
    margin-bottom: 30px;
}

.login-title {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 40px;
    color: #000;
}

.form-container-login {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.field { margin-bottom: 18px; position: relative; }

input[type="text"], input[type="password"], input[type="tel"] {
    width: 100%; padding: 16px 18px; border-radius: 12px; border: 1px solid #cbd5e1;
    background: #fff; color: var(--dp-text); font-family: inherit; font-size: 1.05rem;
    transition: all 0.3s;
}

input:focus { outline: none; border-color: var(--dp-primary); box-shadow: 0 0 0 3px var(--dp-primary-soft); }

.password-field input {
    padding-left: 50px;
}

.toggle-password {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
}

.forgot-password {
    text-align: left;
    margin-top: -5px;
    margin-bottom: 40px;
}

.forgot-password a {
    color: #6d4c41;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 700;
}

.login-footer {
    margin-top: auto;
    padding-top: 40px;
    padding-bottom: 20px;
    transform: translateY(calc(-1 * var(--portal-keyboard-offset, 0px)));
    transition: transform 0.2s ease;
}

.alert { padding: 14px 16px; border-radius: 14px; margin-bottom: 20px; font-size: 0.9rem; text-align: right; width: 100%; font-weight: 600; }
.alert-err { background: rgba(239, 68, 68, 0.1); color: #b91c1c; border: 1px solid rgba(239, 68, 68, 0.2); }
.alert-ok { background: var(--dp-success-soft); color: var(--dp-success); border: 1px solid var(--dp-success); }


/* Signup Screen Styles */
#signup-screen {
    background: #fff;
    padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
    overflow: hidden;
}

.signup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #f1f5f9;
    background: #fff;
}

.signup-header h3 {
    font-size: 1.2rem;
    font-weight: 800;
    color: #0f172a;
    margin: 0;
}

.progress-container {
    width: 100%;
    height: 6px;
    background: #f1f5f9;
}

.progress-bar {
    height: 100%;
    background: #0f172a;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 0 4px 4px 0;
}

.signup-body {
    flex: 1;
    padding: 30px 24px;
    padding-bottom: calc(120px + var(--portal-keyboard-offset, 0px));
    overflow-y: auto;
    background: #f8fafc;
}

#ajax-signup-form {
    max-width: 400px;
    margin: 0 auto;
    height: 100%;
}

.step-heading {
    font-size: 1.15rem;
    font-weight: 700;
    color: #334155;
    margin-bottom: 30px;
    text-align: right;
}

.field-hint {
    margin-top: 8px;
    color: #64748b;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: right;
}

.file-upload-box {
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fff;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    transition: all 0.2s;
    margin-top: 20px;
}

.file-upload-box:active {
    background: #f1f5f9;
}

.file-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.file-placeholder p {
    color: #64748b;
    font-size: 1rem;
    font-weight: 600;
    margin-top: 10px;
}

#signup-screen .signup-footer,
#signup-success .signup-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 20px 24px 30px;
    background: #fff;
    border-top: 1px solid #f1f5f9;
    display: flex;
    justify-content: center;
    z-index: 550;
    transform: translateY(calc(-1 * var(--portal-keyboard-offset, 0px)));
    transition: transform 0.2s ease;
}

#signup-success .signup-footer {
    border-top: none;
    background: transparent;
}

#signup-screen .signup-footer .btn-continue,
#signup-success .signup-footer .btn-continue {
    width: 100%;
    max-width: 400px;
}

.signup-vehicle-field {
    margin-top: 4px;
    margin-bottom: 18px;
}

.signup-vehicle-label {
    font-size: 1.02rem;
    font-weight: 800;
    color: #0f172a;
    margin: 0 0 4px;
}

.signup-vehicle-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.signup-vehicle-opt {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1.5px solid #e2e8f0;
    background: #fff;
    color: #0f172a;
    font-family: inherit;
    text-align: right;
    cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.signup-vehicle-opt__name {
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.3;
}

.signup-vehicle-opt__sub {
    font-size: 0.8rem;
    font-weight: 600;
    color: #64748b;
}

.signup-vehicle-opt.is-selected {
    border-color: #1e293b;
    background: #f8fafc;
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.signup-vehicle-opt:active {
    transform: scale(0.99);
}

/* Bottom Sheet */
.sheet-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 1000;
    display: none;
    flex-direction: column;
    justify-content: flex-end;
}

.sheet-backdrop {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s;
}

.sheet-content {
    position: relative;
    background: #fff;
    border-radius: 24px 24px 0 0;
    padding: 30px 24px;
    animation: slideUp 0.3s;
    z-index: 1001;
    max-height: 90vh;
    overflow-y: auto;
}

.sheet-title {
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 24px;
    color: #0f172a;
}

.sheet-instructions {
    list-style: none;
    padding: 0;
    margin-bottom: 30px;
}

.sheet-instructions li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    color: #0f172a;
    font-size: 0.95rem;
    font-weight: 600;
    padding-bottom: 16px;
    border-bottom: 1px solid #f1f5f9;
    line-height: 1.5;
}

.sheet-instructions li:last-child {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.sheet-instructions svg {
    flex-shrink: 0;
    margin-top: 2px;
}

.sheet-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-sheet {
    width: 100%;
    padding: 16px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: none;
    transition: transform 0.1s;
}

.btn-sheet:active { transform: scale(0.98); }
.btn-dark { background: #1e293b; color: #fff; }
.btn-light { background: #f1f5f9; color: #0f172a; }
.btn-text { background: transparent; color: #475569; font-size: 1.05rem; }

/* Success Screen */
#signup-success {
    background: #fff;
    padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
}

#signup-success.portal-view--active {
    z-index: 520;
}

.success-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 40px 110px;
    background: #f8fafc;
}

.success-illustration {
    margin-bottom: 30px;
}

.success-text {
    font-size: 1.4rem;
    font-weight: 800;
    color: #0f172a;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
