/* 
 * Generic Authentication Styles
 * File: static/css/auth-styles.css
 * 
 * Reusable styles for all authentication forms:
 * - Login, Signup, Forgot Password, Reset Password, etc.
 * - Uses CSS custom properties for consistent theming
 * - Dynamic sizing based on form content
 */

/* Main Container */
.auth-container {
    min-height: 100vh;
    background: var(--light);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-card {
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(10, 132, 199, 0.15);
    overflow: hidden;
    min-height: 400px; /* Reduced for flexibility */
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

/* Make the card content flexible */
.auth-card .row {
    flex: 1;
    min-height: inherit;
}

/* Brand Section */
.auth-brand-section {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    position: relative;
    min-height: 400px; /* Ensure minimum height */
}

.auth-brand-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0.05;
}

.brand-content {
    text-align: center;
    position: relative;
    z-index: 1;
}

.brand-logo {
    margin-bottom: 0;
}

.logo-img {
    max-width: 280px;
    height: auto;
    width: 100%;
}

/* Form Section - Dynamic sizing */
.auth-form-section {
    padding: 3rem 2rem; /* Reduced padding for smaller forms */
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px; /* Ensure minimum height */
    flex: 1; /* Allow growth */
}

/* Dynamic padding based on form size */
.auth-form-section.large-form {
    padding: 2rem 1.5rem;
}

.auth-form-section.small-form {
    padding: 4rem 3rem;
}

.form-content {
    width: 100%;
    max-width: 420px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.form-header {
    text-align: center;
    margin-bottom: 2rem;
    flex-shrink: 0; /* Prevent shrinking */
}

.welcome-title {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 0.5rem;
}

.welcome-subtitle {
    color: var(--dark-gray);
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

/* Form Elements - Dynamic spacing */
.form-group {
    margin-bottom: 1.5rem; /* Base spacing */
}

/* Adjust spacing for forms with many fields */
.form-content.many-fields .form-group {
    margin-bottom: 1.25rem;
}

/* Adjust spacing for forms with few fields */
.form-content.few-fields .form-group {
    margin-bottom: 2rem;
}

.form-label {
    font-weight: 500;
    color: var(--dark);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.input-group {
    position: relative;
}

.input-group-text {
    background: var(--light);
    border: 1px solid var(--medium-gray);
    border-right: none;
    border-radius: 8px 0 0 8px;
    padding: 0.75rem 1rem;
    color: var(--dark-gray);
}

.form-control {
    border: 1px solid var(--medium-gray);
    border-radius: 0 8px 8px 0;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    background: var(--white);
    color: var(--dark);
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(10, 132, 199, 0.25);
    outline: none;
}

.form-control.is-invalid {
    border-color: var(--danger);
}

/* Select/Dropdown Styling */
select.form-control,
select.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.25em 1.25em;
    padding-right: 2.5rem;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
}

select.form-control:focus,
select.form-select:focus {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%230A84C7' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
}

select.form-control option,
select.form-select option {
    padding: 0.5rem 0.75rem;
    color: var(--dark);
    background: var(--white);
}

select.form-control option:hover,
select.form-control option:focus,
select.form-select option:hover,
select.form-select option:focus {
    background: var(--light);
    color: var(--primary);
}

/* Placeholder styling for select */
select.form-control option[value=""],
select.form-select option[value=""] {
    color: var(--dark-gray);
    font-style: italic;
}

/* Apply form-control styles to form-select for consistency */
.form-select {
    border: 1px solid var(--medium-gray);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    background: var(--white);
    color: var(--dark);
}

.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(10, 132, 199, 0.25);
    outline: none;
}

.form-select.is-invalid {
    border-color: var(--danger);
}

/* Password Toggle Button */
.password-toggle {
    border-left: none;
    border-radius: 0 8px 8px 0;
    background: var(--light);
    color: var(--dark-gray);
    transition: all 0.3s ease;
    border: 1px solid var(--medium-gray);
}

.password-toggle:hover {
    background: var(--medium-gray);
    color: var(--dark);
}

.password-toggle:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(10, 132, 199, 0.25);
}

/* Links */
.auth-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
}

.auth-link:hover,
.auth-link:focus {
    text-decoration: underline;
    color: var(--primary-dark);
}

.forgot-password-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
}

.forgot-password-link:hover,
.forgot-password-link:focus {
    text-decoration: underline;
    color: var(--primary-dark);
}

/* Checkboxes */
.form-check-input {
    margin-top: 0.25rem;
}

