:root {
    --dark-blue: #0b1a37;
    --red: #bc0404;
    --text-dark: #333333;
    --text-light: #ffffff;
    --input-border: #d1d5db;
    --error-bg: #fee2e2;
    --error-text: #b91c1c;
    --success-text: #15803d;
    --radius: 15px;
    --shadow: 0 30px 50px rgba(0, 0, 0, 0.40);
    --card-w: 800px;
    --card-h: 450px;
    --gap: 15px;
    --pad-lg: 50px;
    --pad-md: 40px;
    --pad-sm: 25px;
    --focus-ring: 0 0 0 2px rgba(188, 4, 4, 0.20);
}

/* =========================================================
   BASE
========================================================= */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Roboto', sans-serif;
    color: var(--text-dark);
}

body.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;

    background:
        linear-gradient(
            rgba(10, 25, 54, 0.50),
            rgba(134, 6, 6, 0.31)
        ),
        url('images/Background.png')
            left center / cover no-repeat;

    background-attachment: fixed;
}

body.modal-open {
    overflow: hidden;
}

button,
input,
select {
    font: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

.hidden {
    visibility: hidden;
}

/* =========================================================
   LOGIN CARD
========================================================= */

.page {
    width: var(--card-w);
    height: var(--card-h);
    max-width: 90%;
    display: flex;
    overflow: hidden;
    border-radius: var(--radius);

    background:
        linear-gradient(
            rgba(7, 34, 88, 0.50),
            rgba(134, 6, 6, 0.31)
        ),
        url('images/bg.png')
            center / cover no-repeat;

    background-blend-mode: overlay;

    box-shadow:
        4px 0 0 rgba(0, 0, 0, 0.44),
        15px 15px 0 rgba(0, 0, 0, 0.25);

    outline: 1px solid rgba(255, 255, 255, 0.05);
}

/* =========================================================
   LEFT PANEL
========================================================= */

.panel-welcome {
    flex: 1;
    padding: 80px var(--pad-lg);
    color: var(--text-light);
}

.logo-container {
    max-width: 340px;
    margin: 38px 0 0 20px;
}

.logo-container img {
    width: 100%;
    max-width: 295px;
    height: auto;
    display: block;
    margin-left: 18px;
    transform: scale(1.08);
    transform-origin: center;
}

.panel-welcome p {
    margin: 8px 0 0 58px;
    font-size: 13px;
    line-height: 1.2;
    color: #f3f3f3;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.40);
}

/* =========================================================
   RIGHT PANEL
========================================================= */

.panel-login {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;

    padding:
        var(--pad-md)
        var(--pad-md)
        var(--pad-md)
        60px;

    transform: scale(0.85);
    transform-origin: center;
    margin-top: -5px;
    margin-left: -10px;
}

.welcome-container {
    width: 100%;
    max-width: 395px;
    height: auto;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    text-align: center;
}

.welcome-container img {
    width: 100%;
    max-width: 390px;
    height: auto;
    display: block;
    transform: scale(1.18);
    transform-origin: center;
}

.panel-login h3 {
    width: 100%;
    max-width: 300px;
    margin: -20px auto 14px;
    font-size: 13px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.81);
    line-height: 1.3;
    text-align: center;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
}

.panel-login form {
    width: 100%;
    max-width: 300px;
    margin: 0;
}

/* =========================================================
   LOGIN FORM
========================================================= */

.form-group {
    width: 100%;
    margin-bottom: var(--gap);
}

.form-group label {
    display: block;
    margin: 0 0 5px;
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    color: rgba(255, 255, 255, 0.65);
}

.field {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--input-border);

    transition:
        border-color 0.2s,
        box-shadow 0.2s;
}

.field:focus-within {
    border-color: var(--red);
    box-shadow: var(--focus-ring);
}

/*
 * Scope this rule to the login panel.
 * This prevents modal password fields from inheriting
 * the white login input text and conflicting styles.
 */
.panel-login .field input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: #ffffff;
    font-size: 14px;
    padding: 2px 0;
}

.panel-login .field input::placeholder {
    color: rgba(255, 255, 255, 0.50);
}

.field-icon {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    flex-shrink: 0;
}

.field-icon svg {
    width: 20px;
    height: 20px;
    color: #888888;
    transition: color 0.2s ease;
}

.field:focus-within .field-icon svg {
    color: var(--red);
}

/* =========================================================
   PASSWORD TOGGLE
========================================================= */

.password-toggle {
    width: 24px;
    height: 24px;
    min-width: 24px;
    margin: 0 0 0 8px;
    padding: 0;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border: 0;
    background: transparent;
    cursor: pointer;

    color: var(--input-border);
    opacity: 0.75;

    transition:
        opacity 0.2s,
        color 0.2s;
}

.password-toggle:hover {
    opacity: 1;
}

.password-toggle:focus-visible {
    outline: 2px solid var(--red);
    outline-offset: 2px;
    border-radius: 4px;
}

