/* ================================================
   Modern Login Page V2 - BRK Group CIMS
   Corporate Theme with Floating Icons Animation
   ================================================ */

/* Global Reset for Login Page */
html.login-html {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    height: auto !important;
}

body.login-page-v2 {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #1e3a8a 100%) !important;
}

/* Base Page */
.login-page-v2 {
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile */
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #1e3a8a 100%);
    font-family: 'Segoe UI', 'Noto Sans Thai', sans-serif;
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}

/* Reset box-sizing for all elements */
.login-page-v2 *,
.login-page-v2 *::before,
.login-page-v2 *::after {
    box-sizing: border-box;
}

/* ================================================
   Animated Background
   ================================================ */
.animated-bg {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

/* Floating Corporate Icons */
.floating-icons {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.icon-float {
    position: absolute;
    left: var(--x);
    top: var(--y);
    font-size: 2.5rem;
    color: rgba(255, 255, 255, 0.08);
    animation: floatIcon 15s ease-in-out infinite;
    animation-delay: var(--delay);
    filter: drop-shadow(0 0 20px rgba(220, 38, 38, 0.3));
    transform-origin: center;
}

.icon-float:nth-child(odd) {
    color: rgba(220, 38, 38, 0.15);
}

.icon-float:nth-child(even) {
    color: rgba(59, 130, 246, 0.15);
}

@keyframes floatIcon {
    0%, 100% {
        transform: translateY(0) rotate(0deg) scale(1);
        opacity: 0.5;
    }
    25% {
        transform: translateY(-30px) rotate(10deg) scale(1.1);
        opacity: 0.8;
    }
    50% {
        transform: translateY(-15px) rotate(-5deg) scale(1.05);
        opacity: 0.6;
    }
    75% {
        transform: translateY(-40px) rotate(5deg) scale(1.15);
        opacity: 0.9;
    }
}

/* Gradient Orbs */
.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: orbFloat 20s ease-in-out infinite;
}

.orb-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(220, 38, 38, 0.6) 0%, transparent 70%);
    top: -150px;
    right: -150px;
    animation-delay: 0s;
}

.orb-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(30, 64, 175, 0.6) 0%, transparent 70%);
    bottom: -100px;
    left: -100px;
    animation-delay: -7s;
}

.orb-3 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(124, 58, 237, 0.5) 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -14s;
}

@keyframes orbFloat {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    25% {
        transform: translate(50px, -50px) scale(1.1);
    }
    50% {
        transform: translate(-30px, 30px) scale(0.95);
    }
    75% {
        transform: translate(30px, 20px) scale(1.05);
    }
}

/* ================================================
   Main Container - Split Layout
   ================================================ */
.login-container-v2 {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 1200px;
    margin: auto;
    padding: 30px;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 60px;
    animation: containerFadeIn 1s ease-out;
}

@keyframes containerFadeIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Left Side - Branding */
.login-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 40px 20px;
    animation: slideInLeft 0.8s ease-out;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.branding-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.brand-title {
    font-size: 3rem;
    font-weight: 700;
    color: white;
    margin: 0;
    text-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    letter-spacing: 3px;
}

.brand-tagline {
    display: flex;
    align-items: center;
    gap: 15px;
}

.brand-tagline .line {
    width: 50px;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(220, 38, 38, 0.8), transparent);
}

.brand-tagline .text {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.brand-description {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.8;
    margin-top: 10px;
}

/* DateTime Display in Form Header */
.datetime-display {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-top: 15px;
    padding: 12px 20px;
    background: rgba(30, 64, 175, 0.08);
    border-radius: 12px;
    border: 1px solid rgba(30, 64, 175, 0.15);
}

.datetime-display .datetime-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #64748b;
    font-size: 0.85rem;
}

.datetime-display .datetime-item i {
    color: #dc2626;
    font-size: 14px;
}

/* Right Side - Login Form */
.login-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: slideInRight 0.8s ease-out 0.2s backwards;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ================================================
   Logo Section
   ================================================ */
