@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700&family=Great+Vibes&family=Playfair+Display:wght@600;700&display=swap');

/* ========== Snacks ERP Login — Premium Brand Card ========== */
:root {
    --primary: #A98336;
    --primary-dark: #8A6A2A;
    --primary-deep: #7A5C24;
    --primary-light: #C49A4A;
    --bg-page: #F6F0E6;
    --bg-form: #FFFcf7;
    --dark: #2B2113;
    --muted: rgba(43, 33, 19, 0.58);
    --border: #E6D9BE;
    --white: #ffffff;
    --error-red: #c0392b;
    --success-green: #1e7e34;
    --radius-shell: 32px;
    --radius-control: 16px;
    --field-h: 56px;
    --pad-x: 18px;
    --icon-size: 20px;
    --font: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    --font-display: 'Playfair Display', 'Cairo', serif;
    --font-script: 'Great Vibes', 'Segoe Script', cursive;
    --shadow-shell: 0 28px 70px rgba(43, 33, 19, 0.12), 0 8px 20px rgba(43, 33, 19, 0.05);
    --shadow-btn: 0 10px 30px rgba(169, 131, 54, 0.28);
    --focus-ring: 0 0 0 4px rgba(169, 131, 54, 0.14);
    --ease: 250ms cubic-bezier(0.22, 1, 0.36, 1);
    --ease-fast: 180ms ease;
    --scroll-size: 8px;
    --scroll-track: rgba(234, 223, 192, 0.45);
    --scroll-thumb: #A98336;
    --scroll-thumb-hover: #8A6A2A;
}

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

html, body {
    min-height: 100%;
}

/* ========== Custom scrollbar (Snacks gold) ========== */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

*::-webkit-scrollbar {
    width: var(--scroll-size);
    height: var(--scroll-size);
}

*::-webkit-scrollbar-track {
    background: var(--scroll-track);
    border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary-light, #C49A4A) 0%, var(--scroll-thumb) 100%);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--scroll-thumb-hover);
    border: 2px solid transparent;
    background-clip: padding-box;
}

*::-webkit-scrollbar-corner {
    background: transparent;
}

body {
    font-family: var(--font);
    font-weight: 500;
    font-size: 16px;
    line-height: 1.65;
    direction: rtl;
    background: var(--bg-page);
    color: var(--dark);
    overflow-x: hidden;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    touch-action: manipulation;
}

button, input, select, textarea, a {
    font-family: inherit;
}

button {
    appearance: none;
    -webkit-appearance: none;
    background: none;
    border: none;
}

/* ========== Page backdrop ========== */
.login-page {
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1.25rem, 3vh, 2.5rem);
    animation: pageFade 0.45s ease both;
    overflow: hidden;
}

.login-page-pattern {
    position: absolute;
    inset: -4%;
    z-index: 0;
    pointer-events: none;
    background-image:
        url("/img/login/pattern-peanuts.png"),
        url("/img/login/nuts-sketches.png");
    background-size: 520px auto, 380px auto;
    background-position: 8% 20%, 92% 75%;
    background-repeat: repeat, no-repeat;
    opacity: 0.045;
    filter: invert(1) sepia(0.35) saturate(0.6) hue-rotate(5deg);
}

@keyframes pageFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ========== Centered shell ========== */
.login-shell {
    position: relative;
    z-index: 1;
    width: min(1080px, 100%);
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    direction: ltr;
    background: var(--bg-form);
    border-radius: var(--radius-shell);
    box-shadow: var(--shadow-shell);
    overflow: hidden;
    animation: shellRise 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.05s both;
    min-height: min(720px, 92vh);
}