.form-check-label {
    color: var(--dark-gray);
    font-size: 0.9rem;
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.form-check-input:focus {
    border-color: var(--primary);
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(10, 132, 199, 0.25);
}

/* Auth Button Extensions - now inherit from global button system */
.btn-auth-primary {
    /* Inherits gradient styling from global .btn-primary system */
    /* All gradient, hover, and shadow effects come from global system */
    position: relative;
    overflow: hidden;
}

.btn-auth-secondary {
    /* Inherits outline styling from global .btn-secondary/.btn-outline-primary system */
    /* All outline and hover gradient effects come from global system */
}

/* Button Loading State */
.btn-spinner {
    display: none;
}

.btn-loading {
    color: var(--primary) !important;
    background: var(--white) !important;
    border-color: var(--primary) !important;
    pointer-events: none;
    position: relative;
}

.btn-loading .btn-text {
    opacity: 0;
}

.btn-loading .btn-spinner {
    display: inline;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: var(--primary);
}

.btn-loading:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* Auth Text Links */
.auth-text {
    color: var(--dark-gray);
    font-size: 0.9rem;
    margin-bottom: 0;
}

.auth-text-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-text-link:hover,
.auth-text-link:focus {
    text-decoration: underline;
    color: var(--primary-dark);
}

/* Alerts - Using CSS variables */
.alert {
    border-radius: 8px;
    border: none;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-success {
    background-color: rgba(40, 167, 69, 0.1);
    color: var(--success);
    border: 1px solid rgba(40, 167, 69, 0.2);
}

.alert-warning {
    background-color: rgba(255, 193, 7, 0.1);
    color: #856404;
    border: 1px solid rgba(255, 193, 7, 0.2);
}

.alert-danger {
    background-color: rgba(220, 53, 69, 0.1);
    color: var(--danger);
    border: 1px solid rgba(220, 53, 69, 0.2);
}

.alert-info {
    background-color: rgba(23, 162, 184, 0.1);
    color: var(--info);
    border: 1px solid rgba(23, 162, 184, 0.2);
}

/* Error Messages */
.invalid-feedback {
    display: block;
    font-size: 0.8rem;
    color: var(--danger);
    margin-top: 0.25rem;
}

/* reCAPTCHA */
.g-recaptcha {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

/* Custom Column Layouts */
.brand-column {
    flex: 0 0 40%;
    max-width: 40%;
}

.form-column {
    flex: 0 0 60%;
    max-width: 60%;
}

/* Form Size Variants */
.auth-card.compact {
    min-height: 350px;
}

.auth-card.expanded {
    min-height: 600px;
}

.auth-card.large {
    max-width: 1000px;
    min-height: 650px;
}

/* Responsive Design */
@media (max-width: 1200px) {
    /* Adjust for smaller screens */
    .auth-card.extra-wide {
        max-width: 1100px;
    }
    
    .auth-card.large {
        max-width: 1000px;
    }
}

@media (max-width: 992px) {
    /* Tablet adjustments */
    .auth-card.expanded,
    .auth-card.large,
    .auth-card.extra-wide {
        max-width: 95%;
    }
}

@media (max-width: 768px) {
    .auth-brand-section {
        display: none;
    }
    
    .brand-column,
    .form-column {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
    
    .auth-form-section {
        padding: 2rem 1.5rem;
        min-height: auto; /* Remove fixed height on mobile */
    }
    
    .auth-card {
        margin: 0;
        border-radius: 12px;
        min-height: auto; /* Let content determine height */
        max-width: 100% !important; /* Full width on mobile */
    }
    
    .welcome-title {
        font-size: 1.5rem;
    }
    
    .form-content {
        max-width: 100% !important; /* Full width form content on mobile */
    }
    
    /* Adjust spacing for mobile */
    .form-content.many-fields .form-group {
        margin-bottom: 1rem;
    }
    
    .form-content.few-fields .form-group {
        margin-bottom: 1.5rem;
    }
}

@media (max-width: 576px) {
    .auth-container {
        padding: 1rem;
    }
    
    .auth-form-section {
        padding: 1.5rem 1rem;
    }
    
    .form-content {
        max-width: 100%;
    }
    
    .auth-card {
        margin: 0;
        border-radius: 12px;
    }
    
    /* Compact spacing on small screens */
    .form-group {
        margin-bottom: 1.25rem;
    }
    
    .form-header {
        margin-bottom: 1.5rem;
    }
}

/* Enhanced Visual Elements */
.form-control::placeholder {
    color: var(--dark-gray);
    opacity: 0.7;
    font-size: 0.9rem;
}

.input-group-text i {
    font-size: 0.9rem;
}

.form-control:focus + .password-toggle {
    border-color: var(--primary);
}

/* Accessibility Improvements */
.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;
}

/* Focus indicators for keyboard navigation */
*:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Skip to content link for screen readers */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary);
    color: var(--white);
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
}

.skip-link:focus {
    top: 6px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .auth-card {
        border: 2px solid var(--dark);
    }
    
    .form-control {
        border: 2px solid var(--dark);
    }
    
    .btn-auth-primary {
        border: 2px solid var(--dark);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .btn-auth-primary:hover {
        transform: none;
    }
}

/* Utility classes for dynamic form sizing */
.auth-form-dense {
    /* For forms with many fields - tighter spacing */
}

.auth-form-dense .form-group {
    margin-bottom: 1rem;
}

.auth-form-dense .form-header {
    margin-bottom: 1.5rem;
}

.auth-form-dense .auth-form-section {
    padding: 2rem 2rem;
}

.auth-form-spacious {
    /* For forms with few fields - more spacing */
}

.auth-form-spacious .form-group {
    margin-bottom: 2.5rem;
}

.auth-form-spacious .form-header {
    margin-bottom: 3rem;
}

.auth-form-spacious .auth-form-section {
    padding: 4rem 3rem;
}

/* Additional spacing utilities */
.auth-form-comfortable {
    /* Balanced spacing for medium complexity forms */
}

.auth-form-comfortable .form-group {
    margin-bottom: 1.75rem;
}

.auth-form-comfortable .form-header {
    margin-bottom: 2.5rem;
}

.auth-form-comfortable .auth-form-section {
    padding: 3rem 2.5rem;
}

/* Container width utilities */
.auth-container.full-width {
    max-width: none;
    padding: 2rem 1rem;
}

.auth-container.constrained {
    max-width: 1400px;
    margin: 0 auto;
}

/* Form layout utilities */
.form-layout-wide .form-content {
    max-width: 650px;
}

.form-layout-narrow .form-content {
    max-width: 400px;
}

.form-layout-balanced .form-content {
    max-width: 520px;
}

/* Loading Overlay */
.loading-overlay {
    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: 9999;
}

.loading-overlay .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Button Loading States */
.btn .spinner-border-sm {
    width: 1rem;
    height: 1rem;
    margin-right: 0.5rem;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}