/**
 * SJ Login System - Modern Blue Orange Theme
 * Version: 4.0.1
 * สีน้ำเงิน-ส้ม ที่สวยงาม ทันสมัย น่าใช้งาน
 * - กรอบขาวเฉพาะ Login (ไม่มี Container ซ้อน)
 * - ความกว้าง 555px
 * - UI Elements ขนาดใหญ่ขึ้น สวยงามขึ้น
 */


/* ===== CSS Variables ===== */
:root {
    --sj-primary: #2563EB;      /* Blue */
    --sj-primary-dark: #1E40AF;
    --sj-primary-light: #3B82F6;
    --sj-secondary: #F97316;    /* Orange */
    --sj-secondary-dark: #EA580C;
    --sj-secondary-light: #FB923C;
    --sj-success: #10B981;
    --sj-error: #EF4444;
    --sj-white: #FFFFFF;
    --sj-gray-50: #F9FAFB;
    --sj-gray-100: #F3F4F6;
    --sj-gray-200: #E5E7EB;
    --sj-gray-300: #D1D5DB;
    --sj-gray-400: #9CA3AF;
    --sj-gray-500: #6B7280;
    --sj-gray-600: #4B5563;
    --sj-gray-700: #374151;
    --sj-gray-800: #1F2937;
    --sj-gray-900: #111827;
    --sj-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --sj-radius: 12px;
    --sj-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --sj-shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* ===== Reset & Base ===== */
* {
    box-sizing: border-box;
}

/* ===== Container ===== */
.sj-login-container {
    max-width: 555px;
    margin: 40px auto;
    padding: 0;
    font-family: var(--sj-font);
}

/* ===== Card ===== */
.sj-card {
    background: var(--sj-white);
    border-radius: var(--sj-radius);
    box-shadow: var(--sj-shadow-lg);
    padding: 50px;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--sj-gray-200);
}

.sj-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg, var(--sj-primary) 0%, var(--sj-secondary) 100%);
}

/* ===== Card Header ===== */
.sj-card-header {
    text-align: center;
    margin-bottom: 36px;
}

.sj-icon-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 90px;
    height: 90px;
    background: linear-gradient(135deg, var(--sj-primary) 0%, var(--sj-primary-light) 100%);
    border-radius: 50%;
    margin-bottom: 24px;
    box-shadow: 0 10px 30px rgba(37, 99, 235, 0.35);
}

.sj-icon-wrapper i {
    font-size: 45px;
    color: var(--sj-white);
}

.sj-card-header h2 {
    font-size: 32px;
    font-weight: 700;
    color: var(--sj-gray-900);
    margin: 0 0 10px 0;
    background: linear-gradient(135deg, var(--sj-primary) 0%, var(--sj-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sj-card-header p {
    font-size: 15px;
    color: var(--sj-gray-500);
    margin: 0;
}

/* ===== Form ===== */
.sj-form {
    width: 100%;
}

.sj-form-group {
    margin-bottom: 24px;
}

.sj-form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--sj-gray-700);
    margin-bottom: 10px;
}

.sj-form-group label i {
    color: var(--sj-primary);
    font-size: 17px;
}

/* ===== Inputs ===== */
.sj-input {
    width: 100%;
    padding: 16px 18px;
    font-size: 16px;
    font-family: var(--sj-font);
    color: var(--sj-gray-900);
    background: var(--sj-gray-50);
    border: 2px solid var(--sj-gray-200);
    border-radius: 10px;
    transition: all 0.3s ease;
    outline: none;
}

.sj-input:focus {
    background: var(--sj-white);
    border-color: var(--sj-primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.sj-input::placeholder {
    color: var(--sj-gray-400);
}

/* ===== Input Group (Password) ===== */
.sj-input-group {
    position: relative;
}

.sj-input-group .sj-input {
    padding-right: 48px;
}

.sj-toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--sj-gray-400);
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    transition: color 0.2s ease;
}

.sj-toggle-password:hover {
    color: var(--sj-primary);
}

/* ===== Checkbox ===== */
.sj-checkbox-group {
    margin-bottom: 24px;
}

.sj-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.sj-checkbox input[type="checkbox"] {
    display: none;
}

.sj-checkbox-custom {
    position: relative;
    width: 20px;
    height: 20px;
    background: var(--sj-gray-100);
    border: 2px solid var(--sj-gray-300);
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.sj-checkbox input[type="checkbox"]:checked + .sj-checkbox-custom {
    background: var(--sj-primary);
    border-color: var(--sj-primary);
}

.sj-checkbox input[type="checkbox"]:checked + .sj-checkbox-custom::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--sj-white);
    font-size: 12px;
}

.sj-checkbox-label {
    font-size: 14px;
    color: var(--sj-gray-600);
}

/* ===== Buttons ===== */
.sj-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 28px;
    font-size: 16px;
    font-weight: 600;
    font-family: var(--sj-font);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    outline: none;
}

