/* ====================================
   BASE RESET
   ==================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    height: 100%;
    width: 100%;
    overflow: hidden;
    scroll-behavior: smooth;
}

/* ====================================
   BODY & PAGE LAYOUT
   ==================================== */
body {
    font-family: 'Poppins', sans-serif;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
    position: relative;
    overflow: hidden;
    margin: 0;
}

/* ====================================
   LOGIN CARD / CONTAINER
   ==================================== */
.container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-width: 420px;
    padding: 40px;
    position: relative;
    z-index: 1;
    animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-24px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ====================================
   TABS
   ==================================== */
.tab {
    display: flex;
    gap: 0;
    margin-bottom: 30px;
    background: #f5f5f5;
    border-radius: 12px;
    padding: 5px;
}

.tab button {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-radius: 10px;
    font-family: 'Poppins', sans-serif;
    font-size: 15px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab button.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.tab button:hover:not(.active) {
    color: #667eea;
}

/* ====================================
   FORMS
   ==================================== */
form {
    display: none;
}

form.active {
    display: block;
    animation: fadeIn 0.35s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(-8px); }
    to   { opacity: 1; transform: translateX(0); }
}

h2 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 25px;
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ====================================
   INPUTS
   ==================================== */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="date"]
{
    width: 100%;
    padding: 14px 18px;
    margin-bottom: 16px;
    border: 2px solid #e8e8e8;
    border-radius: 12px;
    font-family: 'Poppins', sans-serif;
    font-size: 16px; /* 16px prevents iOS auto-zoom */
    color: #333;
    background: #f9f9f9;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
    outline: none;
    box-sizing: border-box;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="date"]:focus
{
    border-color: #667eea;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

input[type="text"]::placeholder,
input[type="password"]::placeholder,
input[type="email"]::placeholder,
input[type="tel"]::placeholder,
input[type="date"]::placeholder
{
    color: #aaa;
}

/* ====================================
   SUBMIT BUTTON
   ==================================== */
button[type="submit"] {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-family: 'Poppins', sans-serif;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    margin-top: 10px;
    min-height: 48px;
}

button[type="submit"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

button[type="submit"]:active {
    transform: translateY(0);
}

/* ====================================
   LINKS
   ==================================== */
a {
    color: #667eea;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.3s ease;
    display: inline-block;
    margin-top: 15px;
}

a:hover {
    color: #764ba2;
    text-decoration: underline;
}

/* ====================================
   ALERTS
   ==================================== */
.error {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: #fff;
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    animation: shake 0.5s ease-in-out;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.success {
    background: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%);
    color: #fff;
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    animation: slideDown 0.5s ease-out;
    box-shadow: 0 4px 15px rgba(86, 171, 47, 0.3);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%       { transform: translateX(-10px); }
    75%       { transform: translateX(10px); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ====================================
   ACCESSIBILITY
   ==================================== */
*:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

button:focus-visible {
    outline-offset: 4px;
}

/* ====================================
   LOGIN PAGE — MOBILE RESPONSIVE
   ==================================== */

@media (max-width: 480px) {
    body {
        padding: 16px;
    }

    .container {
        padding: 28px 20px;
        border-radius: 16px;
        max-width: 100%;
    }

    h2 {
        font-size: 22px;
        margin-bottom: 18px;
    }

    .tab {
        margin-bottom: 22px;
        padding: 4px;
        border-radius: 10px;
    }

    .tab button {
        font-size: 13px;
        padding: 10px 12px;
        border-radius: 8px;
    }

    input[type="text"],
    input[type="password"],
    input[type="email"] {
        padding: 12px 14px;
        margin-bottom: 12px;
        border-radius: 10px;
    }

    button[type="submit"] {
        padding: 13px;
        font-size: 15px;
        border-radius: 10px;
    }

    .error,
    .success {
        padding: 10px 13px;
        font-size: 13px;
        margin-bottom: 16px;
    }

    a {
        font-size: 13px;
        margin-top: 12px;
    }
}

@media (max-width: 360px) {
    body {
        padding: 12px;
    }

    .container {
        padding: 22px 16px;
        border-radius: 14px;
    }

    h2 {
        font-size: 20px;
        margin-bottom: 16px;
    }

    .tab button {
        font-size: 12px;
        padding: 9px 10px;
    }

    input[type="text"],
    input[type="password"],
    input[type="email"] {
        padding: 11px 12px;
        margin-bottom: 10px;
    }

    button[type="submit"] {
        padding: 12px;
        font-size: 14px;
    }
}

/* Disable hover lifts on touch screens */
@media (hover: none) and (pointer: coarse) {
    button[type="submit"]:hover {
        transform: none;
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    }

    a:hover {
        text-decoration: none;
    }

    .tab button:hover:not(.active) {
        color: #666;
    }
}

/* Landscape on small screens — allow the page to scroll */
@media (max-width: 768px) and (orientation: landscape) {
    html, body {
        overflow-y: auto;
        height: auto;
    }

    body {
        padding: 12px 16px;
        align-items: flex-start;
    }

    .container {
        margin: 10px auto;
        padding: 22px 24px;
    }

    h2 {
        font-size: 20px;
        margin-bottom: 14px;
    }

    .tab { margin-bottom: 16px; }

    input[type="text"],
    input[type="password"],
    input[type="email"] {
        margin-bottom: 10px;
        padding: 10px 14px;
    }

    button[type="submit"] {
        margin-top: 6px;
        padding: 11px;
    }
}

/* Notched devices (iPhone X+) */
@supports (padding: env(safe-area-inset-top)) {
    body {
        padding-left:  max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ====================================
   RESET PASSWORD MODAL
   ==================================== */

.rm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.rm-overlay.rm-overlay-active {
    display: flex;
    animation: rmFadeIn 0.25s ease;
}

@keyframes rmFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.rm-modal {
    background: #ffffff;
    border-radius: 24px;
    width: 100%;
    max-width: 400px;
    /* overflow-y auto (NOT hidden) so modal can scroll on small screens */
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100dvh - 40px);
    position: relative;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.18),
        0 0 0 1px rgba(102, 126, 234, 0.08);
    animation: rmSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
}

@keyframes rmSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Top gradient accent bar */
.rm-accent-bar {
    height: 4px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
}

/* Close button */
.rm-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    background: #f5f5f5;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    color: #888;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.2s, color 0.2s;
    z-index: 2;
}
.rm-close:hover { background: #ebebeb; color: #333; }

/* Modal body */
.rm-body {
    padding: 32px 32px 28px;
}

/* Step visibility */
.rm-step-active { display: block; animation: rmStepIn 0.3s ease; }
.rm-step-hidden { display: none; }

@keyframes rmStepIn {
    from { opacity: 0; transform: translateX(10px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Icon */
.rm-icon {
    font-size: 28px;
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, rgba(102,126,234,0.12), rgba(118,75,162,0.08));
    border: 1.5px solid rgba(102,126,234,0.2);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
}

/* Title */
.rm-title {
    font-family: 'Poppins', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 6px;
    background: none;
    -webkit-text-fill-color: #1a1a2e;
    text-align: left;
}

/* Subtitle */
.rm-subtitle {
    font-size: 13.5px;
    color: #777;
    line-height: 1.55;
    margin-bottom: 22px;
}
.rm-subtitle strong { color: #444; font-weight: 600; }

/* Progress dots */
.rm-steps-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 22px;
}
.rm-dot {
    height: 4px;
    border-radius: 2px;
    transition: all 0.35s ease;
}
.rm-dot-done    { background: #4ade80; width: 20px; }
.rm-dot-active  { background: linear-gradient(90deg, #667eea, #764ba2); width: 28px; }
.rm-dot-pending { background: #e5e5e5; width: 12px; }

/* Alert banners */
.rm-alert {
    border-radius: 10px;
    padding: 11px 14px;
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: rmAlertIn 0.3s ease;
}
@keyframes rmAlertIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.rm-alert-error   { background: rgba(248, 113, 113, 0.1); border: 1px solid rgba(248,113,113,0.3); color: #c0392b; }
.rm-alert-success { background: rgba(74, 222, 128, 0.1); border: 1px solid rgba(74,222,128,0.3); color: #1e8449; }

/* Override global form { display: none } inside modal */
.rm-body form {
    display: block !important;
}

/* Input label */
.rm-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: #999;
    margin-bottom: 7px;
}

/* Modal input field */
.rm-input {
    width: 100%;
    padding: 13px 16px;
    margin-bottom: 0;
    border: 2px solid #ebebeb;
    border-radius: 12px;
    font-family: 'Poppins', sans-serif;
    font-size: 16px;
    color: #333;
    background: #fafafa;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}
.rm-input:focus {
    border-color: #667eea;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(102,126,234,0.1);
}
.rm-input::placeholder { color: #bbb; }

/* OTP input */
.rm-otp-input {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 8px;
    text-align: center;
}

/* Input group */
.rm-input-group { margin-bottom: 14px; }

/* Password toggle */
.rm-toggle-pass {
    position: absolute;
    right: 14px;
    bottom: 14px;
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}
.rm-toggle-pass:hover { color: #555; }

/* Password strength bar */
.rm-strength-bar {
    display: flex;
    gap: 4px;
    margin-top: 8px;
}
.rm-seg {
    height: 3px;
    flex: 1;
    border-radius: 2px;
    background: #ebebeb;
    transition: background 0.3s;
}
.rm-strength-label {
    font-size: 11px;
    color: #aaa;
    text-align: right;
    margin-top: 4px;
    min-height: 16px;
    transition: color 0.3s;
}

/* Primary button */
.rm-btn-primary {
    width: 100%;
    padding: 13px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-family: 'Poppins', sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.35);
    min-height: 48px;
}
.rm-btn-primary:hover  { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(102,126,234,0.45); }
.rm-btn-primary:active { transform: translateY(0); }

/* Ghost button */
.rm-btn-ghost {
    background: none;
    border: none;
    color: #999;
    font-family: 'Poppins', sans-serif;
    font-size: 13px;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s;
}
.rm-btn-ghost:hover { color: #667eea; }

/* Footer row */
.rm-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 18px;
}
.rm-muted-text { font-size: 13px; color: #aaa; }

/* Success view */
.rm-success-view { text-align: center; padding: 4px 0; }
.rm-success-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, rgba(74,222,128,0.15), rgba(74,222,128,0.05));
    border: 1.5px solid rgba(74,222,128,0.35);
    border-radius: 50%;
    font-size: 26px;
    color: #27ae60;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 18px;
    animation: rmPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes rmPop {
    from { transform: scale(0.4); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}
.rm-success-view .rm-title { text-align: center; }

/* ====================================
   MODAL — MOBILE RESPONSIVE
   ==================================== */

@media (max-width: 768px) {
    .rm-overlay {
        padding: 16px;
        align-items: center;
    }

    .rm-modal {
        max-width: 100%;
        border-radius: 20px;
        max-height: calc(100dvh - 32px);
    }

    .rm-body {
        padding: 26px 24px 22px;
    }
}

@media (max-width: 480px) {
    .rm-overlay {
        padding: 12px;
        align-items: center;
    }

    .rm-modal {
        border-radius: 18px;
        max-height: calc(100dvh - 24px);
        width: 100%;
    }

    .rm-body {
        padding: 20px 16px 18px;
    }

    .rm-accent-bar { height: 3px; }

    .rm-close {
        top: 12px;
        right: 12px;
        width: 30px;
        height: 30px;
        font-size: 15px;
    }

    .rm-icon {
        width: 44px;
        height: 44px;
        font-size: 22px;
        border-radius: 12px;
        margin-bottom: 12px;
    }

    .rm-title { font-size: 17px; margin-bottom: 4px; }

    .rm-subtitle {
        font-size: 12.5px;
        margin-bottom: 16px;
        line-height: 1.5;
    }

    .rm-steps-bar { margin-bottom: 14px; }

    .rm-input-group { margin-bottom: 10px; }

    .rm-input {
        padding: 11px 13px;
        border-radius: 10px;
    }

    .rm-otp-input {
        font-size: 20px;
        letter-spacing: 10px;
        padding: 11px 10px;
    }

    .rm-btn-primary {
        padding: 12px;
        font-size: 14px;
        border-radius: 10px;
        margin-top: 8px;
        min-height: 44px;
    }

    .rm-btn-ghost { font-size: 12.5px; }
    .rm-muted-text { font-size: 12px; }
    .rm-footer { margin-top: 12px; gap: 6px; }

    .rm-alert {
        padding: 10px 12px;
        font-size: 12.5px;
        border-radius: 9px;
        margin-bottom: 12px;
    }

    .rm-success-icon {
        width: 52px;
        height: 52px;
        font-size: 20px;
        margin-bottom: 14px;
    }

    .rm-label { font-size: 10px; }
    .rm-strength-label { font-size: 10.5px; }
}

@media (max-width: 360px) {
    .rm-overlay { padding: 8px; }
    .rm-body { padding: 16px 14px 14px; }
    .rm-title { font-size: 16px; }
    .rm-subtitle { font-size: 12px; margin-bottom: 12px; }
    .rm-input { padding: 10px 12px; }
    .rm-otp-input { font-size: 18px; letter-spacing: 8px; }
    .rm-btn-primary { padding: 11px; font-size: 13.5px; }
}

/* Landscape on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .rm-overlay {
        align-items: flex-start;
        padding: 10px 16px;
        overflow-y: auto;
    }

    .rm-modal {
        max-height: none;
        border-radius: 14px;
        margin: 10px auto;
        max-width: 480px;
    }

    .rm-body { padding: 16px 20px 14px; }
    .rm-icon { margin-bottom: 8px; width: 38px; height: 38px; font-size: 18px; }
    .rm-title { font-size: 15px; margin-bottom: 3px; }
    .rm-subtitle { font-size: 12px; margin-bottom: 10px; }
    .rm-steps-bar { margin-bottom: 10px; }
    .rm-input-group { margin-bottom: 7px; }
    .rm-input { padding: 9px 13px; }
    .rm-btn-primary { padding: 10px; margin-top: 5px; min-height: 40px; }
    .rm-footer { margin-top: 8px; }
}

/* Touch: disable hover lifts */
@media (hover: none) and (pointer: coarse) {
    .rm-btn-primary:hover {
        transform: none;
        box-shadow: 0 4px 16px rgba(102, 126, 234, 0.35);
    }
}

@media (max-width: 480px) {
    #signupForm .sg-grid { grid-template-columns: 1fr; }
}