.logo-section {
    text-align: center;
    margin-bottom: 30px;
    animation: logoSlideDown 0.8s ease-out;
}

@keyframes logoSlideDown {
    from {
        opacity: 0;
        transform: translateY(-40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.logo-circle {
    width: 140px;
    height: 140px;
    margin: 0 auto 25px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        0 0 50px rgba(220, 38, 38, 0.25);
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% {
        box-shadow:
            0 8px 32px rgba(0, 0, 0, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.2),
            0 0 40px rgba(220, 38, 38, 0.2);
    }
    50% {
        box-shadow:
            0 8px 32px rgba(0, 0, 0, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.2),
            0 0 60px rgba(220, 38, 38, 0.4);
    }
}

.logo-circle img {
    width: 90px;
    height: auto;
    max-height: 90px;
    object-fit: contain;
}

.logo-circle i {
    font-size: 55px;
    color: white;
}

.company-info h1 {
    font-size: 2.2rem;
    font-weight: 700;
    color: white;
    margin-bottom: 10px;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
    letter-spacing: 2px;
}

.tagline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.tagline .line {
    width: 40px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
}

.tagline .text {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ================================================
   Login Form Card
   ================================================ */
.login-form-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 40px 35px;
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

@keyframes cardSlideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Decorative Corners */
.card-corner {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 3px solid;
    border-color: #dc2626;
}

.card-corner.top-left {
    top: -3px;
    left: -3px;
    border-right: none;
    border-bottom: none;
    border-radius: 24px 0 0 0;
}

.card-corner.top-right {
    top: -3px;
    right: -3px;
    border-left: none;
    border-bottom: none;
    border-radius: 0 24px 0 0;
}

.card-corner.bottom-left {
    bottom: -3px;
    left: -3px;
    border-right: none;
    border-top: none;
    border-radius: 0 0 0 24px;
}

.card-corner.bottom-right {
    bottom: -3px;
    right: -3px;
    border-left: none;
    border-top: none;
    border-radius: 0 0 24px 0;
}

/* ================================================
   Form Header
   ================================================ */
.form-header {
    text-align: center;
    margin-bottom: 30px;
}

.welcome-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 15px;
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 25px rgba(220, 38, 38, 0.4);
    animation: iconBounce 2s ease-in-out infinite;
}

@keyframes iconBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

.welcome-icon i {
    font-size: 28px;
    color: white;
}

.form-header h2 {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 8px;
}

.form-header p {
    font-size: 0.9rem;
    color: #64748b;
}

/* ================================================
   Form Fields
   ================================================ */
.login-form-v2 {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-field {
    position: relative;
}

.field-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.field-icon i {
    font-size: 16px;
    color: #94a3b8;
    transition: color 0.3s, transform 0.3s;
}

.form-field input {
    width: 100%;
    padding: 16px 50px 16px 48px;
    font-size: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: #f8fafc;
    color: #1e293b;
    outline: none;
    transition: all 0.3s ease;
}

.form-field input:focus {
    border-color: #dc2626;
    background: white;
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.1);
}

.form-field input:focus ~ .field-icon i,
.form-field:focus-within .field-icon i {
    color: #dc2626;
    transform: scale(1.1);
}

.form-field input::placeholder {
    color: #94a3b8;
}

/* Field Line Animation */
.field-line {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, #dc2626, #f97316);
    border-radius: 0 0 12px 12px;
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.form-field input:focus ~ .field-line {
    width: calc(100% - 4px);
}

/* Password Toggle */
.show-pass {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 5px;
    font-size: 16px;
    transition: color 0.3s;
    z-index: 2;
}

.show-pass:hover {
    color: #1e40af;
}

/* ================================================
   Submit Button
   ================================================ */
.submit-btn {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(220, 38, 38, 0.4);
    margin-top: 10px;
}

.submit-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(220, 38, 38, 0.5);
}

.submit-btn:active {
    transform: translateY(-1px);
}

.btn-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s;
}

.btn-content i {
    transition: transform 0.3s;
}

.submit-btn:hover .btn-content i {
    transform: translateX(5px);
}

.btn-loading {
    display: none;
    gap: 12px;
    align-items: center;
    justify-content: center;
}

.btn-loading i {
    font-size: 20px;
}

/* Modern Loading Spinner */
.login-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: loginSpin 0.8s linear infinite;
    display: inline-block;
}

@keyframes loginSpin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.submit-btn.loading .btn-content {
    display: none;
}

.submit-btn.loading .btn-loading {
    display: flex;
    align-items: center;
    justify-content: center;
}

.submit-btn.loading {
    pointer-events: none;
}

/* Shine Effect */
.submit-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: 0.6s;
}