.sj-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.sj-btn-block {
    width: 100%;
}

.sj-btn-primary {
    background: linear-gradient(135deg, var(--sj-primary) 0%, var(--sj-primary-light) 100%);
    color: var(--sj-white);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.sj-btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

.sj-btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.sj-btn-danger {
    background: linear-gradient(135deg, var(--sj-error) 0%, #DC2626 100%);
    color: var(--sj-white);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.sj-btn-danger:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.sj-btn-loading {
    display: none;
}

/* ===== Form Footer ===== */
.sj-form-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--sj-gray-200);
}

.sj-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--sj-primary);
    text-decoration: none;
    transition: all 0.2s ease;
}

.sj-link:hover {
    color: var(--sj-secondary);
    text-decoration: underline;
}

.sj-link i {
    font-size: 13px;
}

.sj-divider {
    color: var(--sj-gray-300);
    font-size: 14px;
}

/* ===== Version ===== */
.sj-version {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--sj-gray-100);
    font-size: 12px;
    color: var(--sj-gray-400);
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* ===== Toast Notification ===== */
.sj-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    display: none;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: var(--sj-shadow-lg);
    font-family: var(--sj-font);
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    min-width: 280px;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.sj-toast i {
    font-size: 20px;
}

.sj-toast-success {
    background: var(--sj-success);
    color: var(--sj-white);
}

.sj-toast-error {
    background: var(--sj-error);
    color: var(--sj-white);
}

.sj-toast-info {
    background: var(--sj-primary);
    color: var(--sj-white);
}

/* ===== Logged In State ===== */
.sj-logged-in .sj-card {
    text-align: center;
}

.sj-success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, var(--sj-success) 0%, #059669 100%);
    border-radius: 50%;
    margin-bottom: 24px;
    animation: scaleIn 0.5s ease;
}

@keyframes scaleIn {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.sj-success-icon i {
    font-size: 50px;
    color: var(--sj-white);
}

.sj-logged-in h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--sj-gray-900);
    margin: 0 0 12px 0;
}

.sj-welcome-text {
    font-size: 16px;
    color: var(--sj-gray-600);
    margin: 0 0 24px 0;
}

.sj-welcome-text strong {
    color: var(--sj-primary);
}

/* ===== Logout Container ===== */
.sj-logout-container {
    display: inline-block;
}

#sj-logout-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 600;
    background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    font-family: var(--sj-font);
}

#sj-logout-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
    background: linear-gradient(135deg, #DC2626 0%, #B91C1C 100%);
}

#sj-logout-btn:active:not(:disabled) {
    transform: translateY(0);
}

#sj-logout-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#sj-logout-btn i {
    font-size: 16px;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
    .sj-login-container {
        max-width: 100%;
        padding: 15px;
        margin: 20px auto;
    }

    .sj-card {
        padding: 40px 30px;
    }

    .sj-card-header h2 {
        font-size: 24px;
    }

    .sj-icon-wrapper {
        width: 70px;
        height: 70px;
    }

    .sj-icon-wrapper i {
        font-size: 35px;
    }

    .sj-toast {
        left: 10px;
        right: 10px;
        min-width: auto;
    }

    .sj-form-footer {
        flex-direction: column;
        gap: 12px;
    }

    .sj-divider {
        display: none;
    }
}

@media (max-width: 400px) {
    .sj-card {
        padding: 30px 20px;
    }
}

/* ===== Dark Mode Support ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --sj-white: #1F2937;
        --sj-gray-50: #111827;
        --sj-gray-100: #1F2937;
        --sj-gray-200: #374151;
        --sj-gray-900: #F9FAFB;
        --sj-gray-800: #E5E7EB;
        --sj-gray-700: #D1D5DB;
    }
}

/* ===== Animations ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* ========================================
   MODAL LOGIN POPUP - ไม่อนุญาตให้ปิดจนกว่าจะ Login
   ======================================== */

/* Modal Overlay */
.sj-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.3s ease;
    backdrop-filter: blur(8px);
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Modal Container */
.sj-modal-container {
    position: relative;
    width: 90%;
    max-width: 555px;
    animation: modalSlideIn 0.4s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Modal Content - ใช้สไตล์เดียวกับ .sj-card แต่กระชับขึ้น 30% */
.sj-modal-content {
    background: var(--sj-white);
    border-radius: var(--sj-radius);
    box-shadow: var(--sj-shadow-lg);
    padding: 35px;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--sj-gray-200);
    max-height: 90vh;
    overflow-y: auto;
}

/* Border Top Gradient เหมือน .sj-card */
.sj-modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--sj-primary) 0%, var(--sj-secondary) 100%);
}

/* Close Button - ซ่อนไว้เพราะไม่ให้ปิด Modal จนกว่าจะ Login */
.sj-modal-close {
    display: none !important;
}

/* Modal Header - ใช้สไตล์เดียวกับ .sj-card-header แต่กระชับขึ้น */
.sj-modal-header {
    text-align: center;
    margin-bottom: 25px;
}

