/* ========================================================================
   Karun Mobile Signup — branded styles  (v1.1.1 — fixes inner card, errors)
   ======================================================================== */

/* --- Page-level: hide all the default Moodle chrome that wraps our card. */
body.path-local-karunmobile {
    background: #f3f1ec;
}

body.path-local-karunmobile #page-header,
body.path-local-karunmobile #page-navbar,
body.path-local-karunmobile .navbar-brand,
body.path-local-karunmobile .breadcrumb-nav,
body.path-local-karunmobile h1.h2,
body.path-local-karunmobile .page-context-header {
    display: none !important;
}

body.path-local-karunmobile #page,
body.path-local-karunmobile #page-content,
body.path-local-karunmobile #region-main-box,
body.path-local-karunmobile #region-main,
body.path-local-karunmobile #region-main > div,
body.path-local-karunmobile [role="main"] {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

body.path-local-karunmobile #region-main .card,
body.path-local-karunmobile #region-main .card-body {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

.karunmobile-wrap {
    --km-brand: #1e3a5f;
    --km-brand-hover: #15294a;
    --km-text: #1a1a1a;
    --km-muted: #6b7280;
    --km-border: #e2e0d9;
    --km-bg-card: #ffffff;
    --km-radius: 14px;
    --km-shadow: 0 10px 35px rgba(30, 58, 95, 0.10), 0 2px 6px rgba(0, 0, 0, 0.04);
    display: flex;
    justify-content: center;
    padding: 36px 16px;
    min-height: 70vh;
}

.karunmobile-card {
    background: var(--km-bg-card);
    width: 100%;
    max-width: 460px;
    border-radius: var(--km-radius);
    box-shadow: var(--km-shadow);
    padding: 36px 32px;
    color: var(--km-text);
}

.karunmobile-header {
    text-align: center;
    margin-bottom: 24px;
}

.karunmobile-logo img {
    max-width: 80px;
    height: auto;
    margin: 0 auto 12px;
}

.karunmobile-brandname {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--km-brand);
    letter-spacing: 0.5px;
}

.karunmobile-steps {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 8px 0 20px;
}

.karunmobile-step {
    width: 28px;
    height: 4px;
    background: var(--km-border);
    border-radius: 2px;
    transition: background 0.2s ease;
}

.karunmobile-step.is-done {
    background: var(--km-brand);
    opacity: 0.55;
}

.karunmobile-step.is-active {
    background: var(--km-brand);
}

.karunmobile-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 6px 0;
    text-align: center;
    color: var(--km-text);
}

.karunmobile-subtitle {
    text-align: center;
    color: var(--km-muted);
    font-size: 0.95rem;
    margin: 0 0 22px 0;
    line-height: 1.6;
}

.karunmobile-body {
    margin-top: 8px;
}

.karunmobile-card .mform {
    background: transparent;
    padding: 0;
}

.karunmobile-card .mform .fitem {
    margin-bottom: 16px;
}

.karunmobile-card .mform .col-md-3,
.karunmobile-card .mform .col-md-9 {
    flex: 0 0 100%;
    max-width: 100%;
    padding: 0;
}

.karunmobile-card .mform label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--km-text);
    font-size: 0.92rem;
}

/* Hide the asterisk / required visuals Moodle adds next to labels. */
.karunmobile-card .mform .req,
.karunmobile-card .mform .fitem-required-indicator,
.karunmobile-card .mform .form-control-feedback-required,
.karunmobile-card .mform .invalid-feedback-required,
.karunmobile-card .mform .fitemtitle .req {
    display: none !important;
}

/* Hide the "Required" hint Moodle places below the form. */
.karunmobile-card .mform .fdescription.required,
.karunmobile-card .mform .formrequiredmarker,
.karunmobile-card .mform > fieldset > .fcontainer > .fdescription {
    display: none !important;
}

/* Hide the small red feedback icon next to the field. */
.karunmobile-card .mform .felement > .form-control-feedback,
.karunmobile-card .mform .fitem .form-control-feedback {
    display: none !important;
}

