/* ==========================================
   MOBILE-FIRST LOGIN STYLING (PWA/MOBILE)
   ========================================== */

/* Hide the desktop root element on mobile/tablet viewports (< 992px) */
#kt_app_root {
    display: none !important;
}

/* Force pure white background and prevent horizontal scrolling on mobile/tablet */
@media (max-width: 991.98px) {

    body,
    html {
        background-color: #ffffff !important;
        background-image: none !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box !important;
        height: auto !important;
        min-height: 100% !important;
    }
}

/* Base mobile/tablet container style - break out of parent flexbox using absolute positioning */
.mobile-login-container {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    min-height: 100vh !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    z-index: 99999 !important;
    background-color: #ffffff !important;
    box-sizing: border-box !important;
    /* Safe Area Padding for Notch Devices */
    padding-top: max(24px, env(safe-area-inset-top)) !important;
    padding-bottom: max(24px, env(safe-area-inset-bottom)) !important;
    padding-left: max(20px, env(safe-area-inset-left)) !important;
    padding-right: max(20px, env(safe-area-inset-right)) !important;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

/* Wrapper supporting vertical centering with auto margins (prevents vertical cutoff on short viewports/keyboards) */
.mobile-login-wrapper {
    width: 100% !important;
    max-width: 380px !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
    flex-shrink: 0;
    margin-top: auto;
    margin-bottom: auto;
    padding: 8px 0;
}

/* Branding Header */
.mobile-login-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 20px;
    width: 100%;
}

.mobile-logo-img {
    height: 42px;
    width: auto;
    margin-bottom: 12px;
    object-fit: contain;
    max-width: 100%;
}

.mobile-app-description {
    font-size: 13px;
    color: #8e8e93;
    font-weight: 400;
    line-height: 1.4;
    max-width: 260px;
    letter-spacing: -0.1px;
}

/* The White Card with subtle border and rounded corners */
.mobile-login-card {
    background: #ffffff;
    border-radius: 20px;
    width: 100% !important;
    padding: 28px 20px;
    box-sizing: border-box;
    border: 1px solid #f2f2f7;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.015);
    display: flex;
    flex-direction: column;
}

.mobile-login-card form {
    width: 100%;
    margin: 0;
    padding: 0;
}

/* Card titles and subtitles */
.mobile-card-title {
    font-size: 24px;
    font-weight: 700;
    color: #000000;
    margin-bottom: 4px;
    text-align: left;
    letter-spacing: -0.5px;
}

.mobile-card-subtitle {
    font-size: 14px;
    color: #8e8e93;
    margin-bottom: 20px;
    text-align: left;
    font-weight: 400;
}

/* Form fields layout */
.mobile-login-card .fv-row {
    margin-bottom: 16px !important;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.mobile-login-card .fv-row:last-of-type {
    margin-bottom: 10px !important;
}

/* Input Labels */
.mobile-input-label {
    font-size: 13px;
    font-weight: 700;
    color: #1c1c1e;
    margin-bottom: 6px;
    text-align: left;
}

/* Form controls - Inputs (touch friendly height >= 44px) */
.mobile-login-card .form-control {
    background-color: #ffffff !important;
    border: 1px solid #e5e5ea !important;
    border-radius: 12px !important;
    padding: 10px 14px !important;
    font-size: 15px !important;
    height: 48px !important;
    color: #1c1c1e !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.mobile-login-card .form-control::placeholder {
    color: #c7c7cc !important;
    opacity: 1;
}

.mobile-login-card .form-control:focus {
    border-color: #0a2240 !important;
    outline: none !important;
}

/* Prevent browser autofill from styling inputs blue */
.mobile-login-card .form-control:-webkit-autofill,
.mobile-login-card .form-control:-webkit-autofill:hover,
.mobile-login-card .form-control:-webkit-autofill:focus,
.mobile-login-card .form-control:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px #ffffff inset !important;
    -webkit-text-fill-color: #1c1c1e !important;
}

/* Eye Icon positioning and styling */
.mobile-password-input-wrapper {
    position: relative;
    width: 100%;
}

.mobile-password-toggle {
    z-index: 10;
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    display: flex;
    align-items: center;
}

.mobile-eye-icon {
    width: 20px;
    height: 20px;
    stroke: #8e8e93;
    transition: stroke 0.2s ease;
}

.mobile-eye-icon:hover {
    stroke: #1c1c1e;
}

/* Validation styles alignment */
.mobile-login-card span.invalid-feedback {
    display: block;
    color: #f1416c;
    font-size: 12px;
    margin-top: 4px;
    font-weight: 500;
    text-align: left;
    width: 100%;
}

.mobile-login-card .form-control.is-invalid {
    border-color: #f1416c !important;
}

/* Forget Password Link alignment and spacing */
.mobile-forget-wrapper {
    display: flex;
    justify-content: flex-end;
    width: 100%;
    margin-bottom: 24px;
}

.mobile-forget-link {
    font-size: 13px;
    font-weight: 500;
    color: #1c1c1e;
    text-decoration: none !important;
    transition: color 0.2s ease;
}

