/* ===========================
   SMALL PHONES (< 480px)
=========================== */
@media (max-width: 479px) {
    body {
        align-items: flex-start;
        padding: 16px 0;
    }

    .login-container {
        grid-template-columns: 1fr;
        padding: 12px;
        gap: 20px;
        max-width: 100%;
    }

    /* Hide brand section on very small screens */
    .brand-section {
        align-items: center;
        text-align: center;
        margin-bottom: 0;
    }

    .brand-logo {
        width: 140px;
        margin-bottom: 20px;
    }

    .brand-section h1 {
        font-size: 1.8rem;
        line-height: 1.2;
        margin-bottom: 12px;
    }

    .brand-section p {
        font-size: 0.9rem;
    }

    .login-card {
        padding: 20px 16px;
        border-radius: 12px;
        max-height: none;
    }

    .card-header img {
        width: 65%;
        margin-bottom: 10px;
    }

    .card-header h2.realm-title {
        font-size: 1.15rem;
    }

    .divider {
        margin: 16px 0 20px;
    }

    /* Form inputs */
    input[type="text"],
    input[type="password"],
    input[type="email"],
    select,
    .custom-input {
        padding: 11px 11px 11px 40px;
        font-size: 15px;
        border-radius: 8px;
    }

    .input-icon {
        left: 12px;
        width: 16px;
        height: 16px;
    }

    .form-group {
        margin-bottom: 16px;
    }

    .form-group label {
        font-size: 0.75rem;
        margin-bottom: 5px;
    }

    /* Buttons */
    .login-button,
    .btn-primary {
        padding: 12px;
        font-size: 0.9rem;
        border-radius: 10px;
    }

    /* Options row */
    .options-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        font-size: 0.8rem;
        margin-bottom: 20px;
    }

    /* Social icons */
    .social-icons {
        gap: 10px;
    }

    .social-icon {
        width: 42px;
        height: 42px;
    }

    .social-icon svg {
        width: 18px;
        height: 18px;
    }

    /* Footer */
    .footer-info {
        font-size: 0.68rem;
        margin-top: 20px;
    }

    /* Success/Expired icons */
    .success-icon,
    .expired-icon {
        width: 48px;
        height: 48px;
        margin-bottom: 16px;
    }

    /* Info/Expired messages */
    .info-message h1,
    .expired-title h1 {
        font-size: 1.15rem;
    }

    .info-message p,
    .instruction-text {
        font-size: 0.85rem;
    }

    /* Action buttons */
    .btn-restart,
    .btn-continue {
        padding: 11px 16px;
        font-size: 0.85rem;
    }

    /* Button groups */
    .button-group {
        flex-direction: column;
        gap: 10px;
    }

    .button-group button,
    .button-group input[type="submit"] {
        width: 100%;
    }
}

/* ===========================
   MOBILE PHONES (480px - 767px)
=========================== */
@media (min-width: 480px) and (max-width: 767px) {
    body {
        align-items: flex-start;
        padding: 20px 0;
    }

    .login-container {
        grid-template-columns: 1fr;
        padding: 16px;
        gap: 24px;
        max-width: 100%;
    }

    .brand-section {
        align-items: center;
        text-align: center;
    }

    .brand-logo {
        width: 180px;
        margin-bottom: 24px;
    }

    .brand-section h1 {
        font-size: 2.2rem;
        line-height: 1.15;
        margin-bottom: 14px;
    }

    .brand-section p {
        font-size: 1rem;
    }

    .login-card {
        padding: 24px 20px;
        border-radius: 16px;
        max-height: none;
    }

    .card-header img {
        width: 60%;
        margin-bottom: 12px;
    }

    .card-header h2.realm-title {
        font-size: 1.35rem;
    }

    .divider {
        margin: 20px 0 24px;
    }

    /* Form inputs */
    input[type="text"],
    input[type="password"],
    input[type="email"],
    select,
    .custom-input {
        padding: 13px 13px 13px 44px;
        font-size: 16px;
    }

    .input-icon {
        left: 14px;
        width: 18px;
        height: 18px;
    }

    .form-group {
        margin-bottom: 18px;
    }

    .form-group label {
        font-size: 0.8rem;
    }

    /* Buttons */
    .login-button,
    .btn-primary {
        padding: 13px;
        font-size: 0.95rem;
    }

    /* Success/Expired icons */
    .success-icon,
    .expired-icon {
        width: 56px;
        height: 56px;
    }

    /* Button groups */
    .button-group {
        flex-direction: column;
        gap: 10px;
    }
}

