/**
 * VinaPet Modal Authentication Styles
 * Optimized for ERPNext Integration
 */

/* =============================================================================
   CSS VARIABLES
   ============================================================================= */
:root {
    --primary-color: #2563eb;
    --secondary-color: #1d4ed8;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    
    --text-primary: #19457B;
    --text-secondary: #666471;
    --text-muted: #9ca3af;
    
    --bg-primary: #F3F3F4;
    --bg-secondary: #fff;
    --bg-overlay: rgba(0, 0, 0, 0.5);
    
    --border-color: #e5e7eb;
    --border-color-focus: var(--primary-color);
    --border-radius: 8px;
    --border-radius-lg: 12px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    --font-family: 'Inter', 'Segoe UI', 'Roboto', sans-serif;
    --font-family-heading: 'Poppins', var(--font-family);
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    --z-modal: 9999;
}

/* =============================================================================
   MODAL OVERLAY & CONTAINER
   ============================================================================= */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-overlay);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-container {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    transform: scale(0.9) translateY(20px);
    transition: transform var(--transition-normal);
    font-family: 'SVN-Gilroy', sans-serif;
}

.modal-overlay.active .modal-container {
    transform: scale(1) translateY(0);
}

.modal-close {
    position: absolute;
    top: 28px;
    right: 16px;
    background: none;
    border: none;
    color: #19457B;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    z-index: 10;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-content {
    padding: 32px 28px 28px;
}

/* =============================================================================
   MODAL HEADER
   ============================================================================= */

.modal-header {
    text-align: center;
    margin-bottom: 32px;
}

.modal-title {
    font-family: var(--font-family-heading);
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 8px 0;
    line-height: 1.2;
}

.modal-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin: 0;
    font-weight: 400;
}

.register-notice{
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: #F1F8FE;
    border: 1px solid #0070B01A;
    border-left: 3px solid #0172CB;    
    border-radius: 3px;
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 20px;
}

/* =============================================================================
   FORMS
   ============================================================================= */

.auth-form {
    width: 100%;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 16px;
    font-family: var(--font-family);
    background: var(--bg-primary);
    transition: all var(--transition-fast);
    box-sizing: border-box;
}

.form-input:focus {
    outline: none;
    /* border-color: var(--border-color-focus); */
    /* box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); */
}

.form-input.error {
    border-color: var(--error-color);
}

.form-input.error:focus {
    border-color: var(--error-color);
    /* box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1); */
}

.form-input::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

/* Error messages */
.error-message {
    display: none;
    color: var(--error-color);
    font-size: 14px;
    margin-top: 6px;
    font-weight: 500;
}

.error-message:before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 4px;
    background: currentColor;
    border-radius: 50%;
    margin-right: 8px;
    margin-bottom: 2px;
}

/* Form rows */
.form-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

/* Checkbox styling */
.checkbox-group {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.checkbox-input {
    width: 18px;
    height: 18px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    appearance: none;
    background: var(--bg-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    margin-top: 2px;
}

.checkbox-input:checked {
    background: #19457B;
}

.checkbox-input:checked::after {
    content: '✓';
    color: white;
    font-size: 12px;
    font-weight: bold;
    display: block;
    text-align: center;
    line-height: 14px;
}

.checkbox-label {
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1.5;
}

.checkbox-label a.terms-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.checkbox-label a.terms-link:hover {
    text-decoration: underline;
}

.forgot-password {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    text-decoration: underline;
    transition: color var(--transition-fast);
}

.forgot-password:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

/* =============================================================================
   BUTTONS
   ============================================================================= */

.btn-primary {
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(90deg, #19457B 0%, #0F6B87 100%);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    margin-bottom: 16px;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.btn-text,
.btn-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-loading {
    display: none;
}

/* Google button */
.btn-google {
    width: 100%;
    padding: 14px 24px;
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
}

.btn-google:hover {
    background: var(--bg-secondary);
    border-color: var(--text-muted);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-google:active {
    transform: translateY(0);
}

.google-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* =============================================================================
   SOCIAL LOGIN
   ============================================================================= */

.social-login-divider {
    margin: 24px 0;
    position: relative;
    text-align: center;
}

.divider {
    position: relative;
    color: var(--text-muted);
    font-size: 14px;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border-color);
    z-index: 1;
}

.divider span {
    background: var(--bg-primary);
    padding: 0 16px;
    position: relative;
    z-index: 2;
}

.social-login-container {
    margin-top: 24px;
    margin-bottom: 24px;
}

/* =============================================================================
   FORM SWITCHING
   ============================================================================= */

.auth-switch {
    text-align: center;
    font-size: 14px;
    color: #19457B;
    margin-top: 24px;
}

.switch-link {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    margin-left: 4px;
    text-decoration: underline;
    transition: color var(--transition-fast);
}

.switch-link:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

/* =============================================================================
   NOTIFICATIONS
   ============================================================================= */

.notification-container {
    margin-bottom: 20px;
}

.auth-notification {
    padding: 14px 16px;
    border-radius: var(--border-radius);
    margin-bottom: 12px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
    position: relative;
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.notification-icon {
    font-size: 16px;
    font-weight: bold;
    flex-shrink: 0;
}

.notification-message {
    line-height: 1.4;
}

.notification-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.notification-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
}

.auth-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--success-color);
}

.auth-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--error-color);
}

