/* ===== Portal Login System CSS v2.2.1 ===== */
/* ===== Created: 2025-01-28 ===== */
/* ===== Last Modified: 2025-10-26 ===== */
/* Authentication forms, modals, and user interface styling */
/* Version: 2.2.1 - Added hidden class for password toggle visibility control */

/* ===== LOGIN FORM STYLES ===== */

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 20px;
    box-sizing: border-box;
}

.login-form {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    width: 100%;
    max-width: none;
    animation: fadeInUp 0.5s ease-out;
}

.login-form h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
    font-size: 2em;
    font-weight: 600;
}

.login-form .subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
    font-size: 14px;
}

/* ===== FORM ELEMENTS ===== */

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #555;
    font-weight: 500;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: #4facfe;
    box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.1);
}

.form-group input:invalid {
    border-color: #dc3545;
}

.form-group input.error {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

/* ===== CHECKBOX STYLING ===== */

.form-group input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
    transform: scale(1.1);
}

.form-group label.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    font-weight: normal;
}

.form-group small {
    display: block;
    color: #666;
    font-size: 12px;
    margin-top: 5px;
    line-height: 1.4;
}

/* ===== BUTTONS ===== */

.login-button, .auth-button {
    width: 100%;
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.login-button:hover, .auth-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(79, 172, 254, 0.4);
}

.login-button:active, .auth-button:active {
    transform: translateY(0);
}

.login-button:disabled, .auth-button:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.login-button:disabled:hover, .auth-button:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* ===== LOADING SPINNER ===== */

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4facfe;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ===== MESSAGES ===== */

.message {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 500;
    animation: slideIn 0.3s ease-out;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.message.warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

/* ===== AUTHENTICATION BADGES ===== */

.auth-badge {
    position: fixed;
    top: 10px;
    left: 10px;
    background: rgba(40, 167, 69, 0.9);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    z-index: 10000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    user-select: none;
    transition: opacity 0.3s ease;
}

.auth-badge.admin {
    background: rgba(220, 53, 69, 0.9);
}

.portal-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1000;
}

/* ===== LOGOUT BUTTON ===== */

.logout-button, .portal-logout-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    z-index: 1000;
    transition: all 0.2s ease;
}

.logout-button:hover, .portal-logout-btn:hover {
    background: #dc3545;
    transform: scale(1.05);
}

/* ===== ACCESS DENIED STYLING ===== */

.access-denied-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    padding: 20px;
}

.access-denied-card {
    background: white;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    text-align: center;
    max-width: 500px;
    width: 100%;
    animation: fadeInUp 0.5s ease-out;
}

.access-denied-icon {
    font-size: 3em;
    margin-bottom: 20px;
}

.access-denied-card h1 {
    color: #dc3545;
    margin-bottom: 15px;
    font-size: 1.8em;
}

.access-denied-card p {
    color: #666;
    margin-bottom: 30px;
    line-height: 1.6;
}

.access-denied-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.access-denied-buttons button {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: transform 0.2s ease;
}

.access-denied-buttons button:hover {
    transform: translateY(-1px);
}

.access-denied-buttons button.secondary {
    background: #6c757d;
}

/* ===== USER INFO DISPLAY ===== */