/* ===========================
   TABLETS (768px - 1023px)
   Single column but larger
=========================== */
@media (min-width: 768px) and (max-width: 1023px) {
    .login-container {
        grid-template-columns: 1fr;
        padding: 32px;
        gap: 32px;
        max-width: 700px;
        margin: 0 auto;
    }

    .brand-section {
        align-items: center;
        text-align: center;
    }

    .brand-logo {
        width: 220px;
        margin-bottom: 28px;
    }

    .brand-section h1 {
        font-size: 2.6rem;
    }

    .brand-section p {
        font-size: 1.1rem;
    }

    .login-card {
        padding: 30px 32px;
        max-height: calc(100vh - 80px);
    }

    .card-header img {
        width: 56%;
    }

    .card-header h2.realm-title {
        font-size: 1.45rem;
    }
}

/* ===========================
   SMALL LAPTOPS (1024px - 1279px)
   TWO-COLUMN LAYOUT PRESERVED!
=========================== */
@media (min-width: 1024px) and (max-width: 1279px) {
    .login-container {
        grid-template-columns: 1.1fr 1fr; /* Two columns! */
        padding: 16px 40px;
        gap: 48px;
        max-width: 1100px;
    }

    .brand-logo {
        width: 230px;
    }

    .brand-section h1 {
        font-size: 3rem;
    }

    .brand-section p {
        font-size: 1.1rem;
    }

    .login-card {
        padding: 26px 32px;
    }

    .card-header img {
        width: 55%;
    }
}

/* ===========================
   MEDIUM LAPTOPS (1280px - 1439px)
   TWO-COLUMN LAYOUT
=========================== */
@media (min-width: 1280px) and (max-width: 1439px) {
    .login-container {
        grid-template-columns: 1.15fr 1fr; /* Two columns! */
        padding: 8px 48px;
        gap: 56px;
        max-width: 1150px;
    }

    .brand-logo {
        width: 250px;
    }

    .brand-section h1 {
        font-size: 3.2rem;
    }

    .login-card {
        padding: 26px 34px;
    }
}

/* ===========================
   LARGE LAPTOPS & DESKTOPS (>= 1440px)
   TWO-COLUMN LAYOUT - DEFAULT
=========================== */
@media (min-width: 1440px) {
    .login-container {
        grid-template-columns: 1.15fr 1fr; /* Two columns! */
        padding: 5px 56px;
        gap: 64px;
        max-width: 1500px;
    }

    .brand-logo {
        width: 260px;
    }

    .brand-section h1 {
        font-size: 3.4rem;
    }

    .login-card {
        padding: 25px 36px;
    }
}

/* ===========================
   LANDSCAPE MODE (Mobile/Tablet)
=========================== */
@media (max-height: 600px) and (orientation: landscape) and (max-width: 1023px) {
    body {
        align-items: flex-start;
        padding: 12px 0;
    }

    .login-container {
        gap: 16px;
        padding: 12px;
    }

    /* Keep brand section but make it smaller */
    .brand-section {
        display: none;
    }

    .login-card {
        padding: 16px 20px;
        max-height: none;
    }

    .divider {
        margin: 12px 0 16px;
    }

    .form-group {
        margin-bottom: 12px;
    }

    .footer-info {
        margin-top: 16px;
    }
}

/* ===========================
   COMPONENT-SPECIFIC RESPONSIVE
=========================== */

/* Password toggle */
@media (max-width: 767px) {
    .password-toggle {
        right: 10px;
        padding: 6px;
    }

    .password-toggle svg {
        width: 18px;
        height: 18px;
    }
}