.auth-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--warning-color);
}

.auth-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--info-color);
}

/* =============================================================================
   LOADING ANIMATIONS
   ============================================================================= */

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =============================================================================
   BODY MODAL OPEN STATE
   ============================================================================= */

body.modal-open {
    overflow: hidden;
}

/* =============================================================================
   RESPONSIVE DESIGN
   ============================================================================= */

@media (max-width: 768px) {
    .modal-overlay {
        padding: 16px;
        align-items: flex-start;
        padding-top: 60px;
    }
    
    .modal-container {
        max-height: calc(100vh - 120px);
    }
    
    .modal-content {
        padding: 24px 20px 20px;
    }
    
    .modal-title {
        font-size: 24px;
    }
    
    .modal-subtitle {
        font-size: 14px;
    }
    
    .form-input {
        padding: 12px 14px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .btn-primary,
    .btn-google {
        padding: 14px 20px;
        font-size: 15px;
    }
    
    .form-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .modal-overlay {
        padding: 12px;
        padding-top: 40px;
    }
    
    .modal-container {
        max-height: calc(100vh - 80px);
    }
    
    .modal-content {
        padding: 20px 16px 16px;
    }
    
    .modal-title {
        font-size: 22px;
    }
    
    .checkbox-group {
        align-items: flex-start;
        gap: 8px;
    }
    
    .checkbox-label {
        font-size: 13px;
    }
}

/* =============================================================================
   ACCESSIBILITY
   ============================================================================= */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (prefers-contrast: high) {
    .modal-container {
        border: 2px solid var(--text-primary);
    }
    
    .form-input {
        border-width: 3px;
    }
    
    .btn-google {
        border-width: 3px;
    }
}

/* Focus visible for better keyboard navigation */
/* .modal-close:focus-visible,
.form-input:focus-visible,
.btn-primary:focus-visible,
.btn-google:focus-visible,
.checkbox-input:focus-visible,
.switch-link:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
} */

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* =============================================================================
   PRINT STYLES
   ============================================================================= */

@media print {
    .modal-overlay {
        display: none !important;
    }
}

/* =============================================================================
   GOOGLE REGISTER SPECIFIC STYLES - Thêm vào modal-auth.css
   ============================================================================= */

#googleRegisterForm {
    animation: fadeIn 0.3s ease-in-out;
}

#googleRegisterEmail {
    background-color: #F0FDFF !important;
    color: #0C0C0C !important;
    cursor: not-allowed !important;
    border: none !important;
    
}

#googleRegisterEmail:focus {
    outline: none !important;
    box-shadow: none !important;
}

.register-notice {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: #F1F8FE;
    border: 1px solid #0070B01A;
    border-left: 3px solid #0172CB;    
    border-radius: 3px;
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 20px;
}

.register-notice svg {
    flex-shrink: 0;
}

/* Animation for form switching */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

/* Terms link styling */
.terms-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.terms-link:hover {
    text-decoration: underline;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .register-notice {
        font-size: 13px;
        padding: 12px 16px;
    }
}

.google-label {
    color: #19457B;
    font-size: 16px;
}

.form-input select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23666' viewBox='0 0 16 16'%3E%3Cpath d='M8 11.5L4 7h8l-4 4.5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  padding-right: 40px;
}

.form-input select:disabled {
  background-color: #f5f5f5;
  color: #999;
  cursor: not-allowed;
}