.user-info-display {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.user-info-display .user-name {
    font-weight: 500;
    color: #333;
}

.user-info-display .user-type {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
}

.user-info-display .user-type.admin {
    background: #ffe4e1;
    color: #d63384;
}

.user-info-display .user-type.resident {
    background: #e7f3ff;
    color: #0066cc;
}

.user-info-display button {
    background: #dc3545;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.user-info-display button:hover {
    background: #c82333;
}

/* ===== FORM VALIDATION INDICATORS ===== */

.auth-indicator {
    color: #28a745;
    font-size: 0.9em;
    font-weight: 500;
    margin-left: 8px;
}

.auth-indicator::before {
    content: '✓';
    margin-right: 4px;
}

.form-group input[readonly] {
    background-color: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
}

/* ===== ANIMATIONS ===== */

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

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ===== RESPONSIVE DESIGN ===== */

@media (max-width: 768px) {
    .login-form {
        margin: 10px;
        padding: 30px 20px;
    }
    
    .login-form h1 {
        font-size: 1.6em;
    }
    
    .access-denied-card {
        margin: 10px;
        padding: 30px 20px;
    }
    
    .access-denied-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .access-denied-buttons button {
        width: 100%;
        max-width: 200px;
    }
    
    .user-info-display {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
}

@media (max-width: 480px) {
    .login-container,
    .access-denied-container {
        padding: 10px;
    }
    
    .form-group input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .login-button,
    .auth-button {
        padding: 14px; /* Larger touch target */
    }
}

/* ===== HIGH CONTRAST MODE ===== */

@media (prefers-contrast: high) {
    .login-form,
    .access-denied-card {
        border: 2px solid #333;
    }
    
    .form-group input:focus {
        border-color: #000;
        box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.2);
    }
    
    .login-button,
    .auth-button {
        background: #000;
    }
    
    .message.error {
        border-color: #000;
    }
    
    .message.success {
        border-color: #000;
    }
}

/* ===== REDUCED MOTION ===== */

@media (prefers-reduced-motion: reduce) {
    .login-form,
    .access-denied-card,
    .message {
        animation: none;
    }
    
    .login-button:hover,
    .auth-button:hover,
    .logout-button:hover,
    .portal-logout-btn:hover {
        transform: none;
    }
    
    .loading {
        animation: none;
        border-top-color: transparent;
    }
}

/* ===== PRINT STYLES ===== */

@media print {
    .login-container,
    .access-denied-container {
        background: white !important;
    }
    
    .login-form,
    .access-denied-card {
        box-shadow: none !important;
        border: 1px solid #ccc;
    }
    
    .login-button,
    .auth-button,
    .logout-button,
    .portal-logout-btn {
        background: #333 !important;
        color: white !important;
    }
}

/* ===== UTILITY CLASSES ===== */

.hidden {
    display: none !important;
}

.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;
}

.text-center {
    text-align: center;
}

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }

/* ===== PASSKEY AUTHENTICATION STYLES (NEW v2.1.0) ===== */

.passkey-button {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
}

.passkey-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
}

.passkey-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.passkey-button .icon {
    font-size: 20px;
}

.passkey-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 20px 0;
    color: #666;
    font-size: 14px;
}

.passkey-divider::before,
.passkey-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #ddd;
}

.passkey-divider::before {
    margin-right: 10px;
}

.passkey-divider::after {
    margin-left: 10px;
}

.passkey-info {
    background: #f0f9ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 12px;
    margin: 15px 0;
    font-size: 13px;
    color: #1e40af;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.passkey-info .icon {
    font-size: 18px;
    flex-shrink: 0;
}

.passkey-list {
    list-style: none;
    padding: 0;
    margin: 15px 0;
}

.passkey-list-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.passkey-list-item:hover {
    background: #e9ecef;
}

.passkey-device-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.passkey-device-name {
    font-weight: 600;
    color: #333;
}

.passkey-device-date {
    font-size: 12px;
    color: #666;
}

.passkey-delete-btn {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.passkey-delete-btn:hover {
    background: #c82333;
}

.passkey-add-btn {
    background: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.passkey-add-btn:hover {
    background: #218838;
    transform: translateY(-1px);
}

.passkey-unsupported {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 12px;
    margin: 15px 0;
    font-size: 13px;
    color: #856404;
}

.passkey-badge {
    display: inline-block;
    background: #6366f1;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
}

/* ===== PASSKEY MODAL STYLES ===== */

.passkey-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.passkey-modal-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease;
}

.passkey-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.passkey-modal-title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.passkey-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.passkey-modal-close:hover {
    background: #f0f0f0;
}

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