.sj-modal-header .sj-icon-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 63px;
    height: 63px;
    background: linear-gradient(135deg, var(--sj-primary) 0%, var(--sj-primary-light) 100%);
    border-radius: 50%;
    margin-bottom: 17px;
    box-shadow: 0 7px 21px rgba(37, 99, 235, 0.35);
}

.sj-modal-header .sj-icon-wrapper i {
    font-size: 32px;
    color: var(--sj-white);
}

.sj-modal-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--sj-gray-900);
    margin: 0 0 7px 0;
    background: linear-gradient(135deg, var(--sj-primary) 0%, var(--sj-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sj-modal-header p {
    font-size: 13px;
    color: var(--sj-gray-500);
    margin: 0;
}

/* Modal Form */
.sj-modal-form {
    width: 100%;
}

/* Form Groups - กระชับขึ้น */
.sj-modal-form .sj-form-group {
    margin-bottom: 17px;
}

.sj-modal-form .sj-form-group label {
    margin-bottom: 7px;
    font-size: 14px;
}

.sj-modal-form .sj-input {
    padding: 11px 13px;
    font-size: 15px;
}

.sj-modal-form .sj-btn {
    padding: 11px 20px;
    font-size: 15px;
}

/* Message Container - กระชับขึ้น */
.sj-modal-message {
    padding: 11px 14px;
    border-radius: 8px;
    margin-bottom: 17px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sj-modal-message.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--sj-error);
    border: 2px solid rgba(239, 68, 68, 0.2);
}

.sj-modal-message.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--sj-success);
    border: 2px solid rgba(16, 185, 129, 0.2);
}

.sj-modal-message i {
    font-size: 16px;
}

/* Responsive Design for Modal */
@media (max-width: 600px) {
    .sj-modal-container {
        width: 95%;
        max-width: 100%;
        padding: 10px;
    }

    .sj-modal-content {
        padding: 28px 21px;
    }

    .sj-modal-header h2 {
        font-size: 20px;
    }

    .sj-modal-header .sj-icon-wrapper {
        width: 56px;
        height: 56px;
    }

    .sj-modal-header .sj-icon-wrapper i {
        font-size: 28px;
    }
}

@media (max-width: 400px) {
    .sj-modal-content {
        padding: 21px 14px;
    }
}

/* Scrollbar Styling for Modal */
.sj-modal-content::-webkit-scrollbar {
    width: 8px;
}

.sj-modal-content::-webkit-scrollbar-track {
    background: var(--sj-gray-100);
    border-radius: 10px;
}

.sj-modal-content::-webkit-scrollbar-thumb {
    background: var(--sj-gray-300);
    border-radius: 10px;
}

.sj-modal-content::-webkit-scrollbar-thumb:hover {
    background: var(--sj-gray-400);
}

/* ===== Login Divider - กระชับขึ้น ===== */
.sj-login-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 21px 0 17px 0;
    position: relative;
}

.sj-login-divider::before,
.sj-login-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--sj-gray-200);
}

.sj-login-divider span {
    padding: 0 11px;
    font-size: 12px;
    font-weight: 500;
    color: var(--sj-gray-500);
    background: var(--sj-white);
    white-space: nowrap;
}

/* ===== LINE Login Button Wrapper - กระชับขึ้น ===== */
.sj-line-login-wrapper {
    margin-top: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.sj-line-login-wrapper .line-btn-def456,
.sj-line-login-wrapper .line-login-wrapper-def456,
.sj-line-login-wrapper .line-login-wrapper-def456 a {
    width: 100%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    font-size: 15px;
    font-weight: 600;
    background: linear-gradient(135deg, #06C755 0%, #00B900 100%);
    color: var(--sj-white) !important;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 8px rgba(6, 199, 85, 0.3);
    text-decoration: none !important;
}

.sj-line-login-wrapper .line-btn-def456:hover,
.sj-line-login-wrapper .line-login-wrapper-def456 a:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(6, 199, 85, 0.4);
    background: linear-gradient(135deg, #00B900 0%, #009900 100%);
}

.sj-line-login-wrapper .line-btn-def456:active,
.sj-line-login-wrapper .line-login-wrapper-def456 a:active {
    transform: translateY(0);
}

/* LINE Icon */
.sj-line-login-wrapper .line-btn-def456 i,
.sj-line-login-wrapper .line-login-wrapper-def456 a i {
    font-size: 16px;
}

/* Responsive for LINE Login */
@media (max-width: 600px) {
    .sj-login-divider {
        margin: 24px 0 20px 0;
    }

    .sj-login-divider span {
        font-size: 13px;
        padding: 0 12px;
    }

    .sj-line-login-wrapper .line-btn-def456,
    .sj-line-login-wrapper .line-login-wrapper-def456 a {
        padding: 14px 24px;
        font-size: 15px;
    }
}