@keyframes shellRise {
    from { opacity: 0; transform: translateY(16px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ========== Brand (left) ========== */
.login-brand {
    position: relative;
    background: linear-gradient(165deg, #C49A4A 0%, var(--primary) 40%, var(--primary-deep) 100%);
    color: var(--white);
    overflow: hidden;
    min-height: 100%;
}

.brand-inner {
    position: relative;
    z-index: 2;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: clamp(1.75rem, 3.2vh, 2.5rem) clamp(1.5rem, 2.5vw, 2.35rem);
    padding-right: clamp(2rem, 3.5vw, 3.25rem);
}

.brand-wave {
    position: absolute;
    top: 0;
    right: -1px;
    width: 72px;
    height: 100%;
    z-index: 3;
    pointer-events: none;
}

.brand-wave path {
    fill: var(--bg-form);
}

.brand-logo-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.65rem;
    margin-bottom: clamp(1.1rem, 2.2vh, 1.65rem);
}

.brand-mark {
    width: 72px;
    height: auto;
    filter: brightness(0) invert(1);
    opacity: 0.96;
}

.brand-wordmark {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
}

.brand-name {
    font-family: var(--font-display);
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.1;
}

.brand-tag {
    font-family: var(--font-script);
    font-size: 1.35rem;
    font-weight: 400;
    letter-spacing: 0.02em;
    opacity: 0.95;
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}

.brand-tag::before,
.brand-tag::after {
    content: "";
    width: 28px;
    height: 1px;
    background: rgba(255, 255, 255, 0.55);
}

.brand-copy {
    text-align: center;
    margin-bottom: clamp(0.85rem, 1.8vh, 1.25rem);
}

.brand-welcome {
    font-family: var(--font);
    font-size: 1.05rem;
    font-weight: 500;
    line-height: 1.4;
    opacity: 0.92;
    margin-bottom: 0.35rem;
}

.brand-heading {
    font-family: var(--font);
    font-size: clamp(1.9rem, 2.8vw, 2.55rem);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.55rem;
    letter-spacing: 0.02em;
}

[dir="ltr"] .brand-heading {
    font-family: var(--font);
}

.brand-lead {
    font-size: 0.95rem;
    font-weight: 400;
    line-height: 1.65;
    opacity: 0.9;
    max-width: 20rem;
    margin-inline: auto;
}

.brand-hero {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.85rem 0 0.85rem;
    min-height: 160px;
}

.brand-hero-stage {
    position: relative;
    width: min(300px, 88%);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Leaves tucked behind top-left of the bowl (like the reference shot) */
.brand-hero-leaf {
    position: absolute;
    top: -2%;
    left: -4%;
    width: 46%;
    max-width: 140px;
    height: auto;
    z-index: 2;
    pointer-events: none;
    transform: rotate(-18deg);
    /* Knock out solid black background */
    mix-blend-mode: screen;
    filter: saturate(1.05) brightness(1.05);
}

.brand-hero-img {
    position: relative;
    z-index: 1;
    width: 100%;
    height: auto;
    max-height: min(280px, 32vh);
    object-fit: contain;
    object-position: center;
    display: block;
    filter: drop-shadow(0 14px 28px rgba(43, 33, 19, 0.22));
}

.brand-features {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    margin-top: auto;
    padding-top: 0.85rem;
    align-items: stretch;
}

.brand-features li {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    text-align: center;
    gap: 0.55rem;
    padding: 0 0.55rem;
    position: relative;
}

.brand-features li:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 10%;
    bottom: 10%;
    right: 0;
    left: auto;
    width: 1px;
    background: rgba(255, 255, 255, 0.45);
}

.feature-lucide {
    width: 26px;
    height: 26px;
    color: var(--white);
    stroke-width: 1.6;
    opacity: 0.95;
}

.brand-features span {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1.35;
    opacity: 0.95;
    max-width: 7.5rem;
    text-transform: uppercase;
}

/* ========== Form side (right) ========== */
.login-form-side {
    position: relative;
    z-index: 2;
    background: var(--bg-form);
    padding: clamp(1.75rem, 3.2vh, 2.6rem) clamp(1.5rem, 2.8vw, 2.75rem);
    display: flex;
    flex-direction: column;
    direction: rtl;
    overflow-y: auto;
    max-height: 92vh;
    scrollbar-gutter: stable;
}

[dir="ltr"] .login-form-side {
    direction: ltr;
}

.language-switch {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px;
    margin-bottom: 1.15rem;
    background: rgba(169, 131, 54, 0.06);
    border: 1px solid var(--border);
    border-radius: 999px;
}

.lang-btn {
    min-height: 34px;
    padding: 0.35rem 0.95rem;
    border-radius: 999px;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: background var(--ease), color var(--ease), box-shadow var(--ease);
}

.lang-btn.active {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(169, 131, 54, 0.25);
}

.lang-btn:not(.active):hover {
    color: var(--primary);
    background: rgba(169, 131, 54, 0.1);
}

#login-form {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.form-group {
    margin-bottom: 1.05rem;
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 0.55rem;
    color: var(--dark);
    font-weight: 600;
    font-size: 0.94rem;
    line-height: 1.45;
}

.form-group input,
.form-group select {
    width: 100%;
    height: var(--field-h);
    min-height: var(--field-h);
    /* Icons always on physical left (mockup style) */
    padding: 0 var(--pad-x) 0 calc(var(--pad-x) + var(--icon-size) + 12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    background: var(--white);
    color: var(--dark);
    font-size: max(1rem, 16px);
    font-weight: 500;
    line-height: 1.5;
    transition: border-color var(--ease), box-shadow var(--ease);
    appearance: none;
    -webkit-appearance: none;
    outline: none;
    box-shadow: none;
    cursor: text;
}

.form-group select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23A98336' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--pad-x) center;
    background-size: 14px;
    padding-right: calc(var(--pad-x) + 22px);
    padding-left: calc(var(--pad-x) + var(--icon-size) + 12px);
}

.form-group input::placeholder {
    color: var(--dark);
    font-weight: 400;
    opacity: 0.7;
}

.form-group input:hover,
.form-group select:hover {
    border-color: #d4c49a;
}

.form-group input:focus,
.form-group select:focus,
.form-group.focused input,
.form-group.focused select {
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.input-icon {
    position: absolute;
    left: var(--pad-x);
    bottom: calc((var(--field-h) - var(--icon-size)) / 2);
    width: var(--icon-size);
    height: var(--icon-size);
    color: var(--primary);
    pointer-events: none;
    opacity: 0.85;
}

.password-toggle-btn {
    position: absolute;
    right: 8px;
    bottom: calc((var(--field-h) - 36px) / 2);
    z-index: 2;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    cursor: pointer;
    border-radius: 10px;
    transition: background var(--ease-fast), color var(--ease-fast);
}

.password-toggle-btn:hover {
    background: rgba(169, 131, 54, 0.1);
    color: var(--primary-dark);
}

.password-toggle-btn svg {
    width: var(--icon-size);
    height: var(--icon-size);
}

/* Password: lock left + eye right */
.form-group:has(.password-toggle-btn) input {
    padding-left: calc(var(--pad-x) + var(--icon-size) + 12px);
    padding-right: calc(var(--pad-x) + var(--icon-size) + 18px);
}

.form-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0.1rem 0 1.25rem;
    flex-wrap: wrap;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.remember-me input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 1.5px solid #d4c49a;
    border-radius: 5px;
    background: var(--white);
    cursor: pointer;
    transition: background var(--ease-fast), border-color var(--ease-fast);
}

.remember-me input[type="checkbox"]:checked {
    background: var(--primary);
    border-color: var(--primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 12px;
}

.remember-me label {
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    margin: 0;
}

.forgot-password a {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color var(--ease-fast);
}

.forgot-password a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.forgot-password--solo {
    text-align: center;
    margin-bottom: 1rem;
}

.login-btn {
    width: 100%;
    height: 58px;
    border-radius: var(--radius-control);
    background: var(--primary);
    color: var(--white);
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-btn);
    transition: transform var(--ease), box-shadow var(--ease), background var(--ease);
}

.login-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 14px 34px rgba(169, 131, 54, 0.36);
}

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

.form-divider {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin: 1rem 0;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.08em;
}

.form-divider::before,
.form-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.settings-entry-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    width: 100%;
    height: 54px;
    border-radius: var(--radius-control);
    border: 1.5px solid var(--primary);
    color: var(--primary);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 600;
    background: transparent;
    transition: background var(--ease), color var(--ease), transform var(--ease);
}