.submit-btn:hover::before {
    left: 100%;
}

/* ================================================
   Form Divider
   ================================================ */
.form-divider {
    position: relative;
    text-align: center;
    margin: 25px 0;
}

.form-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, #e2e8f0, transparent);
}

.form-divider span {
    position: relative;
    background: rgba(255, 255, 255, 0.95);
    padding: 0 15px;
    color: #64748b;
    font-size: 0.85rem;
}

/* ================================================
   Register Button
   ================================================ */
.register-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px;
    font-size: 14px;
    font-weight: 600;
    color: #1e40af;
    background: transparent;
    border: 2px solid #1e40af;
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.register-btn:hover {
    background: #1e40af;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(30, 64, 175, 0.3);
}

/* Card Footer */
.card-footer {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
    text-align: center;
}

.card-footer p {
    color: #94a3b8;
    font-size: 0.75rem;
    margin: 0;
}


/* ================================================
   Responsive Design
   ================================================ */

/* Tablet - Switch to vertical layout */
@media (max-width: 992px) {
    .login-container-v2 {
        flex-direction: column;
        gap: 30px;
        max-width: 450px;
        padding: 20px;
    }

    .login-left {
        padding: 20px;
    }

    .brand-title {
        font-size: 2.2rem;
    }

    .brand-tagline .text {
        font-size: 0.8rem;
    }

    .brand-description {
        font-size: 1rem;
    }

    .datetime-display {
        flex-direction: row;
        gap: 20px;
        margin-top: 15px;
        padding: 10px 20px;
    }

    .card-footer {
        margin-top: 20px;
        padding-top: 15px;
    }

    .orb-1 {
        width: 350px;
        height: 350px;
    }

    .orb-2 {
        width: 300px;
        height: 300px;
    }

    .orb-3 {
        width: 200px;
        height: 200px;
    }
}