.password-toggle svg {
    width: 20px;
    height: 20px;
    display: block;
}

.password-toggle .eye-icon {
    display: none;
}

/* =========================================================
   REMEMBER AND FORGOT PASSWORD
========================================================= */

.row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    margin: 5px 0 10px 5px;
}

.row label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.68);
    font-weight: 400;
}

.row input[type="checkbox"] {
    accent-color: var(--red);
    transform: scale(1.1);
    margin: 0;
}

.help-link {
    color: #ffffff;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid #ffffff;
}

.help-link:hover {
    opacity: 0.8;
}

/* =========================================================
   LOGIN BUTTON
========================================================= */

.btn-primary {
    width: 100%;
    max-width: 300px;
    display: block;
    margin: 0 auto 15px;
    padding: 10px 0;

    background: rgba(173, 173, 173, 0.45);
    color: #ffffff;

    border:
        2px solid
        rgba(255, 255, 255, 0.56);

    border-radius: 13px;
    font-size: 17px;
    font-weight: 500;
    letter-spacing: 0.5px;
    cursor: pointer;

    transition:
        transform 0.2s ease,
        background 0.2s ease,
        opacity 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.btn-primary:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

/* =========================================================
   REGISTER LINK
========================================================= */

.register-link {
    font-size: 13px;
    margin-top: 10px;
    text-align: center;
}

.register-link label {
    color: rgba(255, 255, 255, 0.61);
    font-weight: 500;
}

.register-link a {
    color: #ffffff;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid #ffffff;
}

.register-link a:hover {
    opacity: 0.8;
}

/* =========================================================
   ERROR BOX
========================================================= */

.error-box {
    width: 100%;
    max-width: 300px;
    margin: 0 auto 15px;
    padding: 10px;

    border-radius: 6px;
    background: var(--error-bg);
    color: var(--error-text);

    font-weight: 500;
    font-size: 13px;
    text-align: center;

    border: 1px solid #fecaca;
}

/* =========================================================
   MODALS
========================================================= */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;

    justify-content: center;
    align-items: center;

    padding: 20px;

    backdrop-filter: blur(4px);
    background: rgba(0, 0, 0, 0.35);
}

.modal-content {
    width: 90%;
    max-width: 500px;
    max-height: calc(100vh - 40px);

    border-radius: 30px;
    overflow: hidden;

    box-shadow:
        0 20px 60px
        rgba(0, 0, 0, 0.40);

    background:
        rgba(255, 255, 255, 0.46);
}

.register-modal-content {
    overflow-y: auto;
}

.role-modal-content {
    max-width: 430px;
}

.modal-header {
    background:
        linear-gradient(
            90deg,
            var(--dark-blue),
            var(--red)
        );

    color: #ffffff;
    text-align: center;
    padding: 20px 15px;
    position: relative;
}

.modal-header h2 {
    margin: 0;
    font-family:
        'Glacial Indifference',
        sans-serif;

    font-size: 20px;
    font-weight: 700;
}

.modal-header p {
    margin: 6px 0 0;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.4;
    opacity: 0.9;
}

/* =========================================================
   ROLE SELECTION
========================================================= */

.role-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
}

.role-btn {
    width: 100%;
    padding: 14px;

    border-radius: 14px;
    border: none;

    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    color: #ffffff;

    background:
        linear-gradient(
            135deg,
            rgba(12, 12, 27, 0.80),
            rgba(16, 48, 116, 0.80),
            rgba(188, 4, 4, 0.71)
        );

    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease,
        filter 0.2s ease;
}

.role-btn:hover {
    transform: translateY(-3px);
    box-shadow:
        0 12px 25px
        rgba(0, 0, 0, 0.20);
    filter: brightness(1.05);
}

.role-btn:active {
    transform: scale(0.98);
}

/* =========================================================
   MODAL FORMS
========================================================= */

#register-form,
#forgot-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--gap);

    padding: var(--pad-sm);

    background:
        rgba(238, 235, 235, 0.35);
}

#register-form label,
#forgot-form label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 2px;
}

#register-form .field-col,
#forgot-form .field-col {
    display: grid;
    gap: 6px;
}

#register-form .form-row {
    display: grid;
    gap: 6px;
}

#register-form .two-col {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/*
 * Do not apply text-field dimensions to:
 * - checkbox
 * - hidden role field
 *
 * This fixes the stretched checkbox bug.
 */
#register-form input:not([type="checkbox"]):not([type="hidden"]),
#register-form select,
#forgot-form input:not([type="checkbox"]):not([type="hidden"]) {
    width: 100%;
    min-width: 0;
    padding: 12px 15px;

    border-radius: 10px;
    border: 1px solid var(--input-border);

    background: #ffffff;
    color: var(--text-dark);

    font-size: 14px;
    outline: none;

    transition:
        border-color 0.2s,
        box-shadow 0.2s;
}

