/* ===== Authentication Modal & Forms ===== */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.auth-overlay.active {
    display: flex;
    opacity: 1;
}

.auth-container {
    position: relative;
    width: 100%;
    max-width: 450px;
    height: 660px;
    perspective: 1000px;
    overflow: visible !important; /* Allow tiny card to show outside */
}

.auth-card {
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--white);
    border-radius: 24px;
    box-shadow: var(--shadow-xl);
    padding: 0;
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Scrollable form content — invisible scrollbar */
.auth-card.form-main .form-content {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    scrollbar-width: none;       /* Firefox */
    -ms-overflow-style: none;    /* IE/Edge */
}

.auth-card.form-main .form-content::-webkit-scrollbar {
    display: none;               /* Chrome, Safari */
}

/* Close button needs its own padding context now */
.auth-card.form-main > .close-auth {
    top: 15px;
    right: 15px;
}

/* Main State */
.auth-card.form-main {
    z-index: 2;
    transform: translateZ(0) scale(1);
    opacity: 1;
    pointer-events: all;
}

/* Tiny State */
.auth-card.form-tiny {
    z-index: 3;
    width: 100%;
    height: 100%;
    top: 20px;
    left: 100%;
    margin-left: 20px; /* Position outside the main form */
    padding: 40px;
    cursor: pointer;
    background: var(--white) !important;
    color: var(--dark);
    transform: scale(0.3);
    transform-origin: top left;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--gray-light);
    pointer-events: all;
    opacity: 0.9;
}

.auth-card.form-tiny:hover {
    transform: scale(0.32); /* Maintain tiny scale on hover */
    opacity: 1;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

/* Content in tiny state */
.auth-card.form-tiny .form-content {
    opacity: 1;
    pointer-events: none;
}

/* Labels for tiny state (optional indicator) */
.auth-card.form-tiny::before {
    content: "SWITCH TO " attr(id);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(20, 184, 166, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 900;
    color: var(--primary);
    opacity: 0;
    transition: 0.3s;
    z-index: 10;
    text-transform: uppercase;
}

.auth-card.form-tiny:hover::before {
    opacity: 1;
}

/* Inactive State (hidden behind main) */
.auth-card.form-inactive {
    z-index: 1;
    transform: translateZ(-100px) scale(0.8);
    opacity: 0;
    pointer-events: none;
}

/* Form Elements */
.auth-header {
    margin-bottom: 30px;
}

.auth-header h2 {
    font-size: 1.75rem;
    color: var(--dark);
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--gray);
    font-size: 0.95rem;
}

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

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--dark);
}

.form-control-modern {
    width: 100%;
    padding: 12px 16px;
    background: #f1f5f9;
    border: 2px solid transparent;
    border-radius: 12px;
    font-size: 1rem;
    transition: var(--transition);
}

.form-control-modern:focus {
    background: var(--white);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.1);
    outline: none;
}

.btn-auth {
    width: 100%;
    padding: 14px;
    background: var(--gradient-teal);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    margin-top: 10px;
    transition: var(--transition);
    cursor: pointer;
}

.btn-auth:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(20, 184, 166, 0.3);
}

.forgot-link {
    font-size: 0.8rem;
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

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

.security-text {
    margin-top: 20px;
    font-size: 0.75rem;
    color: var(--gray);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
}

.security-text i {
    color: var(--success);
}

.close-auth {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.05);
    color: var(--dark);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    z-index: 10;
}

.close-auth:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: rotate(90deg);
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .auth-container {
        max-width: 90%;
        height: auto;
        min-height: 640px;
    }
    
    .auth-card {
        padding: 30px 20px;
    }
    
    .auth-card.form-tiny {
        width: 100px;
        height: 120px;
        top: 10px;
        right: 10px;
    }
}

/* ===== Password Input Wrapper ===== */
.password-wrapper {
    position: relative;
}

.password-wrapper .form-control-modern {
    padding-right: 46px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 14px;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #64748b;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
    transition: color 0.2s ease;
    z-index: 5;
}

.password-toggle:hover {
    color: var(--primary, #14b8a6);
}

/* ===== Field Validation Styles ===== */
.form-control-modern.is-invalid {
    border-color: #ef4444 !important;
    background: #fff5f5;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.form-control-modern.is-valid {
    border-color: #22c55e !important;
    background: #f0fdf4;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.12);
}

.field-error {
    font-size: 0.76rem;
    color: #ef4444;
    margin-top: 4px;
    display: block;
    font-weight: 500;
}

/* ===== Password Strength Indicator ===== */
.strength-wrapper {
    margin-top: 8px;
}

.strength-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 4px;
}

.strength-bar span {
    flex: 1;
    height: 4px;
    border-radius: 4px;
    background: #e2e8f0;
    transition: background 0.3s ease;
}

.strength-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* strength levels */
.strength-weak   .strength-bar span:nth-child(1) { background: #ef4444; }
.strength-fair   .strength-bar span:nth-child(1),
.strength-fair   .strength-bar span:nth-child(2) { background: #f97316; }
.strength-good   .strength-bar span:nth-child(1),
.strength-good   .strength-bar span:nth-child(2),
.strength-good   .strength-bar span:nth-child(3) { background: #eab308; }
.strength-strong .strength-bar span { background: #22c55e; }

.strength-weak   .strength-label { color: #ef4444; }
.strength-fair   .strength-label { color: #f97316; }
.strength-good   .strength-label { color: #eab308; }
.strength-strong .strength-label { color: #22c55e; }