.settings-leaf {
    width: 22px;
    height: 22px;
    object-fit: contain;
    mix-blend-mode: darken;
}

.settings-entry-link:hover {
    background: var(--primary);
    color: var(--white);
    transform: translateY(-1px);
}

.settings-entry-link:hover .settings-leaf {
    filter: brightness(0) invert(1);
    mix-blend-mode: normal;
}

.login-footer {
    margin-top: auto;
    padding-top: 1.35rem;
    text-align: center;
}

.footer-leaf {
    width: 28px;
    height: 28px;
    object-fit: contain;
    margin-bottom: 0.35rem;
    opacity: 0.95;
    mix-blend-mode: darken;
}

.footer-title {
    font-family: var(--font);
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--dark);
    line-height: 1.4;
}

[dir="ltr"] .footer-title {
    font-family: var(--font-display);
}

.footer-sub {
    font-size: 0.82rem;
    font-weight: 400;
    color: var(--muted);
    margin-top: 0.15rem;
}

.settings-login-heading {
    text-align: center;
    margin: 0 0 1.15rem;
}

.settings-login-heading h2 {
    font-family: var(--font);
    font-size: 1.55rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
}

[dir="ltr"] .settings-login-heading h2 {
    font-family: var(--font-display);
}

.settings-login-heading p {
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 400;
}