#register-form select {
    appearance: none;

    background-image:
        linear-gradient(
            45deg,
            transparent 50%,
            #6b7280 50%
        ),
        linear-gradient(
            135deg,
            #6b7280 50%,
            transparent 50%
        );

    background-position:
        calc(100% - 18px) 50%,
        calc(100% - 13px) 50%;

    background-size:
        5px 5px,
        5px 5px;

    background-repeat: no-repeat;
    padding-right: 40px;
    cursor: pointer;
}

#register-form input:not([type="checkbox"]):not([type="hidden"]):focus,
#register-form select:focus,
#forgot-form input:not([type="checkbox"]):not([type="hidden"]):focus {
    border-color: var(--red);
    box-shadow: var(--focus-ring);
}

/* =========================================================
   MODAL PASSWORD FIELDS
========================================================= */

/*
 * The border belongs to the wrapper.
 * The password input inside it has no second border.
 * This fixes the double-border CSS bug.
 */
#register-form .modal-password-wrapper {
    width: 100%;
    min-width: 0;
    padding: 0 12px;

    border-radius: 10px;
    border: 1px solid var(--input-border);

    background: #ffffff;

    transition:
        border-color 0.2s,
        box-shadow 0.2s;
}

#register-form .modal-password-wrapper:focus-within {
    border-color: var(--red);
    box-shadow: var(--focus-ring);
}

#register-form .modal-password-wrapper .password-input {
    flex: 1;
    width: 100%;
    min-width: 0;

    padding: 12px 0;

    border: 0;
    border-radius: 0;
    outline: 0;
    box-shadow: none;

    background: transparent;
    color: var(--text-dark);
}

#register-form .modal-password-wrapper .password-input:focus {
    border: 0;
    box-shadow: none;
}

#register-form .modal-password-wrapper .password-toggle {
    color: #6b7280;
    opacity: 0.75;
}

#register-form .modal-password-wrapper .password-toggle:hover {
    color: var(--red);
    opacity: 1;
}

/* =========================================================
   TERMS AND CONDITIONS
========================================================= */

#register-form .terms-row {
    display: flex;
    align-items: center;
    margin: 2px 0 0;
}

#register-form .terms-row label {
    display: inline-flex;
    align-items: center;
    gap: 7px;

    margin: 0;

    font-size: 13px;
    font-weight: 400;
    color: var(--text-dark);
    cursor: pointer;
}

#register-form input[type="checkbox"] {
    width: auto;
    height: auto;
    flex: 0 0 auto;

    margin: 0;

    accent-color: var(--red);
    transform: scale(1.05);
    cursor: pointer;
}

#tandc {
    color: var(--red);
    text-decoration: none;
    font-weight: 500;
}

#tandc:hover {
    text-decoration: underline;
}

/* =========================================================
   MODAL SUBMIT BUTTONS
========================================================= */

/*
 * Only style submit buttons.
 * Password-toggle buttons are excluded.
 */
#register-form button[type="submit"],
#forgot-form button[type="submit"] {
    width: 100%;
    padding: 12px;

    border-radius: 12px;
    border: 0;

    cursor: pointer;

    background:
        linear-gradient(
            135deg,
            #0c0c1b,
            #211f4d,
            #bc0404
        );

    color: #ffffff;
    font-weight: 700;
    font-size: 15px;

    transition:
        transform 0.2s,
        filter 0.2s,
        opacity 0.2s;
}

#register-form button[type="submit"]:hover:not(:disabled),
#forgot-form button[type="submit"]:hover:not(:disabled) {
    transform: translateY(-2px);
    filter: brightness(1.10);
}

#register-form button[type="submit"]:disabled,
#forgot-form button[type="submit"]:disabled {
    cursor: not-allowed;
    opacity: 0.65;
    transform: none;
}

/* =========================================================
   FORM MESSAGES
========================================================= */

.form-message {
    min-height: 18px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    line-height: 1.4;
}

.message-success {
    color: var(--success-text);
}

.message-error {
    color: var(--error-text);
}

/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 850px) {
    body.login-page {
        overflow-y: auto;
        padding: 20px 0;
    }

    .page {
        width: 100%;
        height: auto;
        flex-direction: column;
        max-width: 450px;
    }

    .panel-welcome {
        display: none;
    }

    .panel-login {
        padding: 30px;
        margin: 0;
        transform: none;
    }
}

@media (max-width: 520px) {
    .modal {
        padding: 12px;
    }

    .modal-content {
        width: 100%;
        max-height: calc(100vh - 24px);
    }

    #register-form .two-col {
        grid-template-columns: 1fr;
    }

    #register-form,
    #forgot-form {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .modal-content {
        border-radius: 20px;
    }

    .modal-header h2 {
        font-size: 18px;
    }

    #register-form button[type="submit"],
    #forgot-form button[type="submit"] {
        font-size: 14px;
    }

    .panel-login {
        padding: 25px 22px;
    }
}
