/**
 * Authentication UI Styles for VPTH-MVP
 * Provides styling for login, registration, and role selection interfaces
 * 
 * @version 1.0
 * @author VPTH Development Team
 */

/* --- Authentication Modal --- */
#authModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(3px);
    transition: opacity 0.3s ease;
}

#authModal.hidden {
    display: none;
}

/* --- Authentication Container --- */
#authContainer {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 420px;
    width: 90%;
    text-align: center;
    position: relative;
    animation: authSlideIn 0.3s ease-out;
}

@keyframes authSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

#authContainer h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 26px;
    font-weight: 600;
}

#authContainer p {
    color: #555;
    margin-bottom: 20px;
    font-size: 16px;
}

/* --- Role Selection --- */
.role-selection {
    margin: 20px 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.role-button {
    padding: 15px 12px;
    border: 2px solid #e0e6ed;
    border-radius: 10px;
    background-color: #f8f9fa;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

.role-button:hover {
    border-color: #4CAF50;
    background-color: #e8f5e8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.2);
}

.role-button.selected {
    border-color: #4CAF50;
    background-color: #4CAF50;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.role-button strong {
    font-size: 16px;
    margin-bottom: 4px;
    display: block;
}

.role-button small {
    font-size: 11px;
    opacity: 0.8;
}

.role-button.selected small {
    opacity: 1;
}

/* Role-specific colors */
.role-button[data-role="therapist"]:not(.selected):hover {
    border-color: #2196F3;
    background-color: #e3f2fd;
}

.role-button[data-role="patient"]:not(.selected):hover {
    border-color: #FF9800;
    background-color: #fff3e0;
}

.role-button[data-role="observer"]:not(.selected):hover {
    border-color: #9C27B0;
    background-color: #f3e5f5;
}

.role-button[data-role="admin"]:not(.selected):hover {
    border-color: #F44336;
    background-color: #ffebee;
}

/* --- Authentication Form --- */
.auth-form {
    margin: 25px 0;
}

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

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

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

.form-group input:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.form-group input::placeholder {
    color: #95a5a6;
}

.form-group input[type="email"] {
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="%23999" viewBox="0 0 16 16"><path d="M0 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V4zm2-1a1 1 0 0 0-1 1v.217l7 4.2 7-4.2V4a1 1 0 0 0-1-1H2zm13 2.383-4.758 2.855L15 11.114v-5.73zm-.034 6.878L9.271 8.82 8 9.583 6.728 8.82l-5.694 3.44A1 1 0 0 0 2 13h12a1 1 0 0 0 .966-.739zM1 11.114l4.758-2.876L1 5.383v5.73z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

.form-group input[type="password"] {
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="%23999" viewBox="0 0 16 16"><path d="M8 1a2 2 0 0 1 2 2v4H6V3a2 2 0 0 1 2-2zm3 6V3a3 3 0 0 0-6 0v4a2 2 0 0 0-2 2v5a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

/* --- Authentication Toggle --- */
.auth-toggle {
    margin: 20px 0;
    color: #666;
    font-size: 14px;
}

.auth-toggle a {
    color: #4CAF50;
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.auth-toggle a:hover {
    color: #45a049;
    text-decoration: underline;
}

/* --- Buttons --- */
.auth-buttons {
    margin-top: 25px;
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.auth-button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 110px;
    position: relative;
}

.auth-button.primary {
    background-color: #4CAF50;
    color: white;
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.2);
}

.auth-button.primary:hover {
    background-color: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.3);
}

.auth-button.secondary {
    background-color: #f8f9fa;
    color: #495057;
    border: 2px solid #e0e6ed;
}

.auth-button.secondary:hover {
    background-color: #e9ecef;
    border-color: #ced4da;
}

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

.auth-button.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    margin: auto;
    border: 2px solid transparent;
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: button-loading-spinner 1s ease infinite;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}

@keyframes button-loading-spinner {
    from {
        transform: translateY(-50%) rotate(0turn);
    }
    to {
        transform: translateY(-50%) rotate(1turn);
    }
}

/* --- Messages --- */
.message {
    padding: 12px 15px;
    border-radius: 6px;
    margin: 15px 0;
    font-size: 14px;
    font-weight: 500;
    display: none;
    animation: messageSlideIn 0.3s ease-out;
}

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

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

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

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

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

/* --- User Info Display --- */
#userInfo {
    position: absolute;
    top: 60px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.8);
    color: #ffffff;
    padding: 12px;
    border-radius: 8px;
    font-size: 12px;
    z-index: 101;
    display: none;
    backdrop-filter: blur(2px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.user-role {
    font-weight: bold;
    text-transform: capitalize;
    color: #4CAF50;
    font-size: 14px;
    margin-bottom: 4px;
}

#userEmail {
    opacity: 0.8;
    font-size: 11px;
    margin-bottom: 8px;
}

.logout-button {
    background-color: #f44336;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    width: 100%;
}

.logout-button:hover {
    background-color: #d32f2f;
}

/* --- Loading States --- */
.auth-loading {
    pointer-events: none;
    opacity: 0.7;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    z-index: 10;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* --- Responsive Design --- */
@media (max-width: 480px) {
    #authContainer {
        margin: 20px;
        padding: 25px 20px;
        max-width: none;
        width: auto;
    }
    
    .role-selection {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .role-button {
        min-height: 60px;
        padding: 12px;
    }
    
    .auth-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .auth-button {
        width: 100%;
        max-width: 200px;
    }
}

/* --- Accessibility --- */
.auth-button:focus,
.role-button:focus,
.form-group input:focus {
    outline: 2px solid #4CAF50;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    #authContainer {
        border: 2px solid #000;
    }
    
    .role-button {
        border-width: 3px;
    }
    
    .form-group input {
        border-width: 3px;
    }
}

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