/* ========== Feedback ========== */
.error-message,
.success-message,
.location-hint {
    padding: 0.85rem 1rem;
    border-radius: 14px;
    margin-bottom: 1rem;
    text-align: center;
    font-size: 0.88rem;
    font-weight: 500;
    line-height: 1.5;
}

.error-message {
    background: rgba(192, 57, 43, 0.07);
    border: 1px solid rgba(192, 57, 43, 0.25);
    color: var(--error-red);
}

.error-message.access-ended,
.location-hint {
    background: rgba(169, 131, 54, 0.08);
    border: 1px solid rgba(169, 131, 54, 0.28);
    color: var(--primary-dark);
}

.success-message {
    background: rgba(30, 126, 52, 0.08);
    border: 1px solid rgba(30, 126, 52, 0.25);
    color: var(--success-green);
}

.text-danger {
    color: var(--error-red);
    font-size: 0.8rem;
    display: block;
    margin-top: 0.35rem;
}

.otp-input {
    text-align: center !important;
    font-size: 1.3rem !important;
    font-weight: 600 !important;
    letter-spacing: 0.3em;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
}

.otp-hint {
    display: block;
    margin-top: 0.45rem;
    color: var(--muted);
    font-size: 0.82rem;
}

/* ========== Responsive ========== */
@media (max-height: 860px) {
    .brand-hero {
        min-height: 120px;
        padding: 0.45rem 0 0.45rem;
    }

    .brand-hero-stage {
        width: min(240px, 82%);
    }

    .brand-hero-leaf {
        width: 44%;
        max-width: 110px;
        top: -4%;
        left: -2%;
    }

    .brand-hero-img {
        max-height: min(200px, 26vh);
    }

    .form-group {
        margin-bottom: 0.85rem;
    }

    .login-shell {
        min-height: auto;
    }
}

@media (max-width: 960px) {
    .login-shell {
        grid-template-columns: 1fr;
        max-width: 480px;
        min-height: auto;
    }

    .login-brand {
        display: none;
    }

    .login-form-side {
        max-height: none;
        padding: 1.75rem 1.35rem;
    }

    .login-page-pattern {
        opacity: 0.06;
    }
}

@media (max-width: 480px) {
    .login-page {
        padding: 0.75rem;
    }

    .login-shell {
        border-radius: 22px;
    }

    .form-meta-row {
        flex-direction: column;
        align-items: flex-start;
    }
}