/* Password strength meter */
@media (max-width: 767px) {
    .password-requirements {
        padding: 10px;
    }

    .requirement {
        font-size: 0.75rem;
    }
}

/* Alert containers */
@media (max-width: 767px) {
    .alert-container {
        padding: 12px;
        font-size: 0.85rem;
    }
}

/* OTP input */
@media (max-width: 767px) {
    .otp-input {
        letter-spacing: 4px;
        font-size: 1rem;
    }
}

/* QR Code */
@media (max-width: 767px) {
    .qr-code,
    .qr-image-styled {
        max-width: 150px;
    }

    .manual-code-text {
        font-size: 0.85rem;
        letter-spacing: 1px;
    }
}

/* Authenticator list */
@media (max-width: 767px) {
    .authenticator-item {
        padding: 12px;
        gap: 12px;
    }

    .authenticator-icon svg {
        width: 20px;
        height: 20px;
    }

    .authenticator-title {
        font-size: 0.9rem;
    }

    .authenticator-desc {
        font-size: 0.8rem;
    }
}

/* Federated Identity (Account pages) */
@media (max-width: 1023px) {
    .providers-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .provider-card {
        padding: 20px;
    }
}

/* Registration form */
@media (max-width: 767px) {
    .login-card .form-group {
        margin-bottom: 14px;
    }

    .login-card .form-group label {
        font-size: 0.8rem;
    }

    .g-recaptcha {
        transform: scale(0.9);
        transform-origin: 0 0;
    }
}

/* Logout sessions checkbox */
@media (max-width: 767px) {
    .logout-sessions-wrapper {
        padding: 10px;
    }

    .logout-sessions-wrapper label {
        font-size: 0.85rem;
    }
}

/* ===========================
   SCROLLBAR
=========================== */
@media (max-width: 767px) {
    .login-card::-webkit-scrollbar {
        width: 4px;
    }
}

/* ===========================
   TOUCH DEVICES
=========================== */
@media (hover: none) and (pointer: coarse) {
    /* Increase tap targets */
    .login-button,
    .btn-primary,
    .btn-secondary,
    .btn-restart,
    .btn-continue {
        min-height: 44px;
    }

    input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }

    .social-icon {
        min-width: 48px;
        min-height: 48px;
    }

    .password-toggle {
        padding: 10px;
    }

    /* Remove hover transforms on touch */
    .login-button:hover,
    .social-icon:hover {
        transform: none;
    }
}

/* ===========================
   HIGH DPI DISPLAYS
=========================== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .login-card {
        box-shadow:
            0 30px 80px rgba(0, 0, 0, 0.28),
            inset 0 1px 0 rgba(255, 255, 255, 0.65);
    }

    input:focus {
        box-shadow:
            0 0 0 4px rgba(26, 115, 232, 0.2),
            0 6px 18px rgba(26, 115, 232, 0.18);
    }
}

/* ===========================
   REDUCED MOTION
=========================== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .spinner,
    .notification-icon {
        animation: none !important;
    }
}

/* ===========================
   HIGH CONTRAST
=========================== */
@media (prefers-contrast: high) {
    input:focus {
        outline: 3px solid currentColor;
        outline-offset: 2px;
    }

    .login-button,
    .btn-primary {
        border: 2px solid #000;
    }
}

/* ===========================
   PRINT
=========================== */
@media print {
    body {
        background: white;
    }

    .brand-section {
        display: none;
    }

    .login-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .login-button,
    .btn-restart,
    .btn-continue {
        display: none;
    }
}

/* ===========================
   UTILITY CLASSES
=========================== */
.hide-mobile {
    display: block;
}

.show-mobile {
    display: none;
}

@media (max-width: 767px) {
    .hide-mobile {
        display: none !important;
    }

    .show-mobile {
        display: block !important;
    }
}

/* ===========================
   PREVENT LAYOUT SHIFTS
=========================== */
@media (min-width: 1024px) {
    /* Ensure two-column layout is never overridden */
    .login-container {
        display: grid !important;
    }
    
    /* Ensure brand section is always visible on laptops */
    .brand-section {
        display: flex !important;
        text-align: left !important;
    }
}