.karunmobile-card .mform input[type="text"],
.karunmobile-card .mform input[type="email"],
.karunmobile-card .mform input[type="tel"],
.karunmobile-card .mform input[type="password"] {
    width: 100%;
    height: 46px;
    padding: 8px 14px;
    border: 1.5px solid var(--km-border);
    border-radius: 10px;
    background: #fff;
    color: var(--km-text);
    font-size: 1rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
}

.karunmobile-card .mform input[type="text"]:focus,
.karunmobile-card .mform input[type="email"]:focus,
.karunmobile-card .mform input[type="password"]:focus {
    outline: none;
    border-color: var(--km-brand);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.12);
}

.karunmobile-card .mform .has-danger input,
.karunmobile-card .mform .has-error input,
.karunmobile-card .mform .is-invalid input,
.karunmobile-card .mform input.is-invalid {
    border-color: #c0392b !important;
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.10) !important;
}

.karunmobile-card .mform .form-control-feedback,
.karunmobile-card .mform .invalid-feedback,
.karunmobile-card .mform .error {
    display: block;
    color: #c0392b;
    font-size: 0.86rem;
    margin-top: 6px;
    font-weight: 500;
}

.karunmobile-card input.karunmobile-identifier-input {
    height: 52px;
    font-size: 1.05rem;
    text-align: center;
}

.karunmobile-card .mform .form-submit,
.karunmobile-card .mform input[type="submit"],
.karunmobile-card .mform button[type="submit"] {
    background: var(--km-brand);
    color: #fff;
    border: none;
    height: 48px;
    padding: 0 24px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.05s ease;
    width: 100%;
    margin: 0;
    text-transform: none;
    letter-spacing: 0.2px;
}

.karunmobile-card .mform input[type="submit"]:hover,
.karunmobile-card .mform button[type="submit"]:hover {
    background: var(--km-brand-hover);
}

.karunmobile-card .mform input[type="submit"]:active,
.karunmobile-card .mform button[type="submit"]:active {
    transform: translateY(1px);
}

.karunmobile-card .mform .btn-secondary,
.karunmobile-card .mform input[name="cancel"] {
    background: transparent;
    color: var(--km-muted);
    border: 1.5px solid var(--km-border);
    margin-top: 10px;
}

.karunmobile-card .mform .btn-secondary:hover {
    background: #f7f6f2;
    color: var(--km-text);
}