.mobile-forget-link:hover {
    color: #000000;
}

/* Button sizing and styles (touch friendly height >= 44px) */
.mobile-login-card .btn-primary {
    background-color: #0a2240 !important;
    border-color: #0a2240 !important;
    color: #ffffff !important;
    border-radius: 12px !important;
    height: 48px !important;
    width: 100% !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    letter-spacing: 0.5px;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-transform: uppercase;
    cursor: pointer;
    box-sizing: border-box !important;
    transition: background-color 0.2s ease, transform 0.1s ease !important;
}

.mobile-login-card .btn-primary:active {
    transform: scale(0.98);
}

.mobile-login-card .btn-primary:hover {
    background-color: #051426 !important;
}

/* Adjustments for extra small viewports (e.g. iPhone SE, width 320px) */
@media (max-width: 375px) {
    .mobile-login-container {
        padding-top: max(12px, env(safe-area-inset-top)) !important;
        padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
        padding-left: max(12px, env(safe-area-inset-left)) !important;
        padding-right: max(12px, env(safe-area-inset-right)) !important;
    }

    .mobile-login-card {
        padding: 20px 14px;
        border-radius: 16px;
    }

    .mobile-card-title {
        font-size: 20px;
    }

    .mobile-card-subtitle {
        margin-bottom: 16px;
    }

    .mobile-logo-img {
        height: 36px;
        margin-bottom: 10px;
    }

    .mobile-forget-wrapper {
        margin-bottom: 20px;
    }
}

/* ==========================================
   MOBILE DASHBOARD STYLES
   ========================================== */

.mobile-dashboard-container {
    width: 100%;
    min-height: 100vh;
    background: #f5f6f8;
}

.mobile-dashboard-topbar {
    height: 90px;
    background: #ffffff;
    border-bottom-left-radius: 24px;
    border-bottom-right-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-dashboard-topbar h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    color: #000;
}

.mobile-dashboard-header {
    background: #082b53;
    padding: 24px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-dashboard-user small {
    color: rgba(255, 255, 255, .75);
    font-size: 16px;
}

.mobile-dashboard-user h2 {
    color: #fff;
    font-size: 40px;
    font-weight: 700;
    margin: 8px 0 0;
}

.mobile-dashboard-right {
    display: flex;
    align-items: center;
    gap: 18px;
}

.mobile-notification {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .15);
    position: relative;
}

.mobile-notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #ff4d4f;
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-menu-btn {
    color: #fff;
    font-size: 34px;
}

/* Statistics */

.mobile-dashboard-stats {
    display: flex;
    gap: 12px;
    padding: 16px;
}

.mobile-stat-card {
    flex: 1;
    background: #fff;
    border-radius: 18px;
    padding: 14px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .05);
}

.mobile-stat-card.active {
    border-left: 5px solid #2196f3;
}

.mobile-stat-card.completed {
    border-left: 5px solid #4caf50;
}

.mobile-stat-card.overdue {
    border-left: 5px solid #ff9800;
}

.mobile-stat-card h5 {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
}

.mobile-stat-card h2 {
    margin: 8px 0 0;
    font-size: 34px;
    font-weight: 700;
}

/* Quick Actions */

.mobile-dashboard-content {
    padding: 0 16px 30px;
}

.mobile-dashboard-title {
    font-size: 24px;
    font-weight: 700;
    color: #000;
    margin-bottom: 16px;
}

.mobile-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.mobile-dashboard-card {
    background: #fff;
    border-radius: 20px;
    padding: 20px;
    min-height: 150px;
    text-decoration: none;
    box-shadow: 0 3px 12px rgba(0, 0, 0, .06);
}

.mobile-dashboard-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    margin-bottom: 16px;
}

.mobile-dashboard-card h4 {
    margin: 0 0 8px;
    color: #000;
    font-size: 18px;
    font-weight: 600;
}

.mobile-dashboard-card p {
    margin: 0;
    color: #777;
    font-size: 14px;
}

.icon-gray {
    background: #eef1f5;
}

.icon-pink {
    background: #ffe4f2;
}

.icon-red {
    background: #ffe5e5;
}

.icon-green {
    background: #ddf7e4;
}

.icon-orange {
    background: #fff1dd;
}

.icon-yellow {
    background: #fff8d6;
}

.icon-cyan {
    background: #dff8ff;
}

.icon-purple {
    background: #ece8ff;
}

/* iPhone SE */

@media (max-width: 375px) {

    .mobile-dashboard-user h2 {
        font-size: 30px;
    }

    .mobile-stat-card h2 {
        font-size: 26px;
    }

    .mobile-dashboard-card {
        padding: 16px;
        min-height: 130px;
    }

    .mobile-dashboard-card h4 {
        font-size: 16px;
    }

    .mobile-dashboard-card p {
        font-size: 13px;
    }
}

/* ==========================================
   DESKTOP OVERRIDES (>= 992px)
   ========================================== */
@media (min-width: 992px) {
    #kt_app_root {
        display: flex !important;
    }

    .mobile-login-container {
        display: none !important;
    }
}