/* Tablet small */
@media (max-width: 768px) {
    .login-page-v2 {
        padding: 15px;
        align-items: flex-start;
        padding-top: 20px;
    }

    .login-container-v2 {
        max-width: 100%;
        padding: 15px;
        gap: 25px;
    }

    .logo-circle {
        width: 90px;
        height: 90px;
    }

    .logo-circle img {
        width: 55px;
        max-height: 55px;
    }

    .brand-title {
        font-size: 2rem;
    }

    .brand-description {
        display: none;
    }

    .icon-float {
        font-size: 2rem;
    }

    .orb-1 {
        width: 300px;
        height: 300px;
        top: -100px;
        right: -100px;
    }

    .orb-2 {
        width: 250px;
        height: 250px;
        bottom: -80px;
        left: -80px;
    }

    .orb-3 {
        width: 180px;
        height: 180px;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .login-page-v2 {
        padding: 10px;
        padding-top: 15px;
    }

    .login-container-v2 {
        padding: 10px;
        gap: 20px;
    }

    .login-left {
        padding: 15px 10px;
    }

    .logo-circle {
        width: 75px;
        height: 75px;
        margin-bottom: 10px;
    }

    .logo-circle img {
        width: 48px;
        max-height: 48px;
    }

    .brand-title {
        font-size: 1.6rem;
        letter-spacing: 1px;
    }

    .brand-tagline .line {
        width: 25px;
    }

    .brand-tagline .text {
        font-size: 0.65rem;
    }

    .branding-content {
        gap: 12px;
    }

    .datetime-display {
        flex-direction: column;
        gap: 6px;
        padding: 10px 15px;
        margin-top: 12px;
    }

    .datetime-display .datetime-item {
        font-size: 0.8rem;
    }

    .card-footer {
        margin-top: 18px;
        padding-top: 15px;
    }

    .card-footer p {
        font-size: 0.7rem;
    }

    .login-form-card {
        padding: 25px 20px;
        border-radius: 18px;
    }

    .card-corner {
        width: 18px;
        height: 18px;
        border-width: 2px;
    }

    .welcome-icon {
        width: 50px;
        height: 50px;
    }

    .welcome-icon i {
        font-size: 22px;
    }

    .form-header {
        margin-bottom: 20px;
    }

    .form-header h2 {
        font-size: 1.3rem;
    }

    .form-header p {
        font-size: 0.85rem;
    }

    .login-form-v2 {
        gap: 15px;
    }

    .form-field input {
        padding: 14px 45px 14px 44px;
        font-size: 16px;
    }

    .submit-btn {
        padding: 14px;
        font-size: 15px;
    }

    .form-divider {
        margin: 18px 0;
    }

    .register-btn {
        padding: 12px;
        font-size: 13px;
    }

    .icon-float {
        font-size: 1.5rem;
        opacity: 0.3;
    }

    .login-footer-v2 p {
        font-size: 0.7rem;
    }

    .orb {
        opacity: 0.2;
    }
}

/* Small mobile */
@media (max-width: 360px) {
    .brand-title {
        font-size: 1.4rem;
    }

    .brand-tagline {
        flex-wrap: wrap;
        justify-content: center;
    }

    .brand-tagline .line {
        display: none;
    }

    .login-form-card {
        padding: 20px 15px;
    }

    .form-header h2 {
        font-size: 1.2rem;
    }

    .datetime-display {
        padding: 10px 15px;
    }
}

/* Landscape on Mobile - Keep horizontal layout */
@media (max-height: 650px) and (orientation: landscape) {
    .login-page-v2 {
        align-items: center;
        padding: 15px;
    }

    .login-container-v2 {
        flex-direction: row;
        max-width: 100%;
        gap: 30px;
        padding: 15px;
    }

    .login-left {
        padding: 15px;
    }

    .logo-circle {
        width: 60px;
        height: 60px;
    }

    .logo-circle img {
        width: 40px;
    }

    .brand-title {
        font-size: 1.5rem;
    }

    .brand-tagline .text {
        font-size: 0.65rem;
    }

    .brand-description {
        display: none;
    }

    .datetime-display {
        margin-top: 15px;
        padding: 10px 15px;
    }

    .login-form-card {
        padding: 20px 25px;
    }

    .form-header {
        margin-bottom: 15px;
    }

    .welcome-icon {
        width: 40px;
        height: 40px;
        margin-bottom: 10px;
    }

    .welcome-icon i {
        font-size: 20px;
    }

    .login-form-v2 {
        gap: 12px;
    }

    .form-divider {
        margin: 12px 0;
    }

    .login-footer-v2 {
        display: none;
    }
}

/* iOS Safari Fix */
@supports (-webkit-touch-callout: none) {
    .login-page-v2 {
        min-height: -webkit-fill-available;
    }

    .form-field input {
        font-size: 16px !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .login-form-card {
        background: white;
        border: 2px solid #1e293b;
    }

    .form-field input {
        border-width: 2px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .icon-float,
    .orb,
    .logo-section,
    .login-form-card,
    .login-container-v2,
    .login-footer-v2,
    .logo-circle,
    .welcome-icon {
        animation: none;
    }

    .submit-btn::before {
        display: none;
    }

    .field-line {
        transition: none;
    }
}