.karunmobile-card .mform .fitem.fitem_actionbuttons .felement {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.karunmobile-otp-boxes {
    display: flex;
    justify-content: center;
    gap: 10px;
    direction: ltr;
    margin: 8px 0 20px;
}

.karunmobile-otp-box {
    width: 52px;
    height: 60px;
    text-align: center;
    border: 1.5px solid var(--km-border);
    border-radius: 10px;
    background: #fff;
    font-size: 1.6rem;
    font-weight: 600;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: var(--km-text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    -moz-appearance: textfield;
}

.karunmobile-otp-box::-webkit-outer-spin-button,
.karunmobile-otp-box::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.karunmobile-otp-box:focus {
    outline: none;
    border-color: var(--km-brand);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.18);
}

.karunmobile-otp-box.is-filled {
    border-color: var(--km-brand);
    background: rgba(30, 58, 95, 0.04);
}

.karunmobile-card .has-danger .karunmobile-otp-box,
.karunmobile-card .error .karunmobile-otp-box {
    border-color: #c0392b;
}

.karunmobile-card .karunmobile-code-hidden-wrap .fitemtitle,
.karunmobile-card .karunmobile-code-hidden-wrap .col-md-3 {
    display: none;
}
.karunmobile-card .karunmobile-code-hidden-wrap input[name="code"] {
    display: none !important;
}

.karunmobile-sentto {
    text-align: center;
    color: var(--km-muted);
    font-size: 0.95rem;
    margin: 0 0 18px;
}
.karunmobile-sentto strong {
    color: var(--km-text);
    direction: ltr;
    display: inline-block;
}

.karunmobile-resend {
    text-align: center;
    margin: 16px 0 0;
    font-size: 0.92rem;
    color: var(--km-muted);
}
.karunmobile-resend a {
    color: var(--km-brand);
    font-weight: 600;
    text-decoration: none;
}
.karunmobile-resend a:hover {
    text-decoration: underline;
}
.karunmobile-resend.is-cooldown a {
    color: var(--km-muted);
    pointer-events: none;
    cursor: default;
}

.karunmobile-card .alert {
    border-radius: 10px;
    border: none;
    padding: 12px 14px;
    font-size: 0.92rem;
    margin-bottom: 16px;
}

html[dir="rtl"] .karunmobile-card,
html[dir="rtl"] .karunmobile-wrap {
    direction: rtl;
}
html[dir="rtl"] .karunmobile-otp-boxes {
    direction: ltr;
}
html[dir="rtl"] .karunmobile-card input.karunmobile-identifier-input {
    text-align: center;
}

@media (max-width: 520px) {
    .karunmobile-card {
        padding: 28px 20px;
        border-radius: 12px;
    }
    .karunmobile-otp-box {
        width: 44px;
        height: 54px;
        font-size: 1.4rem;
    }
}

/* ========================================================================
   v1.1.2 — Almond B theme override.
   Almond B wraps content in its own .main-inner / .almondb-content-card.
   Force every container inside our pages to be transparent.
   ======================================================================== */

/* Wildcard: any direct descendant of body on our pages, except our card. */
body.path-local-karunmobile > div,
body.path-local-karunmobile main,
body.path-local-karunmobile section,
body.path-local-karunmobile article {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* Common Almond B containers — drop their card-like styling on our pages. */
body.path-local-karunmobile .main-inner,
body.path-local-karunmobile .main-content,
body.path-local-karunmobile .almondb-content,
body.path-local-karunmobile .almondb-content-card,
body.path-local-karunmobile .content-wrapper,
body.path-local-karunmobile .main-wrap,
body.path-local-karunmobile .login-container,
body.path-local-karunmobile .login-wrapper,
body.path-local-karunmobile .container,
body.path-local-karunmobile .container-fluid,
body.path-local-karunmobile #maincontent,
body.path-local-karunmobile #topofscroll {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
}

/* Bootstrap card class — used widely by Almond B. */
body.path-local-karunmobile .card:not(.karunmobile-card),
body.path-local-karunmobile .card-body {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

/* The red error icon next to the field label — Moodle's "required" feedback. */
body.path-local-karunmobile .form-control-feedback-required,
body.path-local-karunmobile .invalid-feedback-required,
body.path-local-karunmobile .text-danger.req,
body.path-local-karunmobile .fitemtitle .form-control-feedback,
body.path-local-karunmobile label + .form-control-feedback,
body.path-local-karunmobile label .form-control-feedback,
body.path-local-karunmobile .icon-no-margin.text-danger,
body.path-local-karunmobile .text-danger {
    display: none !important;
}

/* ========================================================================
   v1.1.3 — embedded layout overrides
   pagelayout='embedded' in Almond B still produces a few wrappers — flatten.
   ======================================================================== */
body.pagelayout-embedded.path-local-karunmobile,
body.pagelayout-embedded.path-local-karunmobile #page,
body.pagelayout-embedded.path-local-karunmobile #page-wrapper,
body.pagelayout-embedded.path-local-karunmobile #page-content,
body.pagelayout-embedded.path-local-karunmobile #region-main,
body.pagelayout-embedded.path-local-karunmobile #region-main > div,
body.pagelayout-embedded.path-local-karunmobile [role="main"],
body.pagelayout-embedded.path-local-karunmobile main {
    background: #f3f1ec !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
}

/* ========================================================================
   v1.1.4 — embedded chrome cleanup + vertical centering + logo sizing
   ======================================================================== */

/* Embedded layout adds black bars top/bottom — remove them entirely. */
body.pagelayout-embedded.path-local-karunmobile {
    background: #f3f1ec !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 100vh;
}

html.pagelayout-embedded {
    background: #f3f1ec !important;
}

body.pagelayout-embedded.path-local-karunmobile #topofscroll,
body.pagelayout-embedded.path-local-karunmobile #page,
body.pagelayout-embedded.path-local-karunmobile #page-content {
    background: #f3f1ec !important;
    min-height: 100vh;
}

/* Vertical centering of the card. */
body.path-local-karunmobile .karunmobile-wrap {
    min-height: 100vh;
    align-items: center;     /* vertical center within the wrapper */
    padding: 20px 16px;
}

/* The Karun logo is wider than tall — let it size naturally. */
.karunmobile-logo img {
    max-width: 200px;       /* wider for the wordmark logo */
    max-height: 70px;
    width: auto;
    height: auto;
    margin: 0 auto 8px;
    display: block;
}

/* When a logo is shown, the text brand name becomes redundant — hide it. */
.karunmobile-header:has(.karunmobile-logo img) .karunmobile-brandname {
    display: none;
}

/* ========================================================================
   v1.1.5 — final polish
   ======================================================================== */

/* Hide the Moodle form's own "General" header — we already have a card title. */
.karunmobile-card .mform > fieldset > legend,
.karunmobile-card .mform fieldset.collapsible > legend,
.karunmobile-card .mform .ftoggler,
.karunmobile-card .mform legend a,
.karunmobile-card .mform legend .icons-collapse-expand,
.karunmobile-card .mform .fheader {
    display: none !important;
}

.karunmobile-card .mform fieldset {
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Hide the Cancel button — we don't want it on these single-purpose pages. */
.karunmobile-card .mform input[name="cancel"],
.karunmobile-card .mform button[name="cancel"],
.karunmobile-card .mform .btn-cancel {
    display: none !important;
}

/* Make the actionbuttons fitem use only the primary button. */
.karunmobile-card .mform .fitem_actionbuttons {
    margin-top: 8px;
}

/* The primary submit button should always look enabled regardless of form state. */
.karunmobile-card .mform input[type="submit"]:disabled,
.karunmobile-card .mform button[type="submit"]:disabled {
    background: var(--km-brand) !important;
    color: #fff !important;
    opacity: 1 !important;
    cursor: pointer !important;
}

/* Center the verify button properly. */
.karunmobile-card .mform .fitem_actionbuttons .felement {
    align-items: stretch;
}

/* ========================================================================
   v1.1.7 — match real Karun Academy login page branding
   Colors extracted from theme_almondb config:
     brandcolor #1B3764  |  backcolor #F5F2EE  |  loginimage KarunAcademyLoginBack_result.jpg
   ======================================================================== */

/* Background image (same as login page). */
body.path-local-karunmobile {
    background: #F5F2EE url('https://lms.karun-it.ir/pluginfile.php/1/theme_almondb/loginbackgroundimage/KarunAcademyLoginBack_result.jpg') center center / cover no-repeat fixed !important;
}

/* Override the brand var with the real color so everything aligns. */
.karunmobile-wrap {
    --km-brand: #1B3764 !important;
    --km-brand-hover: #142850 !important;
}

/* The card sits over the background image — give it a subtle backdrop. */
.karunmobile-card {
    background: #ffffff;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
}

/* Brand name + logo color updates. */
.karunmobile-brandname {
    color: #1B3764;
}

/* Step indicator uses real brand color. */
.karunmobile-step.is-done,
.karunmobile-step.is-active {
    background: #1B3764;
}

/* ========================================================================
   Plain HTML form (signup_complete) — Almond B's mform doesn't reach here
   ======================================================================== */
.karunmobile-plainform .fitem {
    margin-bottom: 16px;
}
.karunmobile-plainform label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #1a1a1a;
    font-size: 0.92rem;
}
.karunmobile-plainform input[type="text"],
.karunmobile-plainform input[type="password"] {
    width: 100%;
    height: 46px;
    padding: 8px 14px;
    border: 1.5px solid #e2e0d9;
    border-radius: 10px;
    background: #fff;
    color: #1a1a1a;
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.karunmobile-plainform input:focus {
    outline: none;
    border-color: #1B3764;
    box-shadow: 0 0 0 3px rgba(27, 55, 100, 0.12);
}
.karunmobile-plainform .karunmobile-submit-btn {
    background: #1B3764;
    color: #fff;
    border: none;
    height: 48px;
    width: 100%;
    border-radius: 10px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.15s ease;
}
.karunmobile-plainform .karunmobile-submit-btn:hover {
    background: #142850;
}

/* OTP code label above the boxes (plain-form verify). */
.karunmobile-verifyform .karunmobile-otplabel {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #1a1a1a;
    font-size: 0.92rem;
    text-align: